{ "cells": [ { "cell_type": "code", "execution_count": 1, "id": "0", "metadata": { "execution": { "iopub.execute_input": "2026-04-14T15:03:11.631193Z", "iopub.status.busy": "2026-04-14T15:03:11.630982Z", "iopub.status.idle": "2026-04-14T15:03:11.635518Z", "shell.execute_reply": "2026-04-14T15:03:11.634803Z" }, "tags": [ "hide-in-docs" ] }, "outputs": [], "source": [ "# Check whether easydiffraction is installed; install it if needed.\n", "# Required for remote environments such as Google Colab.\n", "import importlib.util\n", "\n", "if importlib.util.find_spec('easydiffraction') is None:\n", " %pip install easydiffraction==0.13.1" ] }, { "cell_type": "markdown", "id": "1", "metadata": {}, "source": [ "# Structure Refinement: PbSO4, NPD + XRD\n", "\n", "This example demonstrates a more advanced use of the EasyDiffraction\n", "library by explicitly creating and configuring structures and\n", "experiments before adding them to a project. It could be more suitable\n", "for users who are interested in creating custom workflows. This\n", "tutorial provides minimal explanation and is intended for users\n", "already familiar with EasyDiffraction.\n", "\n", "The tutorial covers a Rietveld refinement of PbSO4 crystal structure\n", "based on the joint fit of both X-ray and neutron diffraction data." ] }, { "cell_type": "markdown", "id": "2", "metadata": {}, "source": [ "## Import Library" ] }, { "cell_type": "code", "execution_count": 2, "id": "3", "metadata": { "execution": { "iopub.execute_input": "2026-04-14T15:03:11.637437Z", "iopub.status.busy": "2026-04-14T15:03:11.637238Z", "iopub.status.idle": "2026-04-14T15:03:14.271300Z", "shell.execute_reply": "2026-04-14T15:03:14.270360Z" } }, "outputs": [], "source": [ "from easydiffraction import ExperimentFactory\n", "from easydiffraction import Project\n", "from easydiffraction import StructureFactory\n", "from easydiffraction import download_data" ] }, { "cell_type": "markdown", "id": "4", "metadata": {}, "source": [ "## Define Structure\n", "\n", "This section shows how to add structures and modify their\n", "parameters.\n", "\n", "#### Create Structure" ] }, { "cell_type": "code", "execution_count": 3, "id": "5", "metadata": { "execution": { "iopub.execute_input": "2026-04-14T15:03:14.273275Z", "iopub.status.busy": "2026-04-14T15:03:14.272831Z", "iopub.status.idle": "2026-04-14T15:03:14.278065Z", "shell.execute_reply": "2026-04-14T15:03:14.277120Z" } }, "outputs": [], "source": [ "structure = StructureFactory.from_scratch(name='pbso4')" ] }, { "cell_type": "markdown", "id": "6", "metadata": {}, "source": [ "#### Set Space Group" ] }, { "cell_type": "code", "execution_count": 4, "id": "7", "metadata": { "execution": { "iopub.execute_input": "2026-04-14T15:03:14.279790Z", "iopub.status.busy": "2026-04-14T15:03:14.279607Z", "iopub.status.idle": "2026-04-14T15:03:14.283218Z", "shell.execute_reply": "2026-04-14T15:03:14.282456Z" } }, "outputs": [], "source": [ "structure.space_group.name_h_m = 'P n m a'" ] }, { "cell_type": "markdown", "id": "8", "metadata": {}, "source": [ "#### Set Unit Cell" ] }, { "cell_type": "code", "execution_count": 5, "id": "9", "metadata": { "execution": { "iopub.execute_input": "2026-04-14T15:03:14.284931Z", "iopub.status.busy": "2026-04-14T15:03:14.284753Z", "iopub.status.idle": "2026-04-14T15:03:14.288003Z", "shell.execute_reply": "2026-04-14T15:03:14.287073Z" } }, "outputs": [], "source": [ "structure.cell.length_a = 8.47\n", "structure.cell.length_b = 5.39\n", "structure.cell.length_c = 6.95" ] }, { "cell_type": "markdown", "id": "10", "metadata": {}, "source": [ "#### Set Atom Sites" ] }, { "cell_type": "code", "execution_count": 6, "id": "11", "metadata": { "execution": { "iopub.execute_input": "2026-04-14T15:03:14.289529Z", "iopub.status.busy": "2026-04-14T15:03:14.289370Z", "iopub.status.idle": "2026-04-14T15:03:14.296951Z", "shell.execute_reply": "2026-04-14T15:03:14.296091Z" }, "lines_to_next_cell": 2 }, "outputs": [], "source": [ "structure.atom_sites.create(\n", " label='Pb',\n", " type_symbol='Pb',\n", " fract_x=0.1876,\n", " fract_y=0.25,\n", " fract_z=0.167,\n", " wyckoff_letter='c',\n", " adp_iso=1.37,\n", ")\n", "structure.atom_sites.create(\n", " label='S',\n", " type_symbol='S',\n", " fract_x=0.0654,\n", " fract_y=0.25,\n", " fract_z=0.684,\n", " wyckoff_letter='c',\n", " adp_iso=0.3777,\n", ")\n", "structure.atom_sites.create(\n", " label='O1',\n", " type_symbol='O',\n", " fract_x=0.9082,\n", " fract_y=0.25,\n", " fract_z=0.5954,\n", " wyckoff_letter='c',\n", " adp_iso=1.9764,\n", ")\n", "structure.atom_sites.create(\n", " label='O2',\n", " type_symbol='O',\n", " fract_x=0.1935,\n", " fract_y=0.25,\n", " fract_z=0.5432,\n", " wyckoff_letter='c',\n", " adp_iso=1.4456,\n", ")\n", "structure.atom_sites.create(\n", " label='O3',\n", " type_symbol='O',\n", " fract_x=0.0811,\n", " fract_y=0.0272,\n", " fract_z=0.8086,\n", " wyckoff_letter='d',\n", " adp_iso=1.2822,\n", ")" ] }, { "cell_type": "markdown", "id": "12", "metadata": {}, "source": [ "## Define Experiments\n", "\n", "This section shows how to add experiments, configure their parameters,\n", "and link the structures defined in the previous step.\n", "\n", "### Experiment 1: npd\n", "\n", "#### Download Data" ] }, { "cell_type": "code", "execution_count": 7, "id": "13", "metadata": { "execution": { "iopub.execute_input": "2026-04-14T15:03:14.298496Z", "iopub.status.busy": "2026-04-14T15:03:14.298333Z", "iopub.status.idle": "2026-04-14T15:03:14.539270Z", "shell.execute_reply": "2026-04-14T15:03:14.538412Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\u001b[1;34mGetting data\u001b[0m\u001b[1;34m...\u001b[0m\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "Data #\u001b[1;36m13\u001b[0m: PbSO4, D1A \u001b[1m(\u001b[0mILL\u001b[1m)\u001b[0m\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "✅ Data #\u001b[1;36m13\u001b[0m downloaded to \u001b[32m'data/ed-13.dat'\u001b[0m\n" ] } ], "source": [ "data_path1 = download_data(id=13, destination='data')" ] }, { "cell_type": "markdown", "id": "14", "metadata": {}, "source": [ "#### Create Experiment" ] }, { "cell_type": "code", "execution_count": 8, "id": "15", "metadata": { "execution": { "iopub.execute_input": "2026-04-14T15:03:14.540936Z", "iopub.status.busy": "2026-04-14T15:03:14.540755Z", "iopub.status.idle": "2026-04-14T15:03:14.713041Z", "shell.execute_reply": "2026-04-14T15:03:14.712179Z" } }, "outputs": [], "source": [ "expt1 = ExperimentFactory.from_data_path(\n", " name='npd',\n", " data_path=data_path1,\n", " radiation_probe='neutron',\n", ")" ] }, { "cell_type": "markdown", "id": "16", "metadata": {}, "source": [ "#### Set Instrument" ] }, { "cell_type": "code", "execution_count": 9, "id": "17", "metadata": { "execution": { "iopub.execute_input": "2026-04-14T15:03:14.714934Z", "iopub.status.busy": "2026-04-14T15:03:14.714759Z", "iopub.status.idle": "2026-04-14T15:03:14.717978Z", "shell.execute_reply": "2026-04-14T15:03:14.717258Z" } }, "outputs": [], "source": [ "expt1.instrument.setup_wavelength = 1.91\n", "expt1.instrument.calib_twotheta_offset = -0.1406" ] }, { "cell_type": "markdown", "id": "18", "metadata": {}, "source": [ "#### Set Peak Profile" ] }, { "cell_type": "code", "execution_count": 10, "id": "19", "metadata": { "execution": { "iopub.execute_input": "2026-04-14T15:03:14.719522Z", "iopub.status.busy": "2026-04-14T15:03:14.719361Z", "iopub.status.idle": "2026-04-14T15:03:14.722840Z", "shell.execute_reply": "2026-04-14T15:03:14.722007Z" } }, "outputs": [], "source": [ "expt1.peak.broad_gauss_u = 0.139\n", "expt1.peak.broad_gauss_v = -0.412\n", "expt1.peak.broad_gauss_w = 0.386\n", "expt1.peak.broad_lorentz_x = 0\n", "expt1.peak.broad_lorentz_y = 0.088" ] }, { "cell_type": "markdown", "id": "20", "metadata": {}, "source": [ "#### Set Background" ] }, { "cell_type": "markdown", "id": "21", "metadata": {}, "source": [ "Select the background type." ] }, { "cell_type": "code", "execution_count": 11, "id": "22", "metadata": { "execution": { "iopub.execute_input": "2026-04-14T15:03:14.724647Z", "iopub.status.busy": "2026-04-14T15:03:14.724490Z", "iopub.status.idle": "2026-04-14T15:03:14.729901Z", "shell.execute_reply": "2026-04-14T15:03:14.729146Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\u001b[1;34mBackground type for experiment \u001b[0m\u001b[32m'npd'\u001b[0m\u001b[1;34m already set to\u001b[0m\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "line-segment\n" ] } ], "source": [ "expt1.background_type = 'line-segment'" ] }, { "cell_type": "markdown", "id": "23", "metadata": {}, "source": [ "Add background points." ] }, { "cell_type": "code", "execution_count": 12, "id": "24", "metadata": { "execution": { "iopub.execute_input": "2026-04-14T15:03:14.731388Z", "iopub.status.busy": "2026-04-14T15:03:14.731226Z", "iopub.status.idle": "2026-04-14T15:03:14.736439Z", "shell.execute_reply": "2026-04-14T15:03:14.735651Z" } }, "outputs": [], "source": [ "for id, x, y in [\n", " ('1', 11.0, 206.1624),\n", " ('2', 15.0, 194.75),\n", " ('3', 20.0, 194.505),\n", " ('4', 30.0, 188.4375),\n", " ('5', 50.0, 207.7633),\n", " ('6', 70.0, 201.7002),\n", " ('7', 120.0, 244.4525),\n", " ('8', 153.0, 226.0595),\n", "]:\n", " expt1.background.create(id=id, x=x, y=y)" ] }, { "cell_type": "markdown", "id": "25", "metadata": {}, "source": [ "#### Set Linked Phases" ] }, { "cell_type": "code", "execution_count": 13, "id": "26", "metadata": { "execution": { "iopub.execute_input": "2026-04-14T15:03:14.738291Z", "iopub.status.busy": "2026-04-14T15:03:14.738102Z", "iopub.status.idle": "2026-04-14T15:03:14.741274Z", "shell.execute_reply": "2026-04-14T15:03:14.740394Z" } }, "outputs": [], "source": [ "expt1.linked_phases.create(id='pbso4', scale=1.5)" ] }, { "cell_type": "markdown", "id": "27", "metadata": {}, "source": [ "### Experiment 2: xrd\n", "\n", "#### Download Data" ] }, { "cell_type": "code", "execution_count": 14, "id": "28", "metadata": { "execution": { "iopub.execute_input": "2026-04-14T15:03:14.742824Z", "iopub.status.busy": "2026-04-14T15:03:14.742633Z", "iopub.status.idle": "2026-04-14T15:03:14.916639Z", "shell.execute_reply": "2026-04-14T15:03:14.915652Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\u001b[1;34mGetting data\u001b[0m\u001b[1;34m...\u001b[0m\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "Data #\u001b[1;36m16\u001b[0m: PbSO4, laboratory X-ray\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "✅ Data #\u001b[1;36m16\u001b[0m downloaded to \u001b[32m'data/ed-16.dat'\u001b[0m\n" ] } ], "source": [ "data_path2 = download_data(id=16, destination='data')" ] }, { "cell_type": "markdown", "id": "29", "metadata": {}, "source": [ "#### Create Experiment" ] }, { "cell_type": "code", "execution_count": 15, "id": "30", "metadata": { "execution": { "iopub.execute_input": "2026-04-14T15:03:14.918457Z", "iopub.status.busy": "2026-04-14T15:03:14.918227Z", "iopub.status.idle": "2026-04-14T15:03:15.199644Z", "shell.execute_reply": "2026-04-14T15:03:15.198789Z" } }, "outputs": [], "source": [ "expt2 = ExperimentFactory.from_data_path(\n", " name='xrd',\n", " data_path=data_path2,\n", " radiation_probe='xray',\n", ")" ] }, { "cell_type": "markdown", "id": "31", "metadata": {}, "source": [ "#### Set Instrument" ] }, { "cell_type": "code", "execution_count": 16, "id": "32", "metadata": { "execution": { "iopub.execute_input": "2026-04-14T15:03:15.201470Z", "iopub.status.busy": "2026-04-14T15:03:15.201280Z", "iopub.status.idle": "2026-04-14T15:03:15.205091Z", "shell.execute_reply": "2026-04-14T15:03:15.203951Z" } }, "outputs": [], "source": [ "expt2.instrument.setup_wavelength = 1.540567\n", "expt2.instrument.calib_twotheta_offset = -0.05181" ] }, { "cell_type": "markdown", "id": "33", "metadata": {}, "source": [ "#### Set Peak Profile" ] }, { "cell_type": "code", "execution_count": 17, "id": "34", "metadata": { "execution": { "iopub.execute_input": "2026-04-14T15:03:15.206749Z", "iopub.status.busy": "2026-04-14T15:03:15.206557Z", "iopub.status.idle": "2026-04-14T15:03:15.211375Z", "shell.execute_reply": "2026-04-14T15:03:15.210084Z" } }, "outputs": [], "source": [ "expt2.peak.broad_gauss_u = 0.304138\n", "expt2.peak.broad_gauss_v = -0.112622\n", "expt2.peak.broad_gauss_w = 0.021272\n", "expt2.peak.broad_lorentz_x = 0\n", "expt2.peak.broad_lorentz_y = 0.057691" ] }, { "cell_type": "markdown", "id": "35", "metadata": {}, "source": [ "#### Set Background" ] }, { "cell_type": "markdown", "id": "36", "metadata": {}, "source": [ "Select background type." ] }, { "cell_type": "code", "execution_count": 18, "id": "37", "metadata": { "execution": { "iopub.execute_input": "2026-04-14T15:03:15.213478Z", "iopub.status.busy": "2026-04-14T15:03:15.213170Z", "iopub.status.idle": "2026-04-14T15:03:15.251445Z", "shell.execute_reply": "2026-04-14T15:03:15.248331Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\u001b[1;34mBackground type for experiment \u001b[0m\u001b[32m'xrd'\u001b[0m\u001b[1;34m changed to\u001b[0m\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "chebyshev\n" ] } ], "source": [ "expt2.background_type = 'chebyshev'" ] }, { "cell_type": "markdown", "id": "38", "metadata": {}, "source": [ "Add background points." ] }, { "cell_type": "code", "execution_count": 19, "id": "39", "metadata": { "execution": { "iopub.execute_input": "2026-04-14T15:03:15.255912Z", "iopub.status.busy": "2026-04-14T15:03:15.255675Z", "iopub.status.idle": "2026-04-14T15:03:15.268185Z", "shell.execute_reply": "2026-04-14T15:03:15.264513Z" } }, "outputs": [], "source": [ "for id, x, y in [\n", " ('1', 0, 119.195),\n", " ('2', 1, 6.221),\n", " ('3', 2, -45.725),\n", " ('4', 3, 8.119),\n", " ('5', 4, 54.552),\n", " ('6', 5, -20.661),\n", "]:\n", " expt2.background.create(id=id, order=x, coef=y)" ] }, { "cell_type": "markdown", "id": "40", "metadata": {}, "source": [ "#### Set Linked Phases" ] }, { "cell_type": "code", "execution_count": 20, "id": "41", "metadata": { "execution": { "iopub.execute_input": "2026-04-14T15:03:15.270841Z", "iopub.status.busy": "2026-04-14T15:03:15.270543Z", "iopub.status.idle": "2026-04-14T15:03:15.280339Z", "shell.execute_reply": "2026-04-14T15:03:15.277448Z" } }, "outputs": [], "source": [ "expt2.linked_phases.create(id='pbso4', scale=0.001)" ] }, { "cell_type": "markdown", "id": "42", "metadata": {}, "source": [ "## Define Project\n", "\n", "The project object is used to manage structures, experiments, and\n", "analysis.\n", "\n", "#### Create Project" ] }, { "cell_type": "code", "execution_count": 21, "id": "43", "metadata": { "execution": { "iopub.execute_input": "2026-04-14T15:03:15.282438Z", "iopub.status.busy": "2026-04-14T15:03:15.282214Z", "iopub.status.idle": "2026-04-14T15:03:15.815147Z", "shell.execute_reply": "2026-04-14T15:03:15.814111Z" } }, "outputs": [ { "data": { "application/javascript": [ "\n", " (function() {\n", " var isDark = false;\n", "\n", " // Check JupyterLab theme\n", " if (document.body.classList.contains('jp-mod-dark') || \n", " document.body.classList.contains('theme-dark') ||\n", " document.body.classList.contains('vscode-dark')) {\n", " isDark = true;\n", " }\n", "\n", " // Check theme attribute\n", " var themeAttr = document.body.getAttribute('data-jp-theme-name');\n", " if (themeAttr && themeAttr.includes('dark')) {\n", " isDark = true;\n", " }\n", "\n", " // Check computed background color\n", " var notebookEl = document.querySelector('.jp-Notebook') || \n", " document.querySelector('.notebook_app') ||\n", " document.body;\n", " if (notebookEl) {\n", " var bgColor = window.getComputedStyle(notebookEl).backgroundColor;\n", " var rgb = bgColor.match(/\\d+/g);\n", " if (rgb && rgb.length >= 3) {\n", " var brightness = (parseInt(rgb[0]) + parseInt(rgb[1]) + parseInt(rgb[2])) / 3;\n", " if (brightness < 128) {\n", " isDark = true;\n", " }\n", " }\n", " }\n", "\n", " // Store result\n", " if (typeof IPython !== 'undefined' && IPython.notebook && IPython.notebook.kernel) {\n", " IPython.notebook.kernel.execute('_jupyter_dark_detect_result = ' + isDark);\n", " }\n", " })();\n", " " ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "application/javascript": [ "\n", " if (typeof IPython !== 'undefined' && IPython.notebook) {\n", " IPython.notebook.kernel.execute(\"_jupyter_dark_detect_result = \" + \n", " (document.body.classList.contains('theme-dark') || \n", " document.body.classList.contains('jp-mod-dark') ||\n", " (document.body.getAttribute('data-jp-theme-name') && \n", " document.body.getAttribute('data-jp-theme-name').includes('dark'))));\n", " }\n", " " ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "project = Project()" ] }, { "cell_type": "markdown", "id": "44", "metadata": {}, "source": [ "#### Add Structure" ] }, { "cell_type": "code", "execution_count": 22, "id": "45", "metadata": { "execution": { "iopub.execute_input": "2026-04-14T15:03:15.817201Z", "iopub.status.busy": "2026-04-14T15:03:15.816850Z", "iopub.status.idle": "2026-04-14T15:03:15.820403Z", "shell.execute_reply": "2026-04-14T15:03:15.819460Z" } }, "outputs": [], "source": [ "project.structures.add(structure)" ] }, { "cell_type": "markdown", "id": "46", "metadata": {}, "source": [ "#### Add Experiments" ] }, { "cell_type": "code", "execution_count": 23, "id": "47", "metadata": { "execution": { "iopub.execute_input": "2026-04-14T15:03:15.821987Z", "iopub.status.busy": "2026-04-14T15:03:15.821825Z", "iopub.status.idle": "2026-04-14T15:03:15.824695Z", "shell.execute_reply": "2026-04-14T15:03:15.823896Z" } }, "outputs": [], "source": [ "project.experiments.add(expt1)\n", "project.experiments.add(expt2)" ] }, { "cell_type": "markdown", "id": "48", "metadata": {}, "source": [ "## Perform Analysis\n", "\n", "This section outlines the analysis process, including how to configure\n", "calculation and fitting engines.\n", "\n", "#### Set Fit Mode" ] }, { "cell_type": "code", "execution_count": 24, "id": "49", "metadata": { "execution": { "iopub.execute_input": "2026-04-14T15:03:15.826361Z", "iopub.status.busy": "2026-04-14T15:03:15.826203Z", "iopub.status.idle": "2026-04-14T15:03:15.829751Z", "shell.execute_reply": "2026-04-14T15:03:15.828951Z" } }, "outputs": [], "source": [ "project.analysis.fit_mode.mode = 'joint'" ] }, { "cell_type": "markdown", "id": "50", "metadata": {}, "source": [ "#### Set Minimizer" ] }, { "cell_type": "code", "execution_count": 25, "id": "51", "metadata": { "execution": { "iopub.execute_input": "2026-04-14T15:03:15.831568Z", "iopub.status.busy": "2026-04-14T15:03:15.831413Z", "iopub.status.idle": "2026-04-14T15:03:15.836782Z", "shell.execute_reply": "2026-04-14T15:03:15.835882Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\u001b[1;34mCurrent minimizer changed to\u001b[0m\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "lmfit\n" ] } ], "source": [ "project.analysis.current_minimizer = 'lmfit'" ] }, { "cell_type": "markdown", "id": "52", "metadata": {}, "source": [ "#### Set Fitting Parameters\n", "\n", "Set structure parameters to be optimized." ] }, { "cell_type": "code", "execution_count": 26, "id": "53", "metadata": { "execution": { "iopub.execute_input": "2026-04-14T15:03:15.838346Z", "iopub.status.busy": "2026-04-14T15:03:15.838119Z", "iopub.status.idle": "2026-04-14T15:03:15.842074Z", "shell.execute_reply": "2026-04-14T15:03:15.841160Z" } }, "outputs": [], "source": [ "structure.cell.length_a.free = True\n", "structure.cell.length_b.free = True\n", "structure.cell.length_c.free = True" ] }, { "cell_type": "markdown", "id": "54", "metadata": {}, "source": [ "Set experiment parameters to be optimized." ] }, { "cell_type": "code", "execution_count": 27, "id": "55", "metadata": { "execution": { "iopub.execute_input": "2026-04-14T15:03:15.843647Z", "iopub.status.busy": "2026-04-14T15:03:15.843490Z", "iopub.status.idle": "2026-04-14T15:03:15.846941Z", "shell.execute_reply": "2026-04-14T15:03:15.846240Z" } }, "outputs": [], "source": [ "expt1.linked_phases['pbso4'].scale.free = True\n", "\n", "expt1.instrument.calib_twotheta_offset.free = True\n", "\n", "expt1.peak.broad_gauss_u.free = True\n", "expt1.peak.broad_gauss_v.free = True\n", "expt1.peak.broad_gauss_w.free = True\n", "expt1.peak.broad_lorentz_y.free = True" ] }, { "cell_type": "code", "execution_count": 28, "id": "56", "metadata": { "execution": { "iopub.execute_input": "2026-04-14T15:03:15.848764Z", "iopub.status.busy": "2026-04-14T15:03:15.848592Z", "iopub.status.idle": "2026-04-14T15:03:15.852772Z", "shell.execute_reply": "2026-04-14T15:03:15.851779Z" } }, "outputs": [], "source": [ "expt2.linked_phases['pbso4'].scale.free = True\n", "\n", "expt2.instrument.calib_twotheta_offset.free = True\n", "\n", "expt2.peak.broad_gauss_u.free = True\n", "expt2.peak.broad_gauss_v.free = True\n", "expt2.peak.broad_gauss_w.free = True\n", "expt2.peak.broad_lorentz_y.free = True\n", "\n", "for term in expt2.background:\n", " term.coef.free = True" ] }, { "cell_type": "markdown", "id": "57", "metadata": {}, "source": [ "#### Perform Fit" ] }, { "cell_type": "markdown", "id": "58", "metadata": {}, "source": [ "#### Plot Measured vs Calculated" ] }, { "cell_type": "code", "execution_count": 29, "id": "59", "metadata": { "execution": { "iopub.execute_input": "2026-04-14T15:03:15.854349Z", "iopub.status.busy": "2026-04-14T15:03:15.854169Z", "iopub.status.idle": "2026-04-14T15:03:16.098255Z", "shell.execute_reply": "2026-04-14T15:03:16.097419Z" } }, "outputs": [ { "data": { "text/html": [ "
\n", "
" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "project.plotter.plot_meas_vs_calc(expt_name='npd', x_min=35.5, x_max=38.3, show_residual=True)" ] }, { "cell_type": "code", "execution_count": 30, "id": "60", "metadata": { "execution": { "iopub.execute_input": "2026-04-14T15:03:16.099807Z", "iopub.status.busy": "2026-04-14T15:03:16.099639Z", "iopub.status.idle": "2026-04-14T15:03:16.450562Z", "shell.execute_reply": "2026-04-14T15:03:16.449875Z" } }, "outputs": [ { "data": { "text/html": [ "
\n", "
" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "project.plotter.plot_meas_vs_calc(expt_name='xrd', x_min=29.0, x_max=30.4, show_residual=True)" ] } ], "metadata": { "jupytext": { "cell_metadata_filter": "-all", "main_language": "python", "notebook_metadata_filter": "-all" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.14.4" } }, "nbformat": 4, "nbformat_minor": 5 }