{ "cells": [ { "cell_type": "code", "execution_count": 1, "id": "4142e7f9", "metadata": { "execution": { "iopub.execute_input": "2026-01-06T13:55:25.927022Z", "iopub.status.busy": "2026-01-06T13:55:25.926768Z", "iopub.status.idle": "2026-01-06T13:55:25.936391Z", "shell.execute_reply": "2026-01-06T13:55:25.935796Z" }, "tags": [ "hide-in-docs" ] }, "outputs": [], "source": [ "# Check if the easydiffraction library is installed.\n", "# If not, install it with the 'visualization' extras.\n", "# Needed when running remotely (e.g. Colab) where the lib is absent.\n", "import builtins\n", "import importlib.util\n", "\n", "if (hasattr(builtins, '__IPYTHON__') and\n", " importlib.util.find_spec('easydiffraction') is None):\n", " !pip install 'easydiffraction[visualization]==0.10.1'" ] }, { "cell_type": "markdown", "id": "0", "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": "1", "metadata": {}, "source": [ "## Import Library" ] }, { "cell_type": "code", "execution_count": 2, "id": "2", "metadata": { "execution": { "iopub.execute_input": "2026-01-06T13:55:25.938969Z", "iopub.status.busy": "2026-01-06T13:55:25.938822Z", "iopub.status.idle": "2026-01-06T13:55:29.194597Z", "shell.execute_reply": "2026-01-06T13:55:29.191726Z" } }, "outputs": [], "source": [ "from easydiffraction import ExperimentFactory\n", "from easydiffraction import Project\n", "from easydiffraction import SampleModelFactory\n", "from easydiffraction import download_data" ] }, { "cell_type": "markdown", "id": "3", "metadata": {}, "source": [ "## Define Sample Models\n", "\n", "This section shows how to add sample models and modify their\n", "parameters.\n", "\n", "### Create Sample Model 1: LBCO" ] }, { "cell_type": "code", "execution_count": 3, "id": "4", "metadata": { "execution": { "iopub.execute_input": "2026-01-06T13:55:29.203076Z", "iopub.status.busy": "2026-01-06T13:55:29.200411Z", "iopub.status.idle": "2026-01-06T13:55:29.212264Z", "shell.execute_reply": "2026-01-06T13:55:29.209641Z" } }, "outputs": [], "source": [ "model_1 = SampleModelFactory.create(name='lbco')" ] }, { "cell_type": "markdown", "id": "5", "metadata": {}, "source": [ "#### Set Space Group" ] }, { "cell_type": "code", "execution_count": 4, "id": "6", "metadata": { "execution": { "iopub.execute_input": "2026-01-06T13:55:29.216584Z", "iopub.status.busy": "2026-01-06T13:55:29.215703Z", "iopub.status.idle": "2026-01-06T13:55:29.222198Z", "shell.execute_reply": "2026-01-06T13:55:29.220697Z" } }, "outputs": [], "source": [ "model_1.space_group.name_h_m = 'P m -3 m'\n", "model_1.space_group.it_coordinate_system_code = '1'" ] }, { "cell_type": "markdown", "id": "7", "metadata": {}, "source": [ "#### Set Unit Cell" ] }, { "cell_type": "code", "execution_count": 5, "id": "8", "metadata": { "execution": { "iopub.execute_input": "2026-01-06T13:55:29.225434Z", "iopub.status.busy": "2026-01-06T13:55:29.224927Z", "iopub.status.idle": "2026-01-06T13:55:29.227652Z", "shell.execute_reply": "2026-01-06T13:55:29.227149Z" } }, "outputs": [], "source": [ "model_1.cell.length_a = 3.8909" ] }, { "cell_type": "markdown", "id": "9", "metadata": {}, "source": [ "#### Set Atom Sites" ] }, { "cell_type": "code", "execution_count": 6, "id": "10", "metadata": { "execution": { "iopub.execute_input": "2026-01-06T13:55:29.229985Z", "iopub.status.busy": "2026-01-06T13:55:29.229242Z", "iopub.status.idle": "2026-01-06T13:55:29.240706Z", "shell.execute_reply": "2026-01-06T13:55:29.238246Z" } }, "outputs": [], "source": [ "model_1.atom_sites.add(\n", " label='La',\n", " type_symbol='La',\n", " fract_x=0,\n", " fract_y=0,\n", " fract_z=0,\n", " wyckoff_letter='a',\n", " b_iso=0.2,\n", " occupancy=0.5,\n", ")\n", "model_1.atom_sites.add(\n", " label='Ba',\n", " type_symbol='Ba',\n", " fract_x=0,\n", " fract_y=0,\n", " fract_z=0,\n", " wyckoff_letter='a',\n", " b_iso=0.2,\n", " occupancy=0.5,\n", ")\n", "model_1.atom_sites.add(\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", " b_iso=0.2567,\n", ")\n", "model_1.atom_sites.add(\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", " b_iso=1.4041,\n", ")" ] }, { "cell_type": "markdown", "id": "11", "metadata": {}, "source": [ "### Create Sample Model 2: Si" ] }, { "cell_type": "code", "execution_count": 7, "id": "12", "metadata": { "execution": { "iopub.execute_input": "2026-01-06T13:55:29.243322Z", "iopub.status.busy": "2026-01-06T13:55:29.243155Z", "iopub.status.idle": "2026-01-06T13:55:29.250013Z", "shell.execute_reply": "2026-01-06T13:55:29.249119Z" } }, "outputs": [], "source": [ "model_2 = SampleModelFactory.create(name='si')" ] }, { "cell_type": "markdown", "id": "13", "metadata": {}, "source": [ "#### Set Space Group" ] }, { "cell_type": "code", "execution_count": 8, "id": "14", "metadata": { "execution": { "iopub.execute_input": "2026-01-06T13:55:29.253704Z", "iopub.status.busy": "2026-01-06T13:55:29.253356Z", "iopub.status.idle": "2026-01-06T13:55:29.257336Z", "shell.execute_reply": "2026-01-06T13:55:29.255947Z" } }, "outputs": [], "source": [ "model_2.space_group.name_h_m = 'F d -3 m'\n", "model_2.space_group.it_coordinate_system_code = '2'" ] }, { "cell_type": "markdown", "id": "15", "metadata": {}, "source": [ "#### Set Unit Cell" ] }, { "cell_type": "code", "execution_count": 9, "id": "16", "metadata": { "execution": { "iopub.execute_input": "2026-01-06T13:55:29.259442Z", "iopub.status.busy": "2026-01-06T13:55:29.259317Z", "iopub.status.idle": "2026-01-06T13:55:29.262261Z", "shell.execute_reply": "2026-01-06T13:55:29.261315Z" } }, "outputs": [], "source": [ "model_2.cell.length_a = 5.43146" ] }, { "cell_type": "markdown", "id": "17", "metadata": {}, "source": [ "#### Set Atom Sites" ] }, { "cell_type": "code", "execution_count": 10, "id": "18", "metadata": { "execution": { "iopub.execute_input": "2026-01-06T13:55:29.264546Z", "iopub.status.busy": "2026-01-06T13:55:29.264401Z", "iopub.status.idle": "2026-01-06T13:55:29.267593Z", "shell.execute_reply": "2026-01-06T13:55:29.266779Z" } }, "outputs": [], "source": [ "model_2.atom_sites.add(\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", " b_iso=0.0,\n", ")" ] }, { "cell_type": "markdown", "id": "19", "metadata": {}, "source": [ "## Define Experiment\n", "\n", "This section shows how to add experiments, configure their parameters,\n", "and link the sample models defined in the previous step.\n", "\n", "#### Download Data" ] }, { "cell_type": "code", "execution_count": 11, "id": "20", "metadata": { "execution": { "iopub.execute_input": "2026-01-06T13:55:29.270191Z", "iopub.status.busy": "2026-01-06T13:55:29.270048Z", "iopub.status.idle": "2026-01-06T13:55:29.364643Z", "shell.execute_reply": "2026-01-06T13:55:29.363726Z" } }, "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": "21", "metadata": {}, "source": [ "#### Create Experiment" ] }, { "cell_type": "code", "execution_count": 12, "id": "22", "metadata": { "execution": { "iopub.execute_input": "2026-01-06T13:55:29.370003Z", "iopub.status.busy": "2026-01-06T13:55:29.369661Z", "iopub.status.idle": "2026-01-06T13:55:29.633982Z", "shell.execute_reply": "2026-01-06T13:55:29.632642Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\u001b[1;34mData loaded successfully\u001b[0m\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "Experiment ๐Ÿ”ฌ \u001b[32m'mcstas'\u001b[0m. Number of data points: \u001b[1;36m1000\u001b[0m\n" ] } ], "source": [ "experiment = ExperimentFactory.create(\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": "23", "metadata": {}, "source": [ "#### Set Instrument" ] }, { "cell_type": "code", "execution_count": 13, "id": "24", "metadata": { "execution": { "iopub.execute_input": "2026-01-06T13:55:29.638023Z", "iopub.status.busy": "2026-01-06T13:55:29.637415Z", "iopub.status.idle": "2026-01-06T13:55:29.641332Z", "shell.execute_reply": "2026-01-06T13:55:29.640559Z" } }, "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": "25", "metadata": {}, "source": [ "#### Set Peak Profile" ] }, { "cell_type": "code", "execution_count": 14, "id": "26", "metadata": { "execution": { "iopub.execute_input": "2026-01-06T13:55:29.644409Z", "iopub.status.busy": "2026-01-06T13:55:29.644233Z", "iopub.status.idle": "2026-01-06T13:55:29.648587Z", "shell.execute_reply": "2026-01-06T13:55:29.647377Z" } }, "outputs": [], "source": [ "# experiment.peak_profile_type = 'pseudo-voigt * ikeda-carpenter'\n", "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.broad_mix_beta_0 = 0.0055\n", "experiment.peak.broad_mix_beta_1 = 0.0041\n", "experiment.peak.asym_alpha_0 = 0\n", "experiment.peak.asym_alpha_1 = 0.0097" ] }, { "cell_type": "markdown", "id": "27", "metadata": {}, "source": [ "#### Set Background" ] }, { "cell_type": "markdown", "id": "28", "metadata": {}, "source": [ "Select the background type." ] }, { "cell_type": "code", "execution_count": 15, "id": "29", "metadata": { "execution": { "iopub.execute_input": "2026-01-06T13:55:29.650682Z", "iopub.status.busy": "2026-01-06T13:55:29.650546Z", "iopub.status.idle": "2026-01-06T13:55:29.656287Z", "shell.execute_reply": "2026-01-06T13:55:29.654354Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\u001b[1;34mBackground type for experiment \u001b[0m\u001b[32m'mcstas'\u001b[0m\u001b[1;34m changed to\u001b[0m\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "line-segment\n" ] } ], "source": [ "experiment.background_type = 'line-segment'" ] }, { "cell_type": "markdown", "id": "30", "metadata": {}, "source": [ "Add background points." ] }, { "cell_type": "code", "execution_count": 16, "id": "31", "metadata": { "execution": { "iopub.execute_input": "2026-01-06T13:55:29.659519Z", "iopub.status.busy": "2026-01-06T13:55:29.659219Z", "iopub.status.idle": "2026-01-06T13:55:29.666325Z", "shell.execute_reply": "2026-01-06T13:55:29.665551Z" } }, "outputs": [], "source": [ "experiment.background.add(id='1', x=45000, y=0.2)\n", "experiment.background.add(id='2', x=50000, y=0.2)\n", "experiment.background.add(id='3', x=55000, y=0.2)\n", "experiment.background.add(id='4', x=65000, y=0.2)\n", "experiment.background.add(id='5', x=70000, y=0.2)\n", "experiment.background.add(id='6', x=75000, y=0.2)\n", "experiment.background.add(id='7', x=80000, y=0.2)\n", "experiment.background.add(id='8', x=85000, y=0.2)\n", "experiment.background.add(id='9', x=90000, y=0.2)\n", "experiment.background.add(id='10', x=95000, y=0.2)\n", "experiment.background.add(id='11', x=100000, y=0.2)\n", "experiment.background.add(id='12', x=105000, y=0.2)\n", "experiment.background.add(id='13', x=110000, y=0.2)" ] }, { "cell_type": "markdown", "id": "32", "metadata": {}, "source": [ "#### Set Linked Phases" ] }, { "cell_type": "code", "execution_count": 17, "id": "33", "metadata": { "execution": { "iopub.execute_input": "2026-01-06T13:55:29.669113Z", "iopub.status.busy": "2026-01-06T13:55:29.668927Z", "iopub.status.idle": "2026-01-06T13:55:29.672998Z", "shell.execute_reply": "2026-01-06T13:55:29.672266Z" } }, "outputs": [], "source": [ "experiment.linked_phases.add(id='lbco', scale=4.0)\n", "experiment.linked_phases.add(id='si', scale=0.2)" ] }, { "cell_type": "markdown", "id": "34", "metadata": {}, "source": [ "## Define Project\n", "\n", "The project object is used to manage sample models, experiments, and\n", "analysis.\n", "\n", "#### Create Project" ] }, { "cell_type": "code", "execution_count": 18, "id": "35", "metadata": { "execution": { "iopub.execute_input": "2026-01-06T13:55:29.675414Z", "iopub.status.busy": "2026-01-06T13:55:29.675293Z", "iopub.status.idle": "2026-01-06T13:55:29.890286Z", "shell.execute_reply": "2026-01-06T13:55:29.885059Z" } }, "outputs": [], "source": [ "project = Project()" ] }, { "cell_type": "markdown", "id": "36", "metadata": {}, "source": [ "#### Add Sample Models" ] }, { "cell_type": "code", "execution_count": 19, "id": "37", "metadata": { "execution": { "iopub.execute_input": "2026-01-06T13:55:29.893928Z", "iopub.status.busy": "2026-01-06T13:55:29.893246Z", "iopub.status.idle": "2026-01-06T13:55:29.897737Z", "shell.execute_reply": "2026-01-06T13:55:29.896703Z" } }, "outputs": [], "source": [ "project.sample_models.add(sample_model=model_1)\n", "project.sample_models.add(sample_model=model_2)" ] }, { "cell_type": "markdown", "id": "38", "metadata": {}, "source": [ "#### Show Sample Models" ] }, { "cell_type": "code", "execution_count": 20, "id": "39", "metadata": { "execution": { "iopub.execute_input": "2026-01-06T13:55:29.900794Z", "iopub.status.busy": "2026-01-06T13:55:29.900131Z", "iopub.status.idle": "2026-01-06T13:55:29.912227Z", "shell.execute_reply": "2026-01-06T13:55:29.910015Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\u001b[1;34mDefined sample models ๐Ÿงฉ\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.sample_models.show_names()" ] }, { "cell_type": "markdown", "id": "40", "metadata": {}, "source": [ "#### Add Experiments" ] }, { "cell_type": "code", "execution_count": 21, "id": "41", "metadata": { "execution": { "iopub.execute_input": "2026-01-06T13:55:29.915668Z", "iopub.status.busy": "2026-01-06T13:55:29.914943Z", "iopub.status.idle": "2026-01-06T13:55:29.925809Z", "shell.execute_reply": "2026-01-06T13:55:29.921683Z" } }, "outputs": [], "source": [ "project.experiments.add(experiment=experiment)" ] }, { "cell_type": "markdown", "id": "42", "metadata": {}, "source": [ "#### Set Excluded Regions\n", "\n", "Show measured data as loaded from the file." ] }, { "cell_type": "code", "execution_count": 22, "id": "43", "metadata": { "execution": { "iopub.execute_input": "2026-01-06T13:55:29.928493Z", "iopub.status.busy": "2026-01-06T13:55:29.928188Z", "iopub.status.idle": "2026-01-06T13:55:30.392386Z", "shell.execute_reply": "2026-01-06T13:55:30.391919Z" } }, "outputs": [ { "data": { "text/html": [ "
\n", "
" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "project.plot_meas(expt_name='mcstas')" ] }, { "cell_type": "markdown", "id": "44", "metadata": {}, "source": [ "Add excluded regions." ] }, { "cell_type": "code", "execution_count": 23, "id": "45", "metadata": { "execution": { "iopub.execute_input": "2026-01-06T13:55:30.394617Z", "iopub.status.busy": "2026-01-06T13:55:30.394471Z", "iopub.status.idle": "2026-01-06T13:55:30.397284Z", "shell.execute_reply": "2026-01-06T13:55:30.396715Z" } }, "outputs": [], "source": [ "experiment.excluded_regions.add(id='1', start=0, end=40000)\n", "experiment.excluded_regions.add(id='2', start=108000, end=200000)" ] }, { "cell_type": "markdown", "id": "46", "metadata": {}, "source": [ "Show excluded regions." ] }, { "cell_type": "code", "execution_count": 24, "id": "47", "metadata": { "execution": { "iopub.execute_input": "2026-01-06T13:55:30.399373Z", "iopub.status.busy": "2026-01-06T13:55:30.399216Z", "iopub.status.idle": "2026-01-06T13:55:30.730841Z", "shell.execute_reply": "2026-01-06T13:55:30.730442Z" } }, "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
1040000
2108000200000
\n" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "experiment.excluded_regions.show()" ] }, { "cell_type": "markdown", "id": "48", "metadata": {}, "source": [ "Show measured data after adding excluded regions." ] }, { "cell_type": "code", "execution_count": 25, "id": "49", "metadata": { "execution": { "iopub.execute_input": "2026-01-06T13:55:30.733779Z", "iopub.status.busy": "2026-01-06T13:55:30.733264Z", "iopub.status.idle": "2026-01-06T13:55:31.176504Z", "shell.execute_reply": "2026-01-06T13:55:31.175793Z" } }, "outputs": [ { "data": { "text/html": [ "
\n", "
" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "project.plot_meas(expt_name='mcstas')" ] }, { "cell_type": "markdown", "id": "50", "metadata": {}, "source": [ "Show experiment as CIF." ] }, { "cell_type": "code", "execution_count": 26, "id": "51", "metadata": { "execution": { "iopub.execute_input": "2026-01-06T13:55:31.178754Z", "iopub.status.busy": "2026-01-06T13:55:31.178629Z", "iopub.status.idle": "2026-01-06T13:55:31.977942Z", "shell.execute_reply": "2026-01-06T13:55:31.976502Z" } }, "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", "
 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_peak.gauss_sigma_0 45137.0000
9_peak.gauss_sigma_1 -52394.0000
10_peak.gauss_sigma_2 22998.0000
11_peak.lorentz_gamma_0 0.0000
12_peak.lorentz_gamma_1 0.0000
13_peak.lorentz_gamma_2 0.0000
14_peak.mix_beta_0 0.0055
15_peak.mix_beta_1 0.0041
16_peak.asym_alpha_0 0.0000
17_peak.asym_alpha_1 0.0097
18
19_instr.2theta_bank 94.9093
20_instr.d_to_tof_offset 0.0000
21_instr.d_to_tof_linear 58724.7687
22_instr.d_to_tof_quad -0.0000
23_instr.d_to_tof_recip 0.0000
24
25loop_
26_pd_phase_block.id
27_pd_phase_block.scale
28 lbco 4.0000
29 si 0.2000
30
31loop_
32_excluded_region.id
33_excluded_region.start
34_excluded_region.end
35 1 0.0000 40000.0000
36 2 108000.0000 200000.0000
37
38loop_
39_pd_meas.time_of_flight
40_pd_data.point_id
41_pd_proc.d_spacing
42_pd_meas.intensity_total
43_pd_meas.intensity_total_su
44_pd_calc.intensity_total
45_pd_calc.intensity_bkg
46_pd_data.refinement_status
4741168.1286 1 0.7010 0.2154 0.0249 0.2544 0.2000 incl
4841273.8536 2 0.7028 0.2609 0.0333 0.3380 0.2000 incl
4941379.5785 3 0.7046 0.3043 0.0355 0.4664 0.2000 incl
5041485.3035 4 0.7064 0.4737 0.0421 0.5860 0.2000 incl
5141591.0285 5 0.7082 0.6003 0.0420 0.6236 0.2000 incl
5241696.7534 6 0.7100 0.6017 0.0397 0.5577 0.2000 incl
5341802.4784 7 0.7118 0.5012 0.0381 0.4329 0.2000 incl
5441908.2034 8 0.7136 0.3770 0.0346 0.3153 0.2000 incl
5542013.9284 9 0.7154 0.2753 0.0319 0.2457 0.2000 incl
5642119.6533 10 0.7172 0.2618 0.0283 0.2273 0.2000 incl
57...
58145835.8489 991 2.4834 0.2241 0.0113 0.2000 0.2000 excl
59145941.5739 992 2.4852 0.2138 0.0107 0.2000 0.2000 excl
60146047.2988 993 2.4870 0.2093 0.0109 0.2000 0.2000 excl
61146153.0238 994 2.4888 0.2184 0.0109 0.2000 0.2000 excl
62146258.7488 995 2.4906 0.2161 0.0110 0.2000 0.2000 excl
63146364.4737 996 2.4924 0.2057 0.0111 0.2000 0.2000 excl
64146470.1987 997 2.4942 0.2262 0.0114 0.2000 0.2000 excl
65146575.9237 998 2.4960 0.2211 0.0115 0.2000 0.2000 excl
66146681.6486 999 2.4978 0.2086 0.0110 0.2000 0.2000 excl
67146787.3736 1000 2.4996 0.2088 0.0109 0.2000 0.2000 excl
68
69loop_
70_pd_background.id
71_pd_background.line_segment_X
72_pd_background.line_segment_intensity
73 1 45000.0000 0.2000
74 2 50000.0000 0.2000
75 3 55000.0000 0.2000
76 4 65000.0000 0.2000
77 5 70000.0000 0.2000
78 6 75000.0000 0.2000
79 7 80000.0000 0.2000
80 8 85000.0000 0.2000
81 9 90000.0000 0.2000
82 10 95000.0000 0.2000
83 11 100000.0000 0.2000
84 12 105000.0000 0.2000
85 13 110000.0000 0.2000
\n" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "project.experiments['mcstas'].show_as_cif()" ] }, { "cell_type": "markdown", "id": "52", "metadata": {}, "source": [ "## Perform Analysis\n", "\n", "This section outlines the analysis process, including how to configure\n", "calculation and fitting engines.\n", "\n", "#### Set Calculator" ] }, { "cell_type": "code", "execution_count": 27, "id": "53", "metadata": { "execution": { "iopub.execute_input": "2026-01-06T13:55:31.982974Z", "iopub.status.busy": "2026-01-06T13:55:31.982623Z", "iopub.status.idle": "2026-01-06T13:55:31.993799Z", "shell.execute_reply": "2026-01-06T13:55:31.993215Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\u001b[1;34mCurrent calculator changed to\u001b[0m\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "cryspy\n" ] } ], "source": [ "project.analysis.current_calculator = 'cryspy'" ] }, { "cell_type": "markdown", "id": "54", "metadata": {}, "source": [ "#### Set Minimizer" ] }, { "cell_type": "code", "execution_count": 28, "id": "55", "metadata": { "execution": { "iopub.execute_input": "2026-01-06T13:55:31.995833Z", "iopub.status.busy": "2026-01-06T13:55:31.995700Z", "iopub.status.idle": "2026-01-06T13:55:32.004226Z", "shell.execute_reply": "2026-01-06T13:55:32.003624Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\u001b[1;34mCurrent minimizer changed to\u001b[0m\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "lmfit \u001b[1m(\u001b[0mleastsq\u001b[1m)\u001b[0m\n" ] } ], "source": [ "project.analysis.current_minimizer = 'lmfit (leastsq)'" ] }, { "cell_type": "markdown", "id": "56", "metadata": {}, "source": [ "#### Set Fitting Parameters\n", "\n", "Set sample model parameters to be optimized." ] }, { "cell_type": "code", "execution_count": 29, "id": "57", "metadata": { "execution": { "iopub.execute_input": "2026-01-06T13:55:32.006393Z", "iopub.status.busy": "2026-01-06T13:55:32.006205Z", "iopub.status.idle": "2026-01-06T13:55:32.009250Z", "shell.execute_reply": "2026-01-06T13:55:32.008715Z" } }, "outputs": [], "source": [ "model_1.cell.length_a.free = True\n", "model_1.atom_sites['Co'].b_iso.free = True\n", "model_1.atom_sites['O'].b_iso.free = True\n", "\n", "model_2.cell.length_a.free = True" ] }, { "cell_type": "markdown", "id": "58", "metadata": {}, "source": [ "Set experiment parameters to be optimized." ] }, { "cell_type": "code", "execution_count": 30, "id": "59", "metadata": { "execution": { "iopub.execute_input": "2026-01-06T13:55:32.011750Z", "iopub.status.busy": "2026-01-06T13:55:32.011466Z", "iopub.status.idle": "2026-01-06T13:55:32.015805Z", "shell.execute_reply": "2026-01-06T13:55:32.015096Z" } }, "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.asym_alpha_1.free = True\n", "experiment.peak.broad_mix_beta_0.free = True\n", "experiment.peak.broad_mix_beta_1.free = True\n", "\n", "for point in experiment.background:\n", " point.y.free = True" ] }, { "cell_type": "markdown", "id": "60", "metadata": {}, "source": [ "#### Perform Fit" ] }, { "cell_type": "code", "execution_count": 31, "id": "61", "metadata": { "execution": { "iopub.execute_input": "2026-01-06T13:55:32.018346Z", "iopub.status.busy": "2026-01-06T13:55:32.018134Z", "iopub.status.idle": "2026-01-06T13:55:40.625760Z", "shell.execute_reply": "2026-01-06T13:55:40.624272Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\u001b[1;34mUsing experiment ๐Ÿ”ฌ \u001b[0m\u001b[32m'mcstas'\u001b[0m\u001b[1;34m for \u001b[0m\u001b[32m'single'\u001b[0m\u001b[1;34m fitting\u001b[0m\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.38
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;36m6.96\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.74\u001b[0m%\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "๐Ÿ“ R-factor squared \u001b[1m(\u001b[0mRfยฒ\u001b[1m)\u001b[0m: \u001b[1;36m5.12\u001b[0m%\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "๐Ÿ“ Weighted R-factor \u001b[1m(\u001b[0mwR\u001b[1m)\u001b[0m: \u001b[1;36m5.18\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_siteCob_iso0.25670.32330.0853ร…ยฒ25.94 % โ†‘
3lbcoatom_siteOb_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 % โ†“
7mcstaspeakgauss_sigma_045137.000045210.89692868.4651ยตsยฒ0.16 % โ†‘
8mcstaspeakgauss_sigma_1-52394.0000-52476.89913797.9256ยตs/โ„ซ0.16 % โ†‘
9mcstaspeakgauss_sigma_222998.000023014.33921193.4306ยตsยฒ/โ„ซยฒ0.07 % โ†‘
10mcstaspeakmix_beta_00.00550.00550.0001deg0.64 % โ†‘
11mcstaspeakmix_beta_10.00410.00410.0003deg0.32 % โ†“
12mcstaspeakasym_alpha_10.00970.00970.00020.40 % โ†“
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" } ], "source": [ "project.analysis.fit()\n", "project.analysis.show_fit_results()" ] }, { "cell_type": "markdown", "id": "62", "metadata": {}, "source": [ "#### Plot Measured vs Calculated" ] }, { "cell_type": "code", "execution_count": 32, "id": "63", "metadata": { "execution": { "iopub.execute_input": "2026-01-06T13:55:40.631483Z", "iopub.status.busy": "2026-01-06T13:55:40.631281Z", "iopub.status.idle": "2026-01-06T13:55:41.118980Z", "shell.execute_reply": "2026-01-06T13:55:41.118306Z" } }, "outputs": [ { "data": { "text/html": [ "
\n", "
" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "project.plot_meas_vs_calc(expt_name='mcstas')" ] }, { "cell_type": "code", "execution_count": null, "id": "64", "metadata": {}, "outputs": [], "source": [] } ], "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.13.11" } }, "nbformat": 4, "nbformat_minor": 5 }