{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"id": "43a7543d",
"metadata": {
"execution": {
"iopub.execute_input": "2026-01-06T13:55:18.336493Z",
"iopub.status.busy": "2026-01-06T13:55:18.336390Z",
"iopub.status.idle": "2026-01-06T13:55:18.340339Z",
"shell.execute_reply": "2026-01-06T13:55:18.339790Z"
},
"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: NCAF, WISH\n",
"\n",
"This example demonstrates a Rietveld refinement of Na2Ca3Al2F14\n",
"crystal structure using time-of-flight neutron powder diffraction data\n",
"from WISH at ISIS.\n",
"\n",
"Two datasets from detector banks 5+6 and 4+7 are used for joint\n",
"fitting."
]
},
{
"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:18.342188Z",
"iopub.status.busy": "2026-01-06T13:55:18.342045Z",
"iopub.status.idle": "2026-01-06T13:55:22.060066Z",
"shell.execute_reply": "2026-01-06T13:55:22.058564Z"
}
},
"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 Model\n",
"\n",
"This section covers how to add sample models and modify their\n",
"parameters.\n",
"\n",
"#### Create Sample Model"
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "4",
"metadata": {
"execution": {
"iopub.execute_input": "2026-01-06T13:55:22.067828Z",
"iopub.status.busy": "2026-01-06T13:55:22.066782Z",
"iopub.status.idle": "2026-01-06T13:55:22.077350Z",
"shell.execute_reply": "2026-01-06T13:55:22.075812Z"
}
},
"outputs": [],
"source": [
"model = SampleModelFactory.create(name='ncaf')"
]
},
{
"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:22.080371Z",
"iopub.status.busy": "2026-01-06T13:55:22.079920Z",
"iopub.status.idle": "2026-01-06T13:55:22.083256Z",
"shell.execute_reply": "2026-01-06T13:55:22.082152Z"
}
},
"outputs": [],
"source": [
"model.space_group.name_h_m = 'I 21 3'\n",
"model.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:22.085437Z",
"iopub.status.busy": "2026-01-06T13:55:22.085321Z",
"iopub.status.idle": "2026-01-06T13:55:22.091678Z",
"shell.execute_reply": "2026-01-06T13:55:22.091181Z"
}
},
"outputs": [],
"source": [
"model.cell.length_a = 10.250256"
]
},
{
"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:22.094506Z",
"iopub.status.busy": "2026-01-06T13:55:22.094365Z",
"iopub.status.idle": "2026-01-06T13:55:22.102686Z",
"shell.execute_reply": "2026-01-06T13:55:22.101698Z"
}
},
"outputs": [],
"source": [
"model.atom_sites.add(\n",
" label='Ca',\n",
" type_symbol='Ca',\n",
" fract_x=0.4663,\n",
" fract_y=0.0,\n",
" fract_z=0.25,\n",
" wyckoff_letter='b',\n",
" b_iso=0.92,\n",
")\n",
"model.atom_sites.add(\n",
" label='Al',\n",
" type_symbol='Al',\n",
" fract_x=0.2521,\n",
" fract_y=0.2521,\n",
" fract_z=0.2521,\n",
" wyckoff_letter='a',\n",
" b_iso=0.73,\n",
")\n",
"model.atom_sites.add(\n",
" label='Na',\n",
" type_symbol='Na',\n",
" fract_x=0.0851,\n",
" fract_y=0.0851,\n",
" fract_z=0.0851,\n",
" wyckoff_letter='a',\n",
" b_iso=2.08,\n",
")\n",
"model.atom_sites.add(\n",
" label='F1',\n",
" type_symbol='F',\n",
" fract_x=0.1377,\n",
" fract_y=0.3054,\n",
" fract_z=0.1195,\n",
" wyckoff_letter='c',\n",
" b_iso=0.90,\n",
")\n",
"model.atom_sites.add(\n",
" label='F2',\n",
" type_symbol='F',\n",
" fract_x=0.3625,\n",
" fract_y=0.3633,\n",
" fract_z=0.1867,\n",
" wyckoff_letter='c',\n",
" b_iso=1.37,\n",
")\n",
"model.atom_sites.add(\n",
" label='F3',\n",
" type_symbol='F',\n",
" fract_x=0.4612,\n",
" fract_y=0.4612,\n",
" fract_z=0.4612,\n",
" wyckoff_letter='a',\n",
" b_iso=0.88,\n",
")"
]
},
{
"cell_type": "markdown",
"id": "11",
"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 Measured Data"
]
},
{
"cell_type": "code",
"execution_count": 7,
"id": "12",
"metadata": {
"execution": {
"iopub.execute_input": "2026-01-06T13:55:22.104903Z",
"iopub.status.busy": "2026-01-06T13:55:22.104785Z",
"iopub.status.idle": "2026-01-06T13:55:22.351599Z",
"shell.execute_reply": "2026-01-06T13:55:22.350839Z"
}
},
"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;36m9\u001b[0m: NCAF, WISH \u001b[1m(\u001b[0mISIS\u001b[1m)\u001b[0m, Detector banks \u001b[1;36m5\u001b[0m & \u001b[1;36m6\u001b[0m\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"✅ Data #\u001b[1;36m9\u001b[0m downloaded to \u001b[32m'data/ed-9.xys'\u001b[0m\n"
]
}
],
"source": [
"data_path56 = download_data(id=9, destination='data')"
]
},
{
"cell_type": "code",
"execution_count": 8,
"id": "13",
"metadata": {
"execution": {
"iopub.execute_input": "2026-01-06T13:55:22.355388Z",
"iopub.status.busy": "2026-01-06T13:55:22.353693Z",
"iopub.status.idle": "2026-01-06T13:55:22.595956Z",
"shell.execute_reply": "2026-01-06T13:55:22.585556Z"
}
},
"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;36m10\u001b[0m: NCAF, WISH \u001b[1m(\u001b[0mISIS\u001b[1m)\u001b[0m, Detector banks \u001b[1;36m4\u001b[0m & \u001b[1;36m7\u001b[0m\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"✅ Data #\u001b[1;36m10\u001b[0m downloaded to \u001b[32m'data/ed-10.xys'\u001b[0m\n"
]
}
],
"source": [
"data_path47 = download_data(id=10, destination='data')"
]
},
{
"cell_type": "markdown",
"id": "14",
"metadata": {},
"source": [
"#### Create Experiment"
]
},
{
"cell_type": "code",
"execution_count": 9,
"id": "15",
"metadata": {
"execution": {
"iopub.execute_input": "2026-01-06T13:55:22.623328Z",
"iopub.status.busy": "2026-01-06T13:55:22.622796Z",
"iopub.status.idle": "2026-01-06T13:55:23.903107Z",
"shell.execute_reply": "2026-01-06T13:55:23.899960Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\u001b[1;34mData loaded successfully\u001b[0m\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"Experiment 🔬 \u001b[32m'wish_5_6'\u001b[0m. Number of data points: \u001b[1;36m4121\u001b[0m\n"
]
}
],
"source": [
"expt56 = ExperimentFactory.create(\n",
" name='wish_5_6',\n",
" data_path=data_path56,\n",
" beam_mode='time-of-flight',\n",
")"
]
},
{
"cell_type": "code",
"execution_count": 10,
"id": "16",
"metadata": {
"execution": {
"iopub.execute_input": "2026-01-06T13:55:23.908922Z",
"iopub.status.busy": "2026-01-06T13:55:23.907993Z",
"iopub.status.idle": "2026-01-06T13:55:25.138278Z",
"shell.execute_reply": "2026-01-06T13:55:25.135118Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\u001b[1;34mData loaded successfully\u001b[0m\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"Experiment 🔬 \u001b[32m'wish_4_7'\u001b[0m. Number of data points: \u001b[1;36m4043\u001b[0m\n"
]
}
],
"source": [
"expt47 = ExperimentFactory.create(\n",
" name='wish_4_7',\n",
" data_path=data_path47,\n",
" beam_mode='time-of-flight',\n",
")"
]
},
{
"cell_type": "markdown",
"id": "17",
"metadata": {},
"source": [
"#### Set Instrument"
]
},
{
"cell_type": "code",
"execution_count": 11,
"id": "18",
"metadata": {
"execution": {
"iopub.execute_input": "2026-01-06T13:55:25.140340Z",
"iopub.status.busy": "2026-01-06T13:55:25.140081Z",
"iopub.status.idle": "2026-01-06T13:55:25.148368Z",
"shell.execute_reply": "2026-01-06T13:55:25.146546Z"
}
},
"outputs": [],
"source": [
"expt56.instrument.setup_twotheta_bank = 152.827\n",
"expt56.instrument.calib_d_to_tof_offset = -13.5\n",
"expt56.instrument.calib_d_to_tof_linear = 20773.0\n",
"expt56.instrument.calib_d_to_tof_quad = -1.08308"
]
},
{
"cell_type": "code",
"execution_count": 12,
"id": "19",
"metadata": {
"execution": {
"iopub.execute_input": "2026-01-06T13:55:25.151089Z",
"iopub.status.busy": "2026-01-06T13:55:25.150822Z",
"iopub.status.idle": "2026-01-06T13:55:25.156209Z",
"shell.execute_reply": "2026-01-06T13:55:25.154509Z"
}
},
"outputs": [],
"source": [
"expt47.instrument.setup_twotheta_bank = 121.660\n",
"expt47.instrument.calib_d_to_tof_offset = -15.0\n",
"expt47.instrument.calib_d_to_tof_linear = 18660.0\n",
"expt47.instrument.calib_d_to_tof_quad = -0.47488"
]
},
{
"cell_type": "markdown",
"id": "20",
"metadata": {},
"source": [
"#### Set Peak Profile"
]
},
{
"cell_type": "code",
"execution_count": 13,
"id": "21",
"metadata": {
"execution": {
"iopub.execute_input": "2026-01-06T13:55:25.158582Z",
"iopub.status.busy": "2026-01-06T13:55:25.158325Z",
"iopub.status.idle": "2026-01-06T13:55:25.163494Z",
"shell.execute_reply": "2026-01-06T13:55:25.162985Z"
}
},
"outputs": [],
"source": [
"expt56.peak.broad_gauss_sigma_0 = 0.0\n",
"expt56.peak.broad_gauss_sigma_1 = 0.0\n",
"expt56.peak.broad_gauss_sigma_2 = 15.5\n",
"expt56.peak.broad_mix_beta_0 = 0.007\n",
"expt56.peak.broad_mix_beta_1 = 0.01\n",
"expt56.peak.asym_alpha_0 = -0.0094\n",
"expt56.peak.asym_alpha_1 = 0.1"
]
},
{
"cell_type": "code",
"execution_count": 14,
"id": "22",
"metadata": {
"execution": {
"iopub.execute_input": "2026-01-06T13:55:25.165204Z",
"iopub.status.busy": "2026-01-06T13:55:25.165038Z",
"iopub.status.idle": "2026-01-06T13:55:25.172700Z",
"shell.execute_reply": "2026-01-06T13:55:25.171435Z"
}
},
"outputs": [],
"source": [
"expt47.peak.broad_gauss_sigma_0 = 0.0\n",
"expt47.peak.broad_gauss_sigma_1 = 29.8\n",
"expt47.peak.broad_gauss_sigma_2 = 18.0\n",
"expt47.peak.broad_mix_beta_0 = 0.006\n",
"expt47.peak.broad_mix_beta_1 = 0.015\n",
"expt47.peak.asym_alpha_0 = -0.0115\n",
"expt47.peak.asym_alpha_1 = 0.1"
]
},
{
"cell_type": "markdown",
"id": "23",
"metadata": {},
"source": [
"#### Set Background"
]
},
{
"cell_type": "code",
"execution_count": 15,
"id": "24",
"metadata": {
"execution": {
"iopub.execute_input": "2026-01-06T13:55:25.178730Z",
"iopub.status.busy": "2026-01-06T13:55:25.177953Z",
"iopub.status.idle": "2026-01-06T13:55:25.196618Z",
"shell.execute_reply": "2026-01-06T13:55:25.192148Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\u001b[1;34mBackground type for experiment \u001b[0m\u001b[32m'wish_5_6'\u001b[0m\u001b[1;34m changed to\u001b[0m\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"line-segment\n"
]
}
],
"source": [
"expt56.background_type = 'line-segment'\n",
"for idx, (x, y) in enumerate(\n",
" [\n",
" (9162, 465),\n",
" (11136, 593),\n",
" (13313, 497),\n",
" (14906, 546),\n",
" (16454, 533),\n",
" (17352, 496),\n",
" (18743, 428),\n",
" (20179, 452),\n",
" (21368, 397),\n",
" (22176, 468),\n",
" (22827, 477),\n",
" (24644, 380),\n",
" (26439, 381),\n",
" (28257, 378),\n",
" (31196, 343),\n",
" (34034, 328),\n",
" (37265, 310),\n",
" (41214, 323),\n",
" (44827, 283),\n",
" (49830, 273),\n",
" (52905, 257),\n",
" (58204, 260),\n",
" (62916, 261),\n",
" (70186, 262),\n",
" (74204, 262),\n",
" (82103, 268),\n",
" (91958, 268),\n",
" (102712, 262),\n",
" ],\n",
" start=1,\n",
"):\n",
" expt56.background.add(id=str(idx), x=x, y=y)"
]
},
{
"cell_type": "code",
"execution_count": 16,
"id": "25",
"metadata": {
"execution": {
"iopub.execute_input": "2026-01-06T13:55:25.202023Z",
"iopub.status.busy": "2026-01-06T13:55:25.201719Z",
"iopub.status.idle": "2026-01-06T13:55:25.220054Z",
"shell.execute_reply": "2026-01-06T13:55:25.217992Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\u001b[1;34mBackground type for experiment \u001b[0m\u001b[32m'wish_4_7'\u001b[0m\u001b[1;34m changed to\u001b[0m\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"line-segment\n"
]
}
],
"source": [
"expt47.background_type = 'line-segment'\n",
"for idx, (x, y) in enumerate(\n",
" [\n",
" (9090, 488),\n",
" (10672, 566),\n",
" (12287, 494),\n",
" (14037, 559),\n",
" (15451, 529),\n",
" (16764, 445),\n",
" (18076, 460),\n",
" (19456, 413),\n",
" (20466, 511),\n",
" (21880, 396),\n",
" (23798, 391),\n",
" (25447, 385),\n",
" (28073, 349),\n",
" (30058, 332),\n",
" (32583, 309),\n",
" (34804, 355),\n",
" (37160, 318),\n",
" (40324, 290),\n",
" (46895, 260),\n",
" (50631, 256),\n",
" (54602, 246),\n",
" (58439, 264),\n",
" (66520, 250),\n",
" (75002, 258),\n",
" (83649, 257),\n",
" (92770, 255),\n",
" (101524, 260),\n",
" ],\n",
" start=1,\n",
"):\n",
" expt47.background.add(id=str(idx), x=x, y=y)"
]
},
{
"cell_type": "markdown",
"id": "26",
"metadata": {},
"source": [
"#### Set Linked Phases"
]
},
{
"cell_type": "code",
"execution_count": 17,
"id": "27",
"metadata": {
"execution": {
"iopub.execute_input": "2026-01-06T13:55:25.223737Z",
"iopub.status.busy": "2026-01-06T13:55:25.223357Z",
"iopub.status.idle": "2026-01-06T13:55:25.228464Z",
"shell.execute_reply": "2026-01-06T13:55:25.227541Z"
}
},
"outputs": [],
"source": [
"expt56.linked_phases.add(id='ncaf', scale=1.0)"
]
},
{
"cell_type": "code",
"execution_count": 18,
"id": "28",
"metadata": {
"execution": {
"iopub.execute_input": "2026-01-06T13:55:25.234897Z",
"iopub.status.busy": "2026-01-06T13:55:25.234533Z",
"iopub.status.idle": "2026-01-06T13:55:25.239120Z",
"shell.execute_reply": "2026-01-06T13:55:25.237934Z"
}
},
"outputs": [],
"source": [
"expt47.linked_phases.add(id='ncaf', scale=2.0)"
]
},
{
"cell_type": "markdown",
"id": "29",
"metadata": {},
"source": [
"#### Set Excluded Regions"
]
},
{
"cell_type": "code",
"execution_count": 19,
"id": "30",
"metadata": {
"execution": {
"iopub.execute_input": "2026-01-06T13:55:25.243902Z",
"iopub.status.busy": "2026-01-06T13:55:25.243537Z",
"iopub.status.idle": "2026-01-06T13:55:25.251412Z",
"shell.execute_reply": "2026-01-06T13:55:25.248565Z"
}
},
"outputs": [],
"source": [
"expt56.excluded_regions.add(id='1', start=0, end=10010)\n",
"expt56.excluded_regions.add(id='2', start=100010, end=200000)"
]
},
{
"cell_type": "code",
"execution_count": 20,
"id": "31",
"metadata": {
"execution": {
"iopub.execute_input": "2026-01-06T13:55:25.254890Z",
"iopub.status.busy": "2026-01-06T13:55:25.253192Z",
"iopub.status.idle": "2026-01-06T13:55:25.257889Z",
"shell.execute_reply": "2026-01-06T13:55:25.256743Z"
}
},
"outputs": [],
"source": [
"expt47.excluded_regions.add(id='1', start=0, end=10006)\n",
"expt47.excluded_regions.add(id='2', start=100004, end=200000)"
]
},
{
"cell_type": "markdown",
"id": "32",
"metadata": {},
"source": [
"## Define Project\n",
"\n",
"The project object is used to manage the sample model, experiments,\n",
"and analysis\n",
"\n",
"#### Create Project"
]
},
{
"cell_type": "code",
"execution_count": 21,
"id": "33",
"metadata": {
"execution": {
"iopub.execute_input": "2026-01-06T13:55:25.261033Z",
"iopub.status.busy": "2026-01-06T13:55:25.260198Z",
"iopub.status.idle": "2026-01-06T13:55:25.461568Z",
"shell.execute_reply": "2026-01-06T13:55:25.460873Z"
}
},
"outputs": [],
"source": [
"project = Project()"
]
},
{
"cell_type": "markdown",
"id": "34",
"metadata": {},
"source": [
"#### Set Plotting Engine"
]
},
{
"cell_type": "code",
"execution_count": 22,
"id": "35",
"metadata": {
"execution": {
"iopub.execute_input": "2026-01-06T13:55:25.469653Z",
"iopub.status.busy": "2026-01-06T13:55:25.469436Z",
"iopub.status.idle": "2026-01-06T13:55:25.479364Z",
"shell.execute_reply": "2026-01-06T13:55:25.476218Z"
}
},
"outputs": [],
"source": [
"# Keep the auto-selected engine. Alternatively, you can uncomment the\n",
"# line below to explicitly set the engine to the required one.\n",
"# project.plotter.engine = 'plotly'"
]
},
{
"cell_type": "markdown",
"id": "36",
"metadata": {},
"source": [
"#### Add Sample Model"
]
},
{
"cell_type": "code",
"execution_count": 23,
"id": "37",
"metadata": {
"execution": {
"iopub.execute_input": "2026-01-06T13:55:25.489309Z",
"iopub.status.busy": "2026-01-06T13:55:25.487216Z",
"iopub.status.idle": "2026-01-06T13:55:25.494054Z",
"shell.execute_reply": "2026-01-06T13:55:25.491545Z"
}
},
"outputs": [],
"source": [
"project.sample_models.add(sample_model=model)"
]
},
{
"cell_type": "markdown",
"id": "38",
"metadata": {},
"source": [
"#### Add Experiment"
]
},
{
"cell_type": "code",
"execution_count": 24,
"id": "39",
"metadata": {
"execution": {
"iopub.execute_input": "2026-01-06T13:55:25.495874Z",
"iopub.status.busy": "2026-01-06T13:55:25.495742Z",
"iopub.status.idle": "2026-01-06T13:55:25.502525Z",
"shell.execute_reply": "2026-01-06T13:55:25.500560Z"
}
},
"outputs": [],
"source": [
"project.experiments.add(experiment=expt56)\n",
"project.experiments.add(experiment=expt47)"
]
},
{
"cell_type": "markdown",
"id": "40",
"metadata": {},
"source": [
"## Perform Analysis\n",
"\n",
"This section shows the analysis process, including how to set up\n",
"calculation and fitting engines.\n",
"\n",
"#### Set Calculator"
]
},
{
"cell_type": "code",
"execution_count": 25,
"id": "41",
"metadata": {
"execution": {
"iopub.execute_input": "2026-01-06T13:55:25.505502Z",
"iopub.status.busy": "2026-01-06T13:55:25.504556Z",
"iopub.status.idle": "2026-01-06T13:55:25.512739Z",
"shell.execute_reply": "2026-01-06T13:55:25.510875Z"
}
},
"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": "42",
"metadata": {},
"source": [
"#### Set Minimizer"
]
},
{
"cell_type": "code",
"execution_count": 26,
"id": "43",
"metadata": {
"execution": {
"iopub.execute_input": "2026-01-06T13:55:25.517363Z",
"iopub.status.busy": "2026-01-06T13:55:25.516477Z",
"iopub.status.idle": "2026-01-06T13:55:25.525637Z",
"shell.execute_reply": "2026-01-06T13:55:25.522787Z"
}
},
"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": "44",
"metadata": {},
"source": [
"#### Set Fit Mode"
]
},
{
"cell_type": "code",
"execution_count": 27,
"id": "45",
"metadata": {
"execution": {
"iopub.execute_input": "2026-01-06T13:55:25.529617Z",
"iopub.status.busy": "2026-01-06T13:55:25.529322Z",
"iopub.status.idle": "2026-01-06T13:55:25.534737Z",
"shell.execute_reply": "2026-01-06T13:55:25.533905Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\u001b[1;34mCurrent fit mode changed to\u001b[0m\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"joint\n"
]
}
],
"source": [
"project.analysis.fit_mode = 'joint'"
]
},
{
"cell_type": "markdown",
"id": "46",
"metadata": {},
"source": [
"#### Set Free Parameters"
]
},
{
"cell_type": "code",
"execution_count": 28,
"id": "47",
"metadata": {
"execution": {
"iopub.execute_input": "2026-01-06T13:55:25.538026Z",
"iopub.status.busy": "2026-01-06T13:55:25.537372Z",
"iopub.status.idle": "2026-01-06T13:55:25.541203Z",
"shell.execute_reply": "2026-01-06T13:55:25.540785Z"
}
},
"outputs": [],
"source": [
"model.atom_sites['Ca'].b_iso.free = True\n",
"model.atom_sites['Al'].b_iso.free = True\n",
"model.atom_sites['Na'].b_iso.free = True\n",
"model.atom_sites['F1'].b_iso.free = True\n",
"model.atom_sites['F2'].b_iso.free = True\n",
"model.atom_sites['F3'].b_iso.free = True"
]
},
{
"cell_type": "code",
"execution_count": 29,
"id": "48",
"metadata": {
"execution": {
"iopub.execute_input": "2026-01-06T13:55:25.543728Z",
"iopub.status.busy": "2026-01-06T13:55:25.543291Z",
"iopub.status.idle": "2026-01-06T13:55:25.554563Z",
"shell.execute_reply": "2026-01-06T13:55:25.553375Z"
}
},
"outputs": [],
"source": [
"expt56.linked_phases['ncaf'].scale.free = True\n",
"expt56.instrument.calib_d_to_tof_offset.free = True\n",
"expt56.instrument.calib_d_to_tof_linear.free = True\n",
"expt56.peak.broad_gauss_sigma_2.free = True\n",
"expt56.peak.broad_mix_beta_0.free = True\n",
"expt56.peak.broad_mix_beta_1.free = True\n",
"expt56.peak.asym_alpha_1.free = True\n",
"\n",
"expt47.linked_phases['ncaf'].scale.free = True\n",
"expt47.instrument.calib_d_to_tof_linear.free = True\n",
"expt47.instrument.calib_d_to_tof_offset.free = True\n",
"expt47.peak.broad_gauss_sigma_2.free = True\n",
"expt47.peak.broad_mix_beta_0.free = True\n",
"expt47.peak.broad_mix_beta_1.free = True\n",
"expt47.peak.asym_alpha_1.free = True"
]
},
{
"cell_type": "markdown",
"id": "49",
"metadata": {},
"source": [
"#### Plot Measured vs Calculated"
]
},
{
"cell_type": "code",
"execution_count": 30,
"id": "50",
"metadata": {
"execution": {
"iopub.execute_input": "2026-01-06T13:55:25.559041Z",
"iopub.status.busy": "2026-01-06T13:55:25.558096Z",
"iopub.status.idle": "2026-01-06T13:55:26.679361Z",
"shell.execute_reply": "2026-01-06T13:55:26.678638Z"
}
},
"outputs": [
{
"data": {
"text/html": [
"
"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"project.plot_meas_vs_calc(expt_name='wish_5_6', show_residual=True)"
]
},
{
"cell_type": "code",
"execution_count": 31,
"id": "51",
"metadata": {
"execution": {
"iopub.execute_input": "2026-01-06T13:55:26.682685Z",
"iopub.status.busy": "2026-01-06T13:55:26.682498Z",
"iopub.status.idle": "2026-01-06T13:55:27.314978Z",
"shell.execute_reply": "2026-01-06T13:55:27.314184Z"
}
},
"outputs": [
{
"data": {
"text/html": [
""
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"project.plot_meas_vs_calc(expt_name='wish_4_7', show_residual=True)"
]
},
{
"cell_type": "markdown",
"id": "52",
"metadata": {},
"source": [
"#### Run Fitting"
]
},
{
"cell_type": "code",
"execution_count": 32,
"id": "53",
"metadata": {
"execution": {
"iopub.execute_input": "2026-01-06T13:55:27.317328Z",
"iopub.status.busy": "2026-01-06T13:55:27.317198Z",
"iopub.status.idle": "2026-01-06T13:57:05.717023Z",
"shell.execute_reply": "2026-01-06T13:57:05.713232Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\u001b[1;34mUsing all experiments 🔬 \u001b[0m\u001b[1;34m[\u001b[0m\u001b[32m'wish_5_6'\u001b[0m\u001b[1;34m, \u001b[0m\u001b[32m'wish_4_7'\u001b[0m\u001b[1;34m]\u001b[0m\u001b[1;34m for \u001b[0m\u001b[32m'joint'\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",
" iteration | \n",
" χ² | \n",
" improvement [%] | \n",
"
\n",
" \n",
" \n",
" \n",
" | 1 | \n",
" 1 | \n",
" 47.53 | \n",
" | \n",
"
\n",
" \n",
" | 2 | \n",
" 24 | \n",
" 15.57 | \n",
" 67.2% ↓ | \n",
"
\n",
" \n",
" | 3 | \n",
" 109 | \n",
" 15.49 | \n",
" | \n",
"
\n",
" \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;36m15.49\u001b[0m at iteration \u001b[1;36m95\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;36m95.41\u001b[0m seconds\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"📏 Goodness-of-fit \u001b[1m(\u001b[0mreduced χ²\u001b[1m)\u001b[0m: \u001b[1;36m15.49\u001b[0m\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"📏 R-factor \u001b[1m(\u001b[0mRf\u001b[1m)\u001b[0m: \u001b[1;36m6.97\u001b[0m%\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"📏 R-factor squared \u001b[1m(\u001b[0mRf²\u001b[1m)\u001b[0m: \u001b[1;36m8.03\u001b[0m%\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"📏 Weighted R-factor \u001b[1m(\u001b[0mwR\u001b[1m)\u001b[0m: \u001b[1;36m9.12\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",
" datablock | \n",
" category | \n",
" entry | \n",
" parameter | \n",
" start | \n",
" fitted | \n",
" uncertainty | \n",
" units | \n",
" change | \n",
"
\n",
" \n",
" \n",
" \n",
" | 1 | \n",
" ncaf | \n",
" atom_site | \n",
" Ca | \n",
" b_iso | \n",
" 0.9200 | \n",
" 0.9340 | \n",
" 0.0448 | \n",
" Ų | \n",
" 1.52 % ↑ | \n",
"
\n",
" \n",
" | 2 | \n",
" ncaf | \n",
" atom_site | \n",
" Al | \n",
" b_iso | \n",
" 0.7300 | \n",
" 0.7330 | \n",
" 0.0569 | \n",
" Ų | \n",
" 0.41 % ↑ | \n",
"
\n",
" \n",
" | 3 | \n",
" ncaf | \n",
" atom_site | \n",
" Na | \n",
" b_iso | \n",
" 2.0800 | \n",
" 2.0474 | \n",
" 0.1082 | \n",
" Ų | \n",
" 1.57 % ↓ | \n",
"
\n",
" \n",
" | 4 | \n",
" ncaf | \n",
" atom_site | \n",
" F1 | \n",
" b_iso | \n",
" 0.9000 | \n",
" 0.9389 | \n",
" 0.0373 | \n",
" Ų | \n",
" 4.32 % ↑ | \n",
"
\n",
" \n",
" | 5 | \n",
" ncaf | \n",
" atom_site | \n",
" F2 | \n",
" b_iso | \n",
" 1.3700 | \n",
" 1.3442 | \n",
" 0.0408 | \n",
" Ų | \n",
" 1.88 % ↓ | \n",
"
\n",
" \n",
" | 6 | \n",
" ncaf | \n",
" atom_site | \n",
" F3 | \n",
" b_iso | \n",
" 0.8800 | \n",
" 0.8481 | \n",
" 0.0551 | \n",
" Ų | \n",
" 3.62 % ↓ | \n",
"
\n",
" \n",
" | 7 | \n",
" wish_5_6 | \n",
" linked_phases | \n",
" ncaf | \n",
" scale | \n",
" 1.0000 | \n",
" 1.1029 | \n",
" 0.0035 | \n",
" | \n",
" 10.29 % ↑ | \n",
"
\n",
" \n",
" | 8 | \n",
" wish_5_6 | \n",
" peak | \n",
" | \n",
" gauss_sigma_2 | \n",
" 15.5000 | \n",
" 15.6543 | \n",
" 0.7398 | \n",
" µs²/Ų | \n",
" 1.00 % ↑ | \n",
"
\n",
" \n",
" | 9 | \n",
" wish_5_6 | \n",
" peak | \n",
" | \n",
" mix_beta_0 | \n",
" 0.0070 | \n",
" 0.0067 | \n",
" 0.0000 | \n",
" deg | \n",
" 4.54 % ↓ | \n",
"
\n",
" \n",
" | 10 | \n",
" wish_5_6 | \n",
" peak | \n",
" | \n",
" mix_beta_1 | \n",
" 0.0100 | \n",
" 0.0101 | \n",
" 0.0002 | \n",
" deg | \n",
" 1.46 % ↑ | \n",
"
\n",
" \n",
" | 11 | \n",
" wish_5_6 | \n",
" peak | \n",
" | \n",
" asym_alpha_1 | \n",
" 0.1000 | \n",
" 0.1094 | \n",
" 0.0012 | \n",
" | \n",
" 9.43 % ↑ | \n",
"
\n",
" \n",
" | 12 | \n",
" wish_5_6 | \n",
" instrument | \n",
" | \n",
" d_to_tof_offset | \n",
" -13.5000 | \n",
" -13.6260 | \n",
" 0.4257 | \n",
" µs | \n",
" 0.93 % ↑ | \n",
"
\n",
" \n",
" | 13 | \n",
" wish_5_6 | \n",
" instrument | \n",
" | \n",
" d_to_tof_linear | \n",
" 20773.0000 | \n",
" 20773.0394 | \n",
" 0.3051 | \n",
" µs/Å | \n",
" 0.00 % ↑ | \n",
"
\n",
" \n",
" | 14 | \n",
" wish_4_7 | \n",
" linked_phases | \n",
" ncaf | \n",
" scale | \n",
" 2.0000 | \n",
" 2.5216 | \n",
" 0.0077 | \n",
" | \n",
" 26.08 % ↑ | \n",
"
\n",
" \n",
" | 15 | \n",
" wish_4_7 | \n",
" peak | \n",
" | \n",
" gauss_sigma_2 | \n",
" 18.0000 | \n",
" 18.2604 | \n",
" 0.8685 | \n",
" µs²/Ų | \n",
" 1.45 % ↑ | \n",
"
\n",
" \n",
" | 16 | \n",
" wish_4_7 | \n",
" peak | \n",
" | \n",
" mix_beta_0 | \n",
" 0.0060 | \n",
" 0.0065 | \n",
" 0.0000 | \n",
" deg | \n",
" 7.52 % ↑ | \n",
"
\n",
" \n",
" | 17 | \n",
" wish_4_7 | \n",
" peak | \n",
" | \n",
" mix_beta_1 | \n",
" 0.0150 | \n",
" 0.0148 | \n",
" 0.0003 | \n",
" deg | \n",
" 1.38 % ↓ | \n",
"
\n",
" \n",
" | 18 | \n",
" wish_4_7 | \n",
" peak | \n",
" | \n",
" asym_alpha_1 | \n",
" 0.1000 | \n",
" 0.1222 | \n",
" 0.0018 | \n",
" | \n",
" 22.15 % ↑ | \n",
"
\n",
" \n",
" | 19 | \n",
" wish_4_7 | \n",
" instrument | \n",
" | \n",
" d_to_tof_offset | \n",
" -15.0000 | \n",
" -14.9768 | \n",
" 0.5084 | \n",
" µs | \n",
" 0.15 % ↓ | \n",
"
\n",
" \n",
" | 20 | \n",
" wish_4_7 | \n",
" instrument | \n",
" | \n",
" d_to_tof_linear | \n",
" 18660.0000 | \n",
" 18660.1028 | \n",
" 0.3625 | \n",
" µs/Å | \n",
" 0.00 % ↑ | \n",
"
\n",
" \n",
"
\n"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"project.analysis.fit()\n",
"project.analysis.show_fit_results()"
]
},
{
"cell_type": "markdown",
"id": "54",
"metadata": {},
"source": [
"#### Plot Measured vs Calculated"
]
},
{
"cell_type": "code",
"execution_count": 33,
"id": "55",
"metadata": {
"execution": {
"iopub.execute_input": "2026-01-06T13:57:05.725226Z",
"iopub.status.busy": "2026-01-06T13:57:05.723531Z",
"iopub.status.idle": "2026-01-06T13:57:06.864086Z",
"shell.execute_reply": "2026-01-06T13:57:06.862309Z"
}
},
"outputs": [
{
"data": {
"text/html": [
""
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"project.plot_meas_vs_calc(expt_name='wish_5_6', show_residual=True)"
]
},
{
"cell_type": "code",
"execution_count": 34,
"id": "56",
"metadata": {
"execution": {
"iopub.execute_input": "2026-01-06T13:57:06.866644Z",
"iopub.status.busy": "2026-01-06T13:57:06.866444Z",
"iopub.status.idle": "2026-01-06T13:57:07.765242Z",
"shell.execute_reply": "2026-01-06T13:57:07.764092Z"
}
},
"outputs": [
{
"data": {
"text/html": [
""
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"project.plot_meas_vs_calc(expt_name='wish_4_7', show_residual=True)"
]
},
{
"cell_type": "markdown",
"id": "57",
"metadata": {},
"source": [
"## Summary\n",
"\n",
"This final section shows how to review the results of the analysis."
]
},
{
"cell_type": "markdown",
"id": "58",
"metadata": {},
"source": [
"#### Show Project Summary"
]
},
{
"cell_type": "code",
"execution_count": 35,
"id": "59",
"metadata": {
"execution": {
"iopub.execute_input": "2026-01-06T13:57:07.767398Z",
"iopub.status.busy": "2026-01-06T13:57:07.767244Z",
"iopub.status.idle": "2026-01-06T13:57:08.760698Z",
"shell.execute_reply": "2026-01-06T13:57:08.760243Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\u001b[1;32m————————————\u001b[0m\n",
"\u001b[1;32mPROJECT INFO\u001b[0m\n",
"\u001b[1;32m————————————\u001b[0m\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"\u001b[1;34mTitle\u001b[0m\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"Untitled Project\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"\u001b[1;32m—————————————————————\u001b[0m\n",
"\u001b[1;32mCRYSTALLOGRAPHIC DATA\u001b[0m\n",
"\u001b[1;32m—————————————————————\u001b[0m\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"\u001b[1;34mPhase datablock\u001b[0m\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"🧩 ncaf\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"\u001b[1;34mSpace group\u001b[0m\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"I \u001b[1;36m21\u001b[0m \u001b[1;36m3\u001b[0m\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"\u001b[1;34mCell parameters\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",
" Parameter | \n",
" Value | \n",
"
\n",
" \n",
" \n",
" \n",
" | 1 | \n",
" a | \n",
" 10.25026 | \n",
"
\n",
" \n",
" | 2 | \n",
" b | \n",
" 10.25026 | \n",
"
\n",
" \n",
" | 3 | \n",
" c | \n",
" 10.25026 | \n",
"
\n",
" \n",
" | 4 | \n",
" alpha | \n",
" 90.00000 | \n",
"
\n",
" \n",
" | 5 | \n",
" beta | \n",
" 90.00000 | \n",
"
\n",
" \n",
" | 6 | \n",
" gamma | \n",
" 90.00000 | \n",
"
\n",
" \n",
"
\n"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"\u001b[1;34mAtom sites\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",
" label | \n",
" type | \n",
" x | \n",
" y | \n",
" z | \n",
" occ | \n",
" Biso | \n",
"
\n",
" \n",
" \n",
" \n",
" | 1 | \n",
" Ca | \n",
" Ca | \n",
" 0.46630 | \n",
" 0.00000 | \n",
" 0.25000 | \n",
" 1.00000 | \n",
" 0.93400 | \n",
"
\n",
" \n",
" | 2 | \n",
" Al | \n",
" Al | \n",
" 0.25210 | \n",
" 0.25210 | \n",
" 0.25210 | \n",
" 1.00000 | \n",
" 0.73301 | \n",
"
\n",
" \n",
" | 3 | \n",
" Na | \n",
" Na | \n",
" 0.08510 | \n",
" 0.08510 | \n",
" 0.08510 | \n",
" 1.00000 | \n",
" 2.04740 | \n",
"
\n",
" \n",
" | 4 | \n",
" F1 | \n",
" F | \n",
" 0.13770 | \n",
" 0.30540 | \n",
" 0.11950 | \n",
" 1.00000 | \n",
" 0.93890 | \n",
"
\n",
" \n",
" | 5 | \n",
" F2 | \n",
" F | \n",
" 0.36250 | \n",
" 0.36330 | \n",
" 0.18670 | \n",
" 1.00000 | \n",
" 1.34424 | \n",
"
\n",
" \n",
" | 6 | \n",
" F3 | \n",
" F | \n",
" 0.46120 | \n",
" 0.46120 | \n",
" 0.46120 | \n",
" 1.00000 | \n",
" 0.84814 | \n",
"
\n",
" \n",
"
\n"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"\u001b[1;32m———————————\u001b[0m\n",
"\u001b[1;32mEXPERIMENTS\u001b[0m\n",
"\u001b[1;32m———————————\u001b[0m\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"\u001b[1;34mExperiment datablock\u001b[0m\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"🔬 wish_5_6\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"\u001b[1;34mExperiment type\u001b[0m\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"powder, neutron, time-of-flight\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"\u001b[1;34mProfile type\u001b[0m\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"PeakProfileTypeEnum.PSEUDO_VOIGT_IKEDA_CARPENTER\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"\u001b[1;34mExperiment datablock\u001b[0m\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"🔬 wish_4_7\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"\u001b[1;34mExperiment type\u001b[0m\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"powder, neutron, time-of-flight\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"\u001b[1;34mProfile type\u001b[0m\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"PeakProfileTypeEnum.PSEUDO_VOIGT_IKEDA_CARPENTER\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"\u001b[1;32m———————\u001b[0m\n",
"\u001b[1;32mFITTING\u001b[0m\n",
"\u001b[1;32m———————\u001b[0m\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"\u001b[1;34mCalculation engine\u001b[0m\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"cryspy\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"\u001b[1;34mMinimization engine\u001b[0m\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"lmfit \u001b[1m(\u001b[0mleastsq\u001b[1m)\u001b[0m\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"\u001b[1;34mFit quality\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",
" metric | \n",
" value | \n",
"
\n",
" \n",
" \n",
" \n",
" | 1 | \n",
" Goodness-of-fit (reduced χ²) | \n",
" 15.49 | \n",
"
\n",
" \n",
"
\n"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"project.summary.show_report()"
]
}
],
"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
}