{ "cells": [ { "cell_type": "code", "execution_count": 1, "id": "0", "metadata": { "execution": { "iopub.execute_input": "2026-04-14T15:06:12.507564Z", "iopub.status.busy": "2026-04-14T15:06:12.507358Z", "iopub.status.idle": "2026-04-14T15:06:12.511296Z", "shell.execute_reply": "2026-04-14T15:06:12.510513Z" }, "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: LBCO+Si, McStas\n", "\n", "This example demonstrates a Rietveld refinement of La0.5Ba0.5CoO3\n", "crystal structure with a small amount of Si phase using time-of-flight\n", "neutron powder diffraction data simulated with McStas." ] }, { "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:06:12.513003Z", "iopub.status.busy": "2026-04-14T15:06:12.512828Z", "iopub.status.idle": "2026-04-14T15:06:15.139577Z", "shell.execute_reply": "2026-04-14T15:06:15.138653Z" } }, "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 Structures\n", "\n", "This section shows how to add structures and modify their\n", "parameters.\n", "\n", "### Create Structure 1: LBCO" ] }, { "cell_type": "code", "execution_count": 3, "id": "5", "metadata": { "execution": { "iopub.execute_input": "2026-04-14T15:06:15.141867Z", "iopub.status.busy": "2026-04-14T15:06:15.141476Z", "iopub.status.idle": "2026-04-14T15:06:15.146656Z", "shell.execute_reply": "2026-04-14T15:06:15.145651Z" } }, "outputs": [], "source": [ "structure_1 = StructureFactory.from_scratch(name='lbco')" ] }, { "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:06:15.148648Z", "iopub.status.busy": "2026-04-14T15:06:15.148361Z", "iopub.status.idle": "2026-04-14T15:06:15.152625Z", "shell.execute_reply": "2026-04-14T15:06:15.151553Z" } }, "outputs": [], "source": [ "structure_1.space_group.name_h_m = 'P m -3 m'\n", "structure_1.space_group.it_coordinate_system_code = '1'" ] }, { "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:06:15.154534Z", "iopub.status.busy": "2026-04-14T15:06:15.154318Z", "iopub.status.idle": "2026-04-14T15:06:15.158139Z", "shell.execute_reply": "2026-04-14T15:06:15.157088Z" } }, "outputs": [], "source": [ "structure_1.cell.length_a = 3.8909" ] }, { "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:06:15.159949Z", "iopub.status.busy": "2026-04-14T15:06:15.159736Z", "iopub.status.idle": "2026-04-14T15:06:15.167868Z", "shell.execute_reply": "2026-04-14T15:06:15.166847Z" } }, "outputs": [], "source": [ "structure_1.atom_sites.create(\n", " label='La',\n", " type_symbol='La',\n", " fract_x=0,\n", " fract_y=0,\n", " fract_z=0,\n", " wyckoff_letter='a',\n", " adp_iso=0.2,\n", " occupancy=0.5,\n", ")\n", "structure_1.atom_sites.create(\n", " label='Ba',\n", " type_symbol='Ba',\n", " fract_x=0,\n", " fract_y=0,\n", " fract_z=0,\n", " wyckoff_letter='a',\n", " adp_iso=0.2,\n", " occupancy=0.5,\n", ")\n", "structure_1.atom_sites.create(\n", " label='Co',\n", " type_symbol='Co',\n", " fract_x=0.5,\n", " fract_y=0.5,\n", " fract_z=0.5,\n", " wyckoff_letter='b',\n", " adp_iso=0.2567,\n", ")\n", "structure_1.atom_sites.create(\n", " label='O',\n", " type_symbol='O',\n", " fract_x=0,\n", " fract_y=0.5,\n", " fract_z=0.5,\n", " wyckoff_letter='c',\n", " adp_iso=1.4041,\n", ")" ] }, { "cell_type": "markdown", "id": "12", "metadata": {}, "source": [ "### Create Structure 2: Si" ] }, { "cell_type": "code", "execution_count": 7, "id": "13", "metadata": { "execution": { "iopub.execute_input": "2026-04-14T15:06:15.169797Z", "iopub.status.busy": "2026-04-14T15:06:15.169590Z", "iopub.status.idle": "2026-04-14T15:06:15.173997Z", "shell.execute_reply": "2026-04-14T15:06:15.172956Z" } }, "outputs": [], "source": [ "structure_2 = StructureFactory.from_scratch(name='si')" ] }, { "cell_type": "markdown", "id": "14", "metadata": {}, "source": [ "#### Set Space Group" ] }, { "cell_type": "code", "execution_count": 8, "id": "15", "metadata": { "execution": { "iopub.execute_input": "2026-04-14T15:06:15.175973Z", "iopub.status.busy": "2026-04-14T15:06:15.175767Z", "iopub.status.idle": "2026-04-14T15:06:15.179303Z", "shell.execute_reply": "2026-04-14T15:06:15.178300Z" } }, "outputs": [], "source": [ "structure_2.space_group.name_h_m = 'F d -3 m'\n", "structure_2.space_group.it_coordinate_system_code = '2'" ] }, { "cell_type": "markdown", "id": "16", "metadata": {}, "source": [ "#### Set Unit Cell" ] }, { "cell_type": "code", "execution_count": 9, "id": "17", "metadata": { "execution": { "iopub.execute_input": "2026-04-14T15:06:15.181218Z", "iopub.status.busy": "2026-04-14T15:06:15.180908Z", "iopub.status.idle": "2026-04-14T15:06:15.184794Z", "shell.execute_reply": "2026-04-14T15:06:15.183816Z" } }, "outputs": [], "source": [ "structure_2.cell.length_a = 5.43146" ] }, { "cell_type": "markdown", "id": "18", "metadata": {}, "source": [ "#### Set Atom Sites" ] }, { "cell_type": "code", "execution_count": 10, "id": "19", "metadata": { "execution": { "iopub.execute_input": "2026-04-14T15:06:15.186640Z", "iopub.status.busy": "2026-04-14T15:06:15.186435Z", "iopub.status.idle": "2026-04-14T15:06:15.192315Z", "shell.execute_reply": "2026-04-14T15:06:15.190834Z" } }, "outputs": [], "source": [ "structure_2.atom_sites.create(\n", " label='Si',\n", " type_symbol='Si',\n", " fract_x=0.0,\n", " fract_y=0.0,\n", " fract_z=0.0,\n", " wyckoff_letter='a',\n", " adp_iso=0.0,\n", ")" ] }, { "cell_type": "markdown", "id": "20", "metadata": {}, "source": [ "## Define Experiment\n", "\n", "This section shows how to add experiments, configure their parameters,\n", "and link the structures defined in the previous step.\n", "\n", "#### Download Data" ] }, { "cell_type": "code", "execution_count": 11, "id": "21", "metadata": { "execution": { "iopub.execute_input": "2026-04-14T15:06:15.193998Z", "iopub.status.busy": "2026-04-14T15:06:15.193811Z", "iopub.status.idle": "2026-04-14T15:06:15.411267Z", "shell.execute_reply": "2026-04-14T15:06:15.410396Z" } }, "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;36m8\u001b[0m: La0.5Ba0.5CoO3 + Si, McStas simulation\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "✅ Data #\u001b[1;36m8\u001b[0m downloaded to \u001b[32m'data/ed-8.xye'\u001b[0m\n" ] } ], "source": [ "data_path = download_data(id=8, destination='data')" ] }, { "cell_type": "markdown", "id": "22", "metadata": {}, "source": [ "#### Create Experiment" ] }, { "cell_type": "code", "execution_count": 12, "id": "23", "metadata": { "execution": { "iopub.execute_input": "2026-04-14T15:06:15.412852Z", "iopub.status.busy": "2026-04-14T15:06:15.412668Z", "iopub.status.idle": "2026-04-14T15:06:15.504530Z", "shell.execute_reply": "2026-04-14T15:06:15.503549Z" } }, "outputs": [], "source": [ "experiment = ExperimentFactory.from_data_path(\n", " name='mcstas',\n", " data_path=data_path,\n", " sample_form='powder',\n", " beam_mode='time-of-flight',\n", " radiation_probe='neutron',\n", " scattering_type='bragg',\n", ")" ] }, { "cell_type": "markdown", "id": "24", "metadata": {}, "source": [ "#### Set Instrument" ] }, { "cell_type": "code", "execution_count": 13, "id": "25", "metadata": { "execution": { "iopub.execute_input": "2026-04-14T15:06:15.506258Z", "iopub.status.busy": "2026-04-14T15:06:15.506041Z", "iopub.status.idle": "2026-04-14T15:06:15.509999Z", "shell.execute_reply": "2026-04-14T15:06:15.509234Z" } }, "outputs": [], "source": [ "experiment.instrument.setup_twotheta_bank = 94.90931761529106\n", "experiment.instrument.calib_d_to_tof_offset = 0.0\n", "experiment.instrument.calib_d_to_tof_linear = 58724.76869981215\n", "experiment.instrument.calib_d_to_tof_quad = -0.00001" ] }, { "cell_type": "markdown", "id": "26", "metadata": {}, "source": [ "#### Set Peak Profile" ] }, { "cell_type": "code", "execution_count": 14, "id": "27", "metadata": { "execution": { "iopub.execute_input": "2026-04-14T15:06:15.511556Z", "iopub.status.busy": "2026-04-14T15:06:15.511382Z", "iopub.status.idle": "2026-04-14T15:06:15.515098Z", "shell.execute_reply": "2026-04-14T15:06:15.514330Z" } }, "outputs": [], "source": [ "experiment.peak.broad_gauss_sigma_0 = 45137\n", "experiment.peak.broad_gauss_sigma_1 = -52394\n", "experiment.peak.broad_gauss_sigma_2 = 22998\n", "experiment.peak.exp_decay_beta_0 = 0.0055\n", "experiment.peak.exp_decay_beta_1 = 0.0041\n", "experiment.peak.exp_rise_alpha_0 = 0\n", "experiment.peak.exp_rise_alpha_1 = 0.0097" ] }, { "cell_type": "markdown", "id": "28", "metadata": {}, "source": [ "#### Set Background" ] }, { "cell_type": "markdown", "id": "29", "metadata": {}, "source": [ "Select the background type." ] }, { "cell_type": "code", "execution_count": 15, "id": "30", "metadata": { "execution": { "iopub.execute_input": "2026-04-14T15:06:15.516867Z", "iopub.status.busy": "2026-04-14T15:06:15.516691Z", "iopub.status.idle": "2026-04-14T15:06:15.522191Z", "shell.execute_reply": "2026-04-14T15:06:15.521203Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\u001b[1;34mBackground type for experiment \u001b[0m\u001b[32m'mcstas'\u001b[0m\u001b[1;34m already set to\u001b[0m\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "line-segment\n" ] } ], "source": [ "experiment.background_type = 'line-segment'" ] }, { "cell_type": "markdown", "id": "31", "metadata": {}, "source": [ "Add background points." ] }, { "cell_type": "code", "execution_count": 16, "id": "32", "metadata": { "execution": { "iopub.execute_input": "2026-04-14T15:06:15.523694Z", "iopub.status.busy": "2026-04-14T15:06:15.523512Z", "iopub.status.idle": "2026-04-14T15:06:15.531234Z", "shell.execute_reply": "2026-04-14T15:06:15.530256Z" } }, "outputs": [], "source": [ "experiment.background.create(id='1', x=45000, y=0.2)\n", "experiment.background.create(id='2', x=50000, y=0.2)\n", "experiment.background.create(id='3', x=55000, y=0.2)\n", "experiment.background.create(id='4', x=65000, y=0.2)\n", "experiment.background.create(id='5', x=70000, y=0.2)\n", "experiment.background.create(id='6', x=75000, y=0.2)\n", "experiment.background.create(id='7', x=80000, y=0.2)\n", "experiment.background.create(id='8', x=85000, y=0.2)\n", "experiment.background.create(id='9', x=90000, y=0.2)\n", "experiment.background.create(id='10', x=95000, y=0.2)\n", "experiment.background.create(id='11', x=100000, y=0.2)\n", "experiment.background.create(id='12', x=105000, y=0.2)\n", "experiment.background.create(id='13', x=110000, y=0.2)" ] }, { "cell_type": "markdown", "id": "33", "metadata": {}, "source": [ "#### Set Linked Phases" ] }, { "cell_type": "code", "execution_count": 17, "id": "34", "metadata": { "execution": { "iopub.execute_input": "2026-04-14T15:06:15.533000Z", "iopub.status.busy": "2026-04-14T15:06:15.532824Z", "iopub.status.idle": "2026-04-14T15:06:15.536398Z", "shell.execute_reply": "2026-04-14T15:06:15.535500Z" } }, "outputs": [], "source": [ "experiment.linked_phases.create(id='lbco', scale=4.0)\n", "experiment.linked_phases.create(id='si', scale=0.2)" ] }, { "cell_type": "markdown", "id": "35", "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": 18, "id": "36", "metadata": { "execution": { "iopub.execute_input": "2026-04-14T15:06:15.537790Z", "iopub.status.busy": "2026-04-14T15:06:15.537617Z", "iopub.status.idle": "2026-04-14T15:06:16.054512Z", "shell.execute_reply": "2026-04-14T15:06:16.053375Z" } }, "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": "37", "metadata": {}, "source": [ "#### Add Structures" ] }, { "cell_type": "code", "execution_count": 19, "id": "38", "metadata": { "execution": { "iopub.execute_input": "2026-04-14T15:06:16.056477Z", "iopub.status.busy": "2026-04-14T15:06:16.056258Z", "iopub.status.idle": "2026-04-14T15:06:16.060383Z", "shell.execute_reply": "2026-04-14T15:06:16.059428Z" } }, "outputs": [], "source": [ "project.structures.add(structure_1)\n", "project.structures.add(structure_2)" ] }, { "cell_type": "markdown", "id": "39", "metadata": {}, "source": [ "#### Show Structures" ] }, { "cell_type": "code", "execution_count": 20, "id": "40", "metadata": { "execution": { "iopub.execute_input": "2026-04-14T15:06:16.062384Z", "iopub.status.busy": "2026-04-14T15:06:16.062163Z", "iopub.status.idle": "2026-04-14T15:06:16.067415Z", "shell.execute_reply": "2026-04-14T15:06:16.066639Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\u001b[1;34mDefined structures 🧩\u001b[0m\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "\u001b[1m[\u001b[0m\u001b[32m'lbco'\u001b[0m, \u001b[32m'si'\u001b[0m\u001b[1m]\u001b[0m\n" ] } ], "source": [ "project.structures.show_names()" ] }, { "cell_type": "markdown", "id": "41", "metadata": {}, "source": [ "#### Add Experiments" ] }, { "cell_type": "code", "execution_count": 21, "id": "42", "metadata": { "execution": { "iopub.execute_input": "2026-04-14T15:06:16.069377Z", "iopub.status.busy": "2026-04-14T15:06:16.069196Z", "iopub.status.idle": "2026-04-14T15:06:16.072011Z", "shell.execute_reply": "2026-04-14T15:06:16.071217Z" } }, "outputs": [], "source": [ "project.experiments.add(experiment)" ] }, { "cell_type": "markdown", "id": "43", "metadata": {}, "source": [ "#### Set Excluded Regions\n", "\n", "Show measured data as loaded from the file." ] }, { "cell_type": "code", "execution_count": 22, "id": "44", "metadata": { "execution": { "iopub.execute_input": "2026-04-14T15:06:16.073501Z", "iopub.status.busy": "2026-04-14T15:06:16.073326Z", "iopub.status.idle": "2026-04-14T15:06:16.644826Z", "shell.execute_reply": "2026-04-14T15:06:16.644024Z" } }, "outputs": [ { "data": { "text/html": [ "
\n", "
" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "project.plotter.plot_meas(expt_name='mcstas')" ] }, { "cell_type": "markdown", "id": "45", "metadata": {}, "source": [ "Add excluded regions." ] }, { "cell_type": "code", "execution_count": 23, "id": "46", "metadata": { "execution": { "iopub.execute_input": "2026-04-14T15:06:16.646843Z", "iopub.status.busy": "2026-04-14T15:06:16.646643Z", "iopub.status.idle": "2026-04-14T15:06:16.651102Z", "shell.execute_reply": "2026-04-14T15:06:16.650394Z" } }, "outputs": [], "source": [ "experiment.excluded_regions.create(id='1', start=0, end=40000)\n", "experiment.excluded_regions.create(id='2', start=108000, end=200000)" ] }, { "cell_type": "markdown", "id": "47", "metadata": {}, "source": [ "Show excluded regions." ] }, { "cell_type": "code", "execution_count": 24, "id": "48", "metadata": { "execution": { "iopub.execute_input": "2026-04-14T15:06:16.652971Z", "iopub.status.busy": "2026-04-14T15:06:16.652777Z", "iopub.status.idle": "2026-04-14T15:06:16.906596Z", "shell.execute_reply": "2026-04-14T15:06:16.905689Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\u001b[1;34mExcluded regions\u001b[0m\n" ] }, { "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" }, { "data": { "text/html": [ "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
 startend
10.0000040000
2108000.00000200000
\n" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "experiment.excluded_regions.show()" ] }, { "cell_type": "markdown", "id": "49", "metadata": {}, "source": [ "Show measured data after adding excluded regions." ] }, { "cell_type": "code", "execution_count": 25, "id": "50", "metadata": { "execution": { "iopub.execute_input": "2026-04-14T15:06:16.908998Z", "iopub.status.busy": "2026-04-14T15:06:16.908710Z", "iopub.status.idle": "2026-04-14T15:06:17.306854Z", "shell.execute_reply": "2026-04-14T15:06:17.306042Z" } }, "outputs": [ { "data": { "text/html": [ "
\n", "
" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "project.plotter.plot_meas(expt_name='mcstas')" ] }, { "cell_type": "markdown", "id": "51", "metadata": {}, "source": [ "Show experiment as CIF." ] }, { "cell_type": "code", "execution_count": 26, "id": "52", "metadata": { "execution": { "iopub.execute_input": "2026-04-14T15:06:17.308444Z", "iopub.status.busy": "2026-04-14T15:06:17.308264Z", "iopub.status.idle": "2026-04-14T15:06:17.526793Z", "shell.execute_reply": "2026-04-14T15:06:17.525925Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\u001b[1;34mExperiment 🔬 \u001b[0m\u001b[32m'mcstas'\u001b[0m\u001b[1;34m as cif\u001b[0m\n" ] }, { "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" }, { "data": { "text/html": [ "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
 CIF
1data_mcstas
2
3_expt_type.sample_form powder
4_expt_type.beam_mode time-of-flight
5_expt_type.radiation_probe neutron
6_expt_type.scattering_type bragg
7
8_diffrn.ambient_temperature ?
9_diffrn.ambient_pressure ?
10_diffrn.ambient_magnetic_field ?
11_diffrn.ambient_electric_field ?
12
13_peak.rise_alpha_0 0.00000000
14_peak.rise_alpha_1 0.00970000
15_peak.decay_beta_0 0.00550000
16_peak.decay_beta_1 0.00410000
17_peak.gauss_sigma_0 45137.00000000
18_peak.gauss_sigma_1 -52394.00000000
19_peak.gauss_sigma_2 22998.00000000
20_peak.profile_type jorgensen
21
22_instr.2theta_bank 94.90931762
23_instr.d_to_tof_offset 0.00000000
24_instr.d_to_tof_linear 58724.76869981
25_instr.d_to_tof_quad -0.00001000
26_instr.d_to_tof_recip 0.00000000
27
28loop_
29_pd_phase_block.id
30_pd_phase_block.scale
31lbco 4.00000000
32si 0.20000000
33
34loop_
35_excluded_region.id
36_excluded_region.start
37_excluded_region.end
381 0.00000000 40000.00000000
392 108000.00000000 200000.00000000
40
41loop_
42_pd_meas.time_of_flight
43_pd_data.point_id
44_pd_proc.d_spacing
45_pd_meas.intensity_total
46_pd_meas.intensity_total_su
47_pd_calc.intensity_total
48_pd_calc.intensity_bkg
49_pd_data.refinement_status
5041168.12860000 1 0.70103524 0.21537107 0.02485114 0.25454340 0.20000000 incl
5141273.85360000 2 0.70283531 0.26087313 0.03329888 0.33827395 0.20000000 incl
5241379.57850000 3 0.70463575 0.30433686 0.03547088 0.46671492 0.20000000 incl
5341485.30350000 4 0.70643619 0.47366708 0.04206284 0.58607007 0.20000000 incl
5441591.02850000 5 0.70823626 0.60026520 0.04196648 0.62332826 0.20000000 incl
5541696.75340000 6 0.71003669 0.60174483 0.03965186 0.55740164 0.20000000 incl
5641802.47840000 7 0.71183713 0.50118258 0.03810349 0.43268833 0.20000000 incl
5741908.20340000 8 0.71363756 0.37702264 0.03458906 0.31517711 0.20000000 incl
5842013.92840000 9 0.71543800 0.27533183 0.03190951 0.24565766 0.20000000 incl
5942119.65330000 10 0.71723844 0.26182311 0.02830043 0.22739949 0.20000000 incl
60...
61145835.84890000 991 2.48337892 0.22406860 0.01131008 0.20000000 0.20000000 excl
62145941.57390000 992 2.48517936 0.21377274 0.01070627 0.20000000 0.20000000 excl
63146047.29880000 993 2.48697943 0.20927726 0.01085520 0.20000000 0.20000000 excl
64146153.02380000 994 2.48877986 0.21839779 0.01091455 0.20000000 0.20000000 excl
65146258.74880000 995 2.49058030 0.21613293 0.01104795 0.20000000 0.20000000 excl
66146364.47370000 996 2.49238037 0.20571926 0.01109275 0.20000000 0.20000000 excl
67146470.19870000 997 2.49418081 0.22615941 0.01142946 0.20000000 0.20000000 excl
68146575.92370000 998 2.49598124 0.22113311 0.01151463 0.20000000 0.20000000 excl
69146681.64860000 999 2.49778168 0.20862390 0.01097638 0.20000000 0.20000000 excl
70146787.37360000 1000 2.49958175 0.20883912 0.01092893 0.20000000 0.20000000 excl
71
72loop_
73_pd_background.id
74_pd_background.line_segment_X
75_pd_background.line_segment_intensity
761 45000.00000000 0.20000000
772 50000.00000000 0.20000000
783 55000.00000000 0.20000000
794 65000.00000000 0.20000000
805 70000.00000000 0.20000000
816 75000.00000000 0.20000000
827 80000.00000000 0.20000000
838 85000.00000000 0.20000000
849 90000.00000000 0.20000000
8510 95000.00000000 0.20000000
8611 100000.00000000 0.20000000
8712 105000.00000000 0.20000000
8813 110000.00000000 0.20000000
\n" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "project.experiments['mcstas'].show_as_cif()" ] }, { "cell_type": "markdown", "id": "53", "metadata": {}, "source": [ "## Perform Analysis\n", "\n", "This section outlines the analysis process, including how to configure\n", "calculation and fitting engines.\n", "\n", "#### Set Fitting Parameters\n", "\n", "Set structure parameters to be optimized." ] }, { "cell_type": "code", "execution_count": 27, "id": "54", "metadata": { "execution": { "iopub.execute_input": "2026-04-14T15:06:17.528733Z", "iopub.status.busy": "2026-04-14T15:06:17.528529Z", "iopub.status.idle": "2026-04-14T15:06:17.532104Z", "shell.execute_reply": "2026-04-14T15:06:17.531324Z" } }, "outputs": [], "source": [ "structure_1.cell.length_a.free = True\n", "structure_1.atom_sites['Co'].adp_iso.free = True\n", "structure_1.atom_sites['O'].adp_iso.free = True\n", "\n", "structure_2.cell.length_a.free = True" ] }, { "cell_type": "markdown", "id": "55", "metadata": {}, "source": [ "Set experiment parameters to be optimized." ] }, { "cell_type": "code", "execution_count": 28, "id": "56", "metadata": { "execution": { "iopub.execute_input": "2026-04-14T15:06:17.533715Z", "iopub.status.busy": "2026-04-14T15:06:17.533533Z", "iopub.status.idle": "2026-04-14T15:06:17.538439Z", "shell.execute_reply": "2026-04-14T15:06:17.537535Z" } }, "outputs": [], "source": [ "experiment.linked_phases['lbco'].scale.free = True\n", "experiment.linked_phases['si'].scale.free = True\n", "\n", "experiment.peak.broad_gauss_sigma_0.free = True\n", "experiment.peak.broad_gauss_sigma_1.free = True\n", "experiment.peak.broad_gauss_sigma_2.free = True\n", "\n", "experiment.peak.exp_rise_alpha_1.free = True\n", "experiment.peak.exp_decay_beta_0.free = True\n", "experiment.peak.exp_decay_beta_1.free = True\n", "\n", "for point in experiment.background:\n", " point.y.free = True" ] }, { "cell_type": "markdown", "id": "57", "metadata": {}, "source": [ "#### Perform Fit" ] }, { "cell_type": "code", "execution_count": 29, "id": "58", "metadata": { "execution": { "iopub.execute_input": "2026-04-14T15:06:17.539904Z", "iopub.status.busy": "2026-04-14T15:06:17.539735Z", "iopub.status.idle": "2026-04-14T15:06:23.538957Z", "shell.execute_reply": "2026-04-14T15:06:23.538064Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\u001b[1;34mStandard fitting\u001b[0m\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "📋 Using experiment 🔬 \u001b[32m'mcstas'\u001b[0m for \u001b[32m'single'\u001b[0m fitting\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "🚀 Starting fit process with \u001b[32m'lmfit \u001b[0m\u001b[32m(\u001b[0m\u001b[32mleastsq\u001b[0m\u001b[32m)\u001b[0m\u001b[32m'\u001b[0m\u001b[33m...\u001b[0m\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "📈 Goodness-of-fit \u001b[1m(\u001b[0mreduced χ²\u001b[1m)\u001b[0m change:\n" ] }, { "data": { "text/html": [ "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
 iterationχ²improvement [%]
11301.41
2293.3698.9% ↓
3553.243.7% ↓
41343.24
\n" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "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" }, { "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" }, { "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" }, { "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" }, { "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" }, { "name": "stdout", "output_type": "stream", "text": [ "🏆 Best goodness-of-fit \u001b[1m(\u001b[0mreduced χ²\u001b[1m)\u001b[0m is \u001b[1;36m3.24\u001b[0m at iteration \u001b[1;36m133\u001b[0m\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "✅ Fitting complete.\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "\u001b[1;34mFit results\u001b[0m\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "✅ Success: \u001b[3;92mTrue\u001b[0m\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "⏱️ Fitting time: \u001b[1;36m4.51\u001b[0m seconds\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "📏 Goodness-of-fit \u001b[1m(\u001b[0mreduced χ²\u001b[1m)\u001b[0m: \u001b[1;36m3.24\u001b[0m\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "📏 R-factor \u001b[1m(\u001b[0mRf\u001b[1m)\u001b[0m: \u001b[1;36m4.76\u001b[0m%\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "📏 R-factor squared \u001b[1m(\u001b[0mRf²\u001b[1m)\u001b[0m: \u001b[1;36m5.16\u001b[0m%\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "📏 Weighted R-factor \u001b[1m(\u001b[0mwR\u001b[1m)\u001b[0m: \u001b[1;36m5.22\u001b[0m%\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "📈 Fitted parameters:\n" ] }, { "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" }, { "data": { "text/html": [ "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
 datablockcategoryentryparameterstartfitteduncertaintyunitschange
1lbcocelllength_a3.89093.89040.0001Å0.01 % ↓
2lbcoatom_siteCoadp_iso0.25670.32330.0853Ų25.94 % ↑
3lbcoatom_siteOadp_iso1.40412.16860.0282Ų54.45 % ↑
4sicelllength_a5.43155.43270.0006Å0.02 % ↑
5mcstaslinked_phaseslbcoscale4.00004.55770.031813.94 % ↑
6mcstaslinked_phasessiscale0.20000.03140.000884.28 % ↓
7mcstaspeakrise_alpha_10.00970.00970.0002μs/Å0.40 % ↓
8mcstaspeakdecay_beta_00.00550.00550.0001μs0.64 % ↑
9mcstaspeakdecay_beta_10.00410.00410.0003μs/Å0.32 % ↓
10mcstaspeakgauss_sigma_045137.000045210.89692868.4651μs²0.16 % ↑
11mcstaspeakgauss_sigma_1-52394.0000-52476.89913797.9256μs/Å0.16 % ↑
12mcstaspeakgauss_sigma_222998.000023014.33921193.4306μs²/Ų0.07 % ↑
13mcstasbackground1y0.20000.25020.008225.09 % ↑
14mcstasbackground2y0.20000.24980.008024.91 % ↑
15mcstasbackground3y0.20000.26740.004733.68 % ↑
16mcstasbackground4y0.20000.25510.003627.53 % ↑
17mcstasbackground5y0.20000.24630.003523.17 % ↑
18mcstasbackground6y0.20000.24170.002720.86 % ↑
19mcstasbackground7y0.20000.24210.003321.07 % ↑
20mcstasbackground8y0.20000.23740.002118.71 % ↑
21mcstasbackground9y0.20000.23810.002019.07 % ↑
22mcstasbackground10y0.20000.24230.002521.14 % ↑
23mcstasbackground11y0.20000.22580.002212.88 % ↑
24mcstasbackground12y0.20000.22280.002611.40 % ↑
25mcstasbackground13y0.20000.22250.007811.23 % ↑
\n" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "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" }, { "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" }, { "data": { "text/html": [ "
\n", "
" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "project.analysis.fit()\n", "project.analysis.display.fit_results()\n", "project.plotter.plot_param_correlations()" ] }, { "cell_type": "markdown", "id": "59", "metadata": {}, "source": [ "#### Plot Measured vs Calculated" ] }, { "cell_type": "code", "execution_count": 30, "id": "60", "metadata": { "execution": { "iopub.execute_input": "2026-04-14T15:06:23.540893Z", "iopub.status.busy": "2026-04-14T15:06:23.540698Z", "iopub.status.idle": "2026-04-14T15:06:23.570849Z", "shell.execute_reply": "2026-04-14T15:06:23.569915Z" } }, "outputs": [ { "data": { "text/html": [ "
\n", "
" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "project.plotter.plot_meas_vs_calc(expt_name='mcstas')" ] } ], "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 }