{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"id": "0",
"metadata": {
"execution": {
"iopub.execute_input": "2026-06-30T22:32:42.586894Z",
"iopub.status.busy": "2026-06-30T22:32:42.586744Z",
"iopub.status.idle": "2026-06-30T22:32:42.591299Z",
"shell.execute_reply": "2026-06-30T22:32:42.590398Z"
},
"tags": [
"hide-in-docs"
]
},
"outputs": [],
"source": [
"# Check whether easydiffraction is installed; install it if needed.\n",
"# Required for remote environments such as Google Colab.\n",
"import importlib.util\n",
"\n",
"if importlib.util.find_spec('easydiffraction') is None:\n",
" %pip install easydiffraction==0.19.1"
]
},
{
"cell_type": "markdown",
"id": "1",
"metadata": {},
"source": [
"# Structure Refinement: LBCO, HRPT\n",
"\n",
"This example demonstrates how to use the EasyDiffraction API in a\n",
"simplified, user-friendly manner that closely follows the GUI workflow\n",
"for a Rietveld refinement of La0.5Ba0.5CoO3 crystal structure using\n",
"constant wavelength neutron powder diffraction data from HRPT at PSI.\n",
"\n",
"It is intended for users with minimal programming experience who want\n",
"to learn how to perform standard crystal structure fitting using\n",
"diffraction data. This script covers creating a project, adding\n",
"crystal structures and experiments, performing analysis, and refining\n",
"parameters.\n",
"\n",
"Only a single import of `easydiffraction` is required, and all\n",
"operations are performed through high-level components of the\n",
"`project` object, such as `project.structures`,\n",
"`project.experiments`, and `project.analysis`. The `project` object is\n",
"the main container for all information."
]
},
{
"cell_type": "markdown",
"id": "2",
"metadata": {},
"source": [
"## π οΈ Import Library"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "3",
"metadata": {
"execution": {
"iopub.execute_input": "2026-06-30T22:32:42.593314Z",
"iopub.status.busy": "2026-06-30T22:32:42.593151Z",
"iopub.status.idle": "2026-06-30T22:32:45.459772Z",
"shell.execute_reply": "2026-06-30T22:32:45.458950Z"
}
},
"outputs": [],
"source": [
"import easydiffraction as edi"
]
},
{
"cell_type": "markdown",
"id": "4",
"metadata": {},
"source": [
"## π¦ Define Project\n",
"\n",
"This section explains how to create a project and define its metadata."
]
},
{
"cell_type": "markdown",
"id": "5",
"metadata": {},
"source": [
"### Create Project"
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "6",
"metadata": {
"execution": {
"iopub.execute_input": "2026-06-30T22:32:45.462000Z",
"iopub.status.busy": "2026-06-30T22:32:45.461704Z",
"iopub.status.idle": "2026-06-30T22:32:45.674011Z",
"shell.execute_reply": "2026-06-30T22:32:45.673314Z"
}
},
"outputs": [],
"source": [
"project = edi.Project(name='lbco_hrpt')"
]
},
{
"cell_type": "markdown",
"id": "7",
"metadata": {},
"source": [
"### Set Project Metadata"
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "8",
"metadata": {
"execution": {
"iopub.execute_input": "2026-06-30T22:32:45.676166Z",
"iopub.status.busy": "2026-06-30T22:32:45.675986Z",
"iopub.status.idle": "2026-06-30T22:32:45.679216Z",
"shell.execute_reply": "2026-06-30T22:32:45.678504Z"
}
},
"outputs": [],
"source": [
"project.metadata.title = 'La0.5Ba0.5CoO3 at HRPT@PSI'\n",
"project.metadata.description = \"\"\"This project demonstrates a standard\n",
"refinement of La0.5Ba0.5CoO3, which crystallizes in a perovskite-type\n",
"structure, using neutron powder diffraction data collected in constant\n",
"wavelength mode at the HRPT diffractometer (PSI).\"\"\""
]
},
{
"cell_type": "markdown",
"id": "9",
"metadata": {},
"source": [
"### Show Project Metadata as Text"
]
},
{
"cell_type": "code",
"execution_count": 5,
"id": "10",
"metadata": {
"execution": {
"iopub.execute_input": "2026-06-30T22:32:45.681082Z",
"iopub.status.busy": "2026-06-30T22:32:45.680910Z",
"iopub.status.idle": "2026-06-30T22:32:45.695743Z",
"shell.execute_reply": "2026-06-30T22:32:45.694867Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\u001b[1;36mProject π¦ \u001b[0m\u001b[32m'lbco_hrpt'\u001b[0m\u001b[1;36m metadata as text\u001b[0m\n"
]
},
{
"data": {
"text/html": [
"
| Edi |
|---|
| 1 | _metadata.name lbco_hrpt |
|---|
| 2 | _metadata.title "La0.5Ba0.5CoO3 at HRPT@PSI" |
|---|
| 3 | _metadata.description |
|---|
| 4 | ; |
|---|
| 5 | This project demonstrates a standard refinement of |
|---|
| 6 | La0.5Ba0.5CoO3, which crystallizes in a perovskite-type |
|---|
| 7 | structure, using neutron powder diffraction data collected |
|---|
| 8 | in constant wavelength mode at the HRPT diffractometer |
|---|
| 9 | (PSI). |
|---|
| 10 | ; |
|---|
| 11 | _metadata.created "30 Jun 2026 22:32:45" |
|---|
| 12 | _metadata.last_modified "30 Jun 2026 22:32:45" |
|---|
| 13 | _metadata.timestamp ? |
|---|
"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"project.metadata.show_as_text()"
]
},
{
"cell_type": "markdown",
"id": "11",
"metadata": {},
"source": [
"### Save Project\n",
"\n",
"When saving the project for the first time, you need to specify the\n",
"directory path."
]
},
{
"cell_type": "code",
"execution_count": 6,
"id": "12",
"metadata": {
"execution": {
"iopub.execute_input": "2026-06-30T22:32:45.697474Z",
"iopub.status.busy": "2026-06-30T22:32:45.697232Z",
"iopub.status.idle": "2026-06-30T22:32:45.756290Z",
"shell.execute_reply": "2026-06-30T22:32:45.755386Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\u001b[1;36mSaving project π¦ \u001b[0m\u001b[32m'lbco_hrpt'\u001b[0m\u001b[1;36m to \u001b[0m\u001b[32m'../../../projects/refine-lbco-hrpt-report'\u001b[0m\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"βββ π project.edi\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"βββ π structures/\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"βββ π experiments/\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"βββ π analysis/\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"β βββ π analysis.edi\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"βββ π reports/\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
" βββ π lbco_hrpt.html\n"
]
}
],
"source": [
"project.save_as(dir_path='projects/refine-lbco-hrpt-report')"
]
},
{
"cell_type": "markdown",
"id": "13",
"metadata": {},
"source": [
"## π§© Define Structure\n",
"\n",
"This section shows how to add structures and modify their\n",
"parameters."
]
},
{
"cell_type": "markdown",
"id": "14",
"metadata": {},
"source": [
"### Add Structure"
]
},
{
"cell_type": "code",
"execution_count": 7,
"id": "15",
"metadata": {
"execution": {
"iopub.execute_input": "2026-06-30T22:32:45.757912Z",
"iopub.status.busy": "2026-06-30T22:32:45.757735Z",
"iopub.status.idle": "2026-06-30T22:32:45.761232Z",
"shell.execute_reply": "2026-06-30T22:32:45.760345Z"
}
},
"outputs": [],
"source": [
"project.structures.create(name='lbco')"
]
},
{
"cell_type": "markdown",
"id": "16",
"metadata": {},
"source": [
"### Show Defined Structures\n",
"\n",
"Show the names of the crystal structures added. These names are used\n",
"to access the structure using the syntax:\n",
"`project.structures[name]`. All structure parameters can be accessed\n",
"via the `project` object."
]
},
{
"cell_type": "code",
"execution_count": 8,
"id": "17",
"metadata": {
"execution": {
"iopub.execute_input": "2026-06-30T22:32:45.762877Z",
"iopub.status.busy": "2026-06-30T22:32:45.762705Z",
"iopub.status.idle": "2026-06-30T22:32:45.767581Z",
"shell.execute_reply": "2026-06-30T22:32:45.766935Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\u001b[1;36mDefined structures π§©\u001b[0m\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"\u001b[1m[\u001b[0m\u001b[32m'lbco'\u001b[0m\u001b[1m]\u001b[0m\n"
]
}
],
"source": [
"project.structures.show_names()"
]
},
{
"cell_type": "markdown",
"id": "18",
"metadata": {},
"source": [
"### Set Space Group\n",
"\n",
"Modify the default space group parameters."
]
},
{
"cell_type": "code",
"execution_count": 9,
"id": "19",
"metadata": {
"execution": {
"iopub.execute_input": "2026-06-30T22:32:45.769415Z",
"iopub.status.busy": "2026-06-30T22:32:45.769249Z",
"iopub.status.idle": "2026-06-30T22:32:45.772180Z",
"shell.execute_reply": "2026-06-30T22:32:45.771538Z"
}
},
"outputs": [],
"source": [
"project.structures['lbco'].space_group.name_h_m = 'P m -3 m'\n",
"project.structures['lbco'].space_group.coord_system_code = '1'"
]
},
{
"cell_type": "markdown",
"id": "20",
"metadata": {},
"source": [
"### Set Unit Cell\n",
"\n",
"Modify the default unit cell parameters."
]
},
{
"cell_type": "code",
"execution_count": 10,
"id": "21",
"metadata": {
"execution": {
"iopub.execute_input": "2026-06-30T22:32:45.773983Z",
"iopub.status.busy": "2026-06-30T22:32:45.773813Z",
"iopub.status.idle": "2026-06-30T22:32:45.776518Z",
"shell.execute_reply": "2026-06-30T22:32:45.775968Z"
}
},
"outputs": [],
"source": [
"project.structures['lbco'].cell.length_a = 3.88"
]
},
{
"cell_type": "markdown",
"id": "22",
"metadata": {},
"source": [
"### Set Atom Sites\n",
"\n",
"Add atom sites to the structure."
]
},
{
"cell_type": "code",
"execution_count": 11,
"id": "23",
"metadata": {
"execution": {
"iopub.execute_input": "2026-06-30T22:32:45.778369Z",
"iopub.status.busy": "2026-06-30T22:32:45.778199Z",
"iopub.status.idle": "2026-06-30T22:32:45.784638Z",
"shell.execute_reply": "2026-06-30T22:32:45.783804Z"
}
},
"outputs": [],
"source": [
"project.structures['lbco'].atom_sites.create(\n",
" id='La',\n",
" type_symbol='La',\n",
" fract_x=0,\n",
" fract_y=0,\n",
" fract_z=0,\n",
" adp_iso=0.5,\n",
" occupancy=0.5,\n",
")\n",
"project.structures['lbco'].atom_sites.create(\n",
" id='Ba',\n",
" type_symbol='Ba',\n",
" fract_x=0,\n",
" fract_y=0,\n",
" fract_z=0,\n",
" adp_iso=0.5,\n",
" occupancy=0.5,\n",
")\n",
"project.structures['lbco'].atom_sites.create(\n",
" id='Co',\n",
" type_symbol='Co',\n",
" fract_x=0.5,\n",
" fract_y=0.5,\n",
" fract_z=0.5,\n",
" adp_iso=0.5,\n",
")\n",
"project.structures['lbco'].atom_sites.create(\n",
" id='O',\n",
" type_symbol='O',\n",
" fract_x=0,\n",
" fract_y=0.5,\n",
" fract_z=0.5,\n",
" adp_iso=0.5,\n",
")"
]
},
{
"cell_type": "markdown",
"id": "24",
"metadata": {},
"source": [
"### Show Structure as Text"
]
},
{
"cell_type": "code",
"execution_count": 12,
"id": "25",
"metadata": {
"execution": {
"iopub.execute_input": "2026-06-30T22:32:45.786184Z",
"iopub.status.busy": "2026-06-30T22:32:45.786017Z",
"iopub.status.idle": "2026-06-30T22:32:46.240837Z",
"shell.execute_reply": "2026-06-30T22:32:46.239993Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\u001b[1;36mStructure π§© \u001b[0m\u001b[32m'lbco'\u001b[0m\u001b[1;36m as text\u001b[0m\n"
]
},
{
"data": {
"text/html": [
" | Edi |
|---|
| 1 | data_lbco |
|---|
| 2 | |
|---|
| 3 | _cell.length_a 3.88 |
|---|
| 4 | _cell.length_b 3.88 |
|---|
| 5 | _cell.length_c 3.88 |
|---|
| 6 | _cell.angle_alpha 90. |
|---|
| 7 | _cell.angle_beta 90. |
|---|
| 8 | _cell.angle_gamma 90. |
|---|
| 9 | |
|---|
| 10 | _space_group.name_h_m "P m -3 m" |
|---|
| 11 | _space_group.coord_system_code 1 |
|---|
| 12 | |
|---|
| 13 | _geom.min_bond_distance_cutoff 0. |
|---|
| 14 | _geom.bond_distance_inc 0.25 |
|---|
| 15 | |
|---|
| 16 | loop_ |
|---|
| 17 | _atom_site.id |
|---|
| 18 | _atom_site.type_symbol |
|---|
| 19 | _atom_site.fract_x |
|---|
| 20 | _atom_site.fract_y |
|---|
| 21 | _atom_site.fract_z |
|---|
| 22 | _atom_site.wyckoff_letter |
|---|
| 23 | _atom_site.multiplicity |
|---|
| 24 | _atom_site.occupancy |
|---|
| 25 | _atom_site.adp_iso |
|---|
| 26 | _atom_site.adp_type |
|---|
| 27 | La La 0. 0. 0. a 1 0.5 0.5 Biso |
|---|
| 28 | Ba Ba 0. 0. 0. a 1 0.5 0.5 Biso |
|---|
| 29 | Co Co 0.5 0.5 0.5 b 1 1. 0.5 Biso |
|---|
| 30 | O O 0. 0.5 0.5 c 3 1. 0.5 Biso |
|---|
"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"project.structures['lbco'].show_as_text()"
]
},
{
"cell_type": "markdown",
"id": "26",
"metadata": {},
"source": [
"### Display Structure\n",
"\n",
"EasyDiffraction can draw the structure that has just been defined. The\n",
"renderer engine is selected through `project.rendering_structure`. The default `auto`\n",
"engine resolves to an interactive `threejs` view inside Jupyter and a\n",
"compact `ascii` schematic in a terminal."
]
},
{
"cell_type": "code",
"execution_count": 13,
"id": "27",
"metadata": {
"execution": {
"iopub.execute_input": "2026-06-30T22:32:46.242497Z",
"iopub.status.busy": "2026-06-30T22:32:46.242328Z",
"iopub.status.idle": "2026-06-30T22:32:46.249994Z",
"shell.execute_reply": "2026-06-30T22:32:46.249186Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\u001b[1;36mRendering Structure types\u001b[0m\n"
]
},
{
"data": {
"text/html": [
" | | Type | Description |
|---|
| 1 | * | auto | Environment default structure-view engine |
|---|
| 2 | | ascii | Console ASCII schematic structure view |
|---|
| 3 | | threejs | Interactive Three.js 3D structure view |
|---|
"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"project.rendering_structure.show_supported()"
]
},
{
"cell_type": "markdown",
"id": "28",
"metadata": {},
"source": [
"Show all public attributes of the structure rendering engine."
]
},
{
"cell_type": "code",
"execution_count": 14,
"id": "29",
"metadata": {
"execution": {
"iopub.execute_input": "2026-06-30T22:32:46.251654Z",
"iopub.status.busy": "2026-06-30T22:32:46.251485Z",
"iopub.status.idle": "2026-06-30T22:32:46.261435Z",
"shell.execute_reply": "2026-06-30T22:32:46.260591Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\u001b[1;36mProperties\u001b[0m\n"
]
},
{
"data": {
"text/html": [
" | Name | Writable | Description |
|---|
| 1 | as_cif | | Return the CIF text for this rendering_structure category. |
|---|
| 2 | parameters | | All GenericDescriptorBase instances on this item. |
|---|
| 3 | type | β | Active factory tag for this category. |
|---|
| 4 | unique_name | | Fully qualified name: datablock, category, entry. |
|---|
| 5 | viewer | | Live structure-view facade bound to the active engine. |
|---|
"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"\u001b[1;36mMethods\u001b[0m\n"
]
},
{
"data": {
"text/html": [
" | Name | Description |
|---|
| 1 | from_cif() | Populate this category from a CIF block, rebinding engine. |
|---|
| 2 | help() | Print parameters, other properties, and methods. |
|---|
| 3 | show_supported() | Print supported types and mark the active one. |
|---|
"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"project.rendering_structure.help()"
]
},
{
"cell_type": "markdown",
"id": "30",
"metadata": {},
"source": [
"Visual styling β the atom view and colour scheme β is configured on\n",
"`project.structure_style`."
]
},
{
"cell_type": "code",
"execution_count": 15,
"id": "31",
"metadata": {
"execution": {
"iopub.execute_input": "2026-06-30T22:32:46.263007Z",
"iopub.status.busy": "2026-06-30T22:32:46.262838Z",
"iopub.status.idle": "2026-06-30T22:32:46.274057Z",
"shell.execute_reply": "2026-06-30T22:32:46.273425Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\u001b[1;36mAtom View types\u001b[0m\n"
]
},
{
"data": {
"text/html": [
" | | Value | Description |
|---|
| 1 | | vdw | Van der Waals radius balls |
|---|
| 2 | * | covalent | Covalent radius balls |
|---|
| 3 | | ionic | Ionic (Shannon) radius balls |
|---|
| 4 | | adp | ADP probability surfaces (spheres / ellipsoids) |
|---|
"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"\u001b[1;36mColor Scheme types\u001b[0m\n"
]
},
{
"data": {
"text/html": [
" | | Value | Description |
|---|
| 1 | * | jmol | Jmol / CPK colour scheme |
|---|
| 2 | | vesta | VESTA colour scheme |
|---|
"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"project.structure_style.atom_view.show_supported()\n",
"project.structure_style.color_scheme.show_supported()"
]
},
{
"cell_type": "code",
"execution_count": 16,
"id": "32",
"metadata": {
"execution": {
"iopub.execute_input": "2026-06-30T22:32:46.276080Z",
"iopub.status.busy": "2026-06-30T22:32:46.275916Z",
"iopub.status.idle": "2026-06-30T22:32:46.278857Z",
"shell.execute_reply": "2026-06-30T22:32:46.278071Z"
}
},
"outputs": [],
"source": [
"project.structure_style.atom_view = 'adp'\n",
"project.structure_style.color_scheme = 'jmol'"
]
},
{
"cell_type": "markdown",
"id": "33",
"metadata": {},
"source": [
"Bonds are generated automatically between atoms whose separation lies\n",
"within the per-structure cutoffs stored on `structure.geom`."
]
},
{
"cell_type": "code",
"execution_count": 17,
"id": "34",
"metadata": {
"execution": {
"iopub.execute_input": "2026-06-30T22:32:46.280257Z",
"iopub.status.busy": "2026-06-30T22:32:46.280108Z",
"iopub.status.idle": "2026-06-30T22:32:46.283203Z",
"shell.execute_reply": "2026-06-30T22:32:46.282395Z"
}
},
"outputs": [],
"source": [
"project.structures['lbco'].geom.min_bond_distance_cutoff = 0.5\n",
"project.structures['lbco'].geom.bond_distance_inc = 0.25"
]
},
{
"cell_type": "markdown",
"id": "35",
"metadata": {},
"source": [
"List which features the structure data and the active engine can draw."
]
},
{
"cell_type": "code",
"execution_count": 18,
"id": "36",
"metadata": {
"execution": {
"iopub.execute_input": "2026-06-30T22:32:46.284964Z",
"iopub.status.busy": "2026-06-30T22:32:46.284825Z",
"iopub.status.idle": "2026-06-30T22:32:46.298300Z",
"shell.execute_reply": "2026-06-30T22:32:46.297154Z"
}
},
"outputs": [
{
"data": {
"text/html": [
" | Option | Description | Available | Auto |
|---|
| 1 | atoms | Atoms as spheres, occupancy wedges, or ADP ellipsoids. | yes | yes |
|---|
| 2 | bonds | Bonds between atoms within the per-structure cutoffs. | yes | yes |
|---|
| 3 | cell | Unit-cell edges. | yes | yes |
|---|
| 4 | axes | The a/b/c axis triad. | yes | yes |
|---|
| 5 | moments | Magnetic-moment arrows (no moment data in version 1). | no | no |
|---|
| 6 | labels | Atom labels at each site. | yes | no |
|---|
"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"project.display.show_structure_options(struct_name='lbco')"
]
},
{
"cell_type": "markdown",
"id": "37",
"metadata": {},
"source": [
"Draw the structure. With `include='auto'` (the default) every available\n",
"feature is shown; a specific tuple such as `('atoms', 'bonds', 'cell')`\n",
"can be requested instead."
]
},
{
"cell_type": "code",
"execution_count": 19,
"id": "38",
"metadata": {
"execution": {
"iopub.execute_input": "2026-06-30T22:32:46.300001Z",
"iopub.status.busy": "2026-06-30T22:32:46.299763Z",
"iopub.status.idle": "2026-06-30T22:32:46.336290Z",
"shell.execute_reply": "2026-06-30T22:32:46.335505Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\u001b[1;36mStructure π§© \u001b[0m\u001b[32m'lbco'\u001b[0m\u001b[1;36m \u001b[0m\u001b[1;36m(\u001b[0m\u001b[1;36mAtom view type: \u001b[0m\u001b[32m'adp'\u001b[0m\u001b[1;36m)\u001b[0m\n"
]
},
{
"data": {
"text/html": [
"\n",
"
\n",
"
Loading plotβ¦
\n",
"
\n",
"
\n",
"
\n",
"
drag = rotate
wheel = zoom
right-drag = pan
\n",
"
\n",
"
\n",
"\n",
"\n",
"\n",
""
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"project.display.structure(struct_name='lbco')"
]
},
{
"cell_type": "markdown",
"id": "39",
"metadata": {},
"source": [
"For a quick text schematic, switch to the `ascii` engine explicitly,\n",
"then restore the automatic default."
]
},
{
"cell_type": "code",
"execution_count": 20,
"id": "40",
"metadata": {
"execution": {
"iopub.execute_input": "2026-06-30T22:32:46.337856Z",
"iopub.status.busy": "2026-06-30T22:32:46.337698Z",
"iopub.status.idle": "2026-06-30T22:32:46.342661Z",
"shell.execute_reply": "2026-06-30T22:32:46.341966Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\u001b[1;36mCurrent engine changed to\u001b[0m\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"\u001b[32m'ascii'\u001b[0m\n"
]
}
],
"source": [
"project.rendering_structure.type = 'ascii'"
]
},
{
"cell_type": "code",
"execution_count": 21,
"id": "41",
"metadata": {
"execution": {
"iopub.execute_input": "2026-06-30T22:32:46.344471Z",
"iopub.status.busy": "2026-06-30T22:32:46.344327Z",
"iopub.status.idle": "2026-06-30T22:32:46.364535Z",
"shell.execute_reply": "2026-06-30T22:32:46.363698Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\u001b[1;36mStructure π§© \u001b[0m\u001b[32m'lbco'\u001b[0m\u001b[1;36m \u001b[0m\u001b[1;36m(\u001b[0m\u001b[1;36mAtom view type: \u001b[0m\u001b[32m'adp'\u001b[0m\u001b[1;36m)\u001b[0m\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"\n",
" b\n",
" β\n",
"\n",
" \u001b[38;5;117mβ\u001b[0m\u001b[38;5;145mβ\u001b[0m\u001b[38;5;145mβ\u001b[0m\u001b[38;5;145mβ\u001b[0m\u001b[38;5;145mβ\u001b[0m\u001b[38;5;145mβ\u001b[0m\u001b[38;5;145mβ\u001b[0m\u001b[38;5;145mβ\u001b[0m\u001b[38;5;145mβ\u001b[0m\u001b[38;5;145mβ\u001b[0m\u001b[38;5;145mβ\u001b[0m\u001b[38;5;145mβ\u001b[0m\u001b[38;5;145mβ\u001b[0m\u001b[38;5;145mβ\u001b[0m\u001b[38;5;145mβ\u001b[0m\u001b[38;5;145mβ\u001b[0m\u001b[38;5;145mβ\u001b[0m\u001b[38;5;145mβ\u001b[0m\u001b[38;5;145mβ\u001b[0m\u001b[38;5;145mβ\u001b[0m\u001b[38;5;145mβ\u001b[0m\u001b[38;5;145mβ\u001b[0m\u001b[38;5;145mβ\u001b[0m\u001b[38;5;145mβ\u001b[0m\u001b[38;5;145mβ\u001b[0m\u001b[38;5;196mβ\u001b[0m\u001b[38;5;145mβ\u001b[0m\u001b[38;5;145mβ\u001b[0m\u001b[38;5;145mβ\u001b[0m\u001b[38;5;145mβ\u001b[0m\u001b[38;5;145mβ\u001b[0m\u001b[38;5;145mβ\u001b[0m\u001b[38;5;145mβ\u001b[0m\u001b[38;5;145mβ\u001b[0m\u001b[38;5;145mβ\u001b[0m\u001b[38;5;145mβ\u001b[0m\u001b[38;5;145mβ\u001b[0m\u001b[38;5;145mβ\u001b[0m\u001b[38;5;145mβ\u001b[0m\u001b[38;5;145mβ\u001b[0m\u001b[38;5;145mβ\u001b[0m\u001b[38;5;145mβ\u001b[0m\u001b[38;5;145mβ\u001b[0m\u001b[38;5;145mβ\u001b[0m\u001b[38;5;145mβ\u001b[0m\u001b[38;5;145mβ\u001b[0m\u001b[38;5;145mβ\u001b[0m\u001b[38;5;145mβ\u001b[0m\u001b[38;5;145mβ\u001b[0m\u001b[38;5;145mβ\u001b[0m\u001b[38;5;117mβ\u001b[0m\n",
" \u001b[38;5;145mβ\u001b[0m \u001b[38;5;145mβ\u001b[0m\n",
" \u001b[38;5;145mβ\u001b[0m \u001b[38;5;145mβ\u001b[0m\n",
" \u001b[38;5;145mβ\u001b[0m \u001b[38;5;145mβ\u001b[0m\n",
" \u001b[38;5;145mβ\u001b[0m \u001b[38;5;145mβ\u001b[0m\n",
" \u001b[38;5;145mβ\u001b[0m \u001b[38;5;145mβ\u001b[0m\n",
" \u001b[38;5;145mβ\u001b[0m \u001b[38;5;145mβ\u001b[0m\n",
" \u001b[38;5;145mβ\u001b[0m \u001b[38;5;145mβ\u001b[0m\n",
" \u001b[38;5;145mβ\u001b[0m \u001b[38;5;145mβ\u001b[0m\n",
" \u001b[38;5;145mβ\u001b[0m \u001b[38;5;145mβ\u001b[0m\n",
" \u001b[38;5;196mβ\u001b[0m \u001b[38;5;196mβ\u001b[0m \u001b[38;5;196mβ\u001b[0m\n",
" \u001b[38;5;145mβ\u001b[0m \u001b[38;5;145mβ\u001b[0m\n",
" \u001b[38;5;145mβ\u001b[0m \u001b[38;5;145mβ\u001b[0m\n",
" \u001b[38;5;145mβ\u001b[0m \u001b[38;5;145mβ\u001b[0m\n",
" \u001b[38;5;145mβ\u001b[0m \u001b[38;5;145mβ\u001b[0m\n",
" \u001b[38;5;145mβ\u001b[0m \u001b[38;5;145mβ\u001b[0m\n",
" \u001b[38;5;145mβ\u001b[0m \u001b[38;5;145mβ\u001b[0m\n",
" \u001b[38;5;145mβ\u001b[0m \u001b[38;5;145mβ\u001b[0m\n",
" \u001b[38;5;145mβ\u001b[0m \u001b[38;5;145mβ\u001b[0m\n",
" \u001b[38;5;145mβ\u001b[0m \u001b[38;5;145mβ\u001b[0m\n",
" \u001b[38;5;145mβ\u001b[0m \u001b[38;5;145mβ\u001b[0m\n",
" \u001b[38;5;117mβ\u001b[0m\u001b[38;5;145mβ\u001b[0m\u001b[38;5;145mβ\u001b[0m\u001b[38;5;145mβ\u001b[0m\u001b[38;5;145mβ\u001b[0m\u001b[38;5;145mβ\u001b[0m\u001b[38;5;145mβ\u001b[0m\u001b[38;5;145mβ\u001b[0m\u001b[38;5;145mβ\u001b[0m\u001b[38;5;145mβ\u001b[0m\u001b[38;5;145mβ\u001b[0m\u001b[38;5;145mβ\u001b[0m\u001b[38;5;145mβ\u001b[0m\u001b[38;5;145mβ\u001b[0m\u001b[38;5;145mβ\u001b[0m\u001b[38;5;145mβ\u001b[0m\u001b[38;5;145mβ\u001b[0m\u001b[38;5;145mβ\u001b[0m\u001b[38;5;145mβ\u001b[0m\u001b[38;5;145mβ\u001b[0m\u001b[38;5;145mβ\u001b[0m\u001b[38;5;145mβ\u001b[0m\u001b[38;5;145mβ\u001b[0m\u001b[38;5;145mβ\u001b[0m\u001b[38;5;145mβ\u001b[0m\u001b[38;5;196mβ\u001b[0m\u001b[38;5;145mβ\u001b[0m\u001b[38;5;145mβ\u001b[0m\u001b[38;5;145mβ\u001b[0m\u001b[38;5;145mβ\u001b[0m\u001b[38;5;145mβ\u001b[0m\u001b[38;5;145mβ\u001b[0m\u001b[38;5;145mβ\u001b[0m\u001b[38;5;145mβ\u001b[0m\u001b[38;5;145mβ\u001b[0m\u001b[38;5;145mβ\u001b[0m\u001b[38;5;145mβ\u001b[0m\u001b[38;5;145mβ\u001b[0m\u001b[38;5;145mβ\u001b[0m\u001b[38;5;145mβ\u001b[0m\u001b[38;5;145mβ\u001b[0m\u001b[38;5;145mβ\u001b[0m\u001b[38;5;145mβ\u001b[0m\u001b[38;5;145mβ\u001b[0m\u001b[38;5;145mβ\u001b[0m\u001b[38;5;145mβ\u001b[0m\u001b[38;5;145mβ\u001b[0m\u001b[38;5;145mβ\u001b[0m\u001b[38;5;145mβ\u001b[0m\u001b[38;5;145mβ\u001b[0m\u001b[38;5;117mβ\u001b[0m β a\n",
"\n",
"\n",
"\n",
"Legend: \u001b[38;5;217mβ Co\u001b[0m \u001b[38;5;196mβ O\u001b[0m \u001b[38;5;117mβ La/Ba\u001b[0m\n"
]
}
],
"source": [
"project.display.structure(struct_name='lbco')"
]
},
{
"cell_type": "code",
"execution_count": 22,
"id": "42",
"metadata": {
"execution": {
"iopub.execute_input": "2026-06-30T22:32:46.366441Z",
"iopub.status.busy": "2026-06-30T22:32:46.366288Z",
"iopub.status.idle": "2026-06-30T22:32:46.371744Z",
"shell.execute_reply": "2026-06-30T22:32:46.370936Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\u001b[1;36mCurrent engine changed to\u001b[0m\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"\u001b[32m'threejs'\u001b[0m\n"
]
}
],
"source": [
"project.rendering_structure.type = 'auto'"
]
},
{
"cell_type": "markdown",
"id": "43",
"metadata": {},
"source": [
"### Save Project State\n",
"\n",
"Save the project state after adding the structure. This ensures\n",
"that all changes are stored and can be accessed later. The project\n",
"state is saved in the directory specified during project creation."
]
},
{
"cell_type": "code",
"execution_count": 23,
"id": "44",
"metadata": {
"execution": {
"iopub.execute_input": "2026-06-30T22:32:46.373186Z",
"iopub.status.busy": "2026-06-30T22:32:46.373017Z",
"iopub.status.idle": "2026-06-30T22:32:46.434699Z",
"shell.execute_reply": "2026-06-30T22:32:46.433871Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\u001b[1;36mSaving project π¦ \u001b[0m\u001b[32m'lbco_hrpt'\u001b[0m\u001b[1;36m to \u001b[0m\u001b[32m'../../../projects/refine-lbco-hrpt-report'\u001b[0m\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"βββ π project.edi\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"βββ π structures/\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"β βββ π lbco.edi\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"βββ π experiments/\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"βββ π analysis/\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"β βββ π analysis.edi\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"βββ π reports/\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
" βββ π lbco_hrpt.html\n"
]
}
],
"source": [
"project.save()"
]
},
{
"cell_type": "markdown",
"id": "45",
"metadata": {},
"source": [
"## π¬ Define Experiment\n",
"\n",
"This section shows how to add experiments, configure their parameters,\n",
"and link the structures defined in the previous step."
]
},
{
"cell_type": "markdown",
"id": "46",
"metadata": {},
"source": [
"### Download Data\n",
"\n",
"Download the data file from the EasyDiffraction repository on GitHub."
]
},
{
"cell_type": "code",
"execution_count": 24,
"id": "47",
"metadata": {
"execution": {
"iopub.execute_input": "2026-06-30T22:32:46.436583Z",
"iopub.status.busy": "2026-06-30T22:32:46.436230Z",
"iopub.status.idle": "2026-06-30T22:32:46.442770Z",
"shell.execute_reply": "2026-06-30T22:32:46.441869Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\u001b[1;36mGetting data\u001b[0m\u001b[1;36m...\u001b[0m\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"Data \u001b[32m'meas-lbco-hrpt'\u001b[0m: La0.5Ba0.5CoO3, HRPT \u001b[1m(\u001b[0mPSI\u001b[1m)\u001b[0m, \u001b[1;36m300\u001b[0m K\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"β
Data \u001b[32m'meas-lbco-hrpt'\u001b[0m already present at \u001b[32m'../../../data/meas-lbco-hrpt.xye'\u001b[0m. Keeping existing.\n"
]
}
],
"source": [
"data_path = edi.download_data('meas-lbco-hrpt', destination='data')"
]
},
{
"cell_type": "markdown",
"id": "48",
"metadata": {},
"source": [
"### Create Experiment"
]
},
{
"cell_type": "code",
"execution_count": 25,
"id": "49",
"metadata": {
"execution": {
"iopub.execute_input": "2026-06-30T22:32:46.444255Z",
"iopub.status.busy": "2026-06-30T22:32:46.444084Z",
"iopub.status.idle": "2026-06-30T22:32:46.942002Z",
"shell.execute_reply": "2026-06-30T22:32:46.941182Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\u001b[1;36mData loaded successfully\u001b[0m\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"Experiment π¬ \u001b[32m'hrpt'\u001b[0m. Number of data points: \u001b[1;36m3098\u001b[0m.\n"
]
}
],
"source": [
"project.experiments.add_from_data_path(\n",
" name='hrpt',\n",
" data_path=data_path,\n",
" sample_form='powder',\n",
" beam_mode='constant wavelength',\n",
" radiation_probe='neutron',\n",
")"
]
},
{
"cell_type": "markdown",
"id": "50",
"metadata": {},
"source": [
"### Show Defined Experiments"
]
},
{
"cell_type": "code",
"execution_count": 26,
"id": "51",
"metadata": {
"execution": {
"iopub.execute_input": "2026-06-30T22:32:46.943539Z",
"iopub.status.busy": "2026-06-30T22:32:46.943373Z",
"iopub.status.idle": "2026-06-30T22:32:46.948669Z",
"shell.execute_reply": "2026-06-30T22:32:46.947731Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\u001b[1;36mDefined experiments π¬\u001b[0m\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"\u001b[1m[\u001b[0m\u001b[32m'hrpt'\u001b[0m\u001b[1m]\u001b[0m\n"
]
}
],
"source": [
"project.experiments.show_names()"
]
},
{
"cell_type": "markdown",
"id": "52",
"metadata": {},
"source": [
"### Show Measured Data"
]
},
{
"cell_type": "code",
"execution_count": 27,
"id": "53",
"metadata": {
"execution": {
"iopub.execute_input": "2026-06-30T22:32:46.950332Z",
"iopub.status.busy": "2026-06-30T22:32:46.950083Z",
"iopub.status.idle": "2026-06-30T22:32:47.008931Z",
"shell.execute_reply": "2026-06-30T22:32:47.008039Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"β οΈ No linked structures defined. Returning empty pattern. \n"
]
},
{
"data": {
"text/html": [
""
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"project.display.pattern(expt_name='hrpt')"
]
},
{
"cell_type": "markdown",
"id": "54",
"metadata": {},
"source": [
"### Set Instrument\n",
"\n",
"Modify the default instrument parameters."
]
},
{
"cell_type": "code",
"execution_count": 28,
"id": "55",
"metadata": {
"execution": {
"iopub.execute_input": "2026-06-30T22:32:47.010640Z",
"iopub.status.busy": "2026-06-30T22:32:47.010478Z",
"iopub.status.idle": "2026-06-30T22:32:47.014045Z",
"shell.execute_reply": "2026-06-30T22:32:47.013027Z"
}
},
"outputs": [],
"source": [
"project.experiments['hrpt'].instrument.setup_wavelength = 1.494\n",
"project.experiments['hrpt'].instrument.calib_twotheta_offset = 0.6"
]
},
{
"cell_type": "markdown",
"id": "56",
"metadata": {},
"source": [
"### Set Peak Profile\n",
"\n",
"Show supported peak profile types."
]
},
{
"cell_type": "code",
"execution_count": 29,
"id": "57",
"metadata": {
"execution": {
"iopub.execute_input": "2026-06-30T22:32:47.015564Z",
"iopub.status.busy": "2026-06-30T22:32:47.015398Z",
"iopub.status.idle": "2026-06-30T22:32:47.022932Z",
"shell.execute_reply": "2026-06-30T22:32:47.022102Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\u001b[1;36mPeak types\u001b[0m\n"
]
},
{
"data": {
"text/html": [
" | | Type | Description |
|---|
| 1 | * | pseudo-voigt | CWL pseudo-Voigt profile |
|---|
| 2 | | pseudo-voigt + berar-baldinozzi asymmetry | CWL pseudo-Voigt profile with Berar-Baldinozzi asymmetry correction. |
|---|
"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"project.experiments['hrpt'].peak.show_supported()"
]
},
{
"cell_type": "markdown",
"id": "58",
"metadata": {},
"source": [
"Select the desired peak profile type."
]
},
{
"cell_type": "code",
"execution_count": 30,
"id": "59",
"metadata": {
"execution": {
"iopub.execute_input": "2026-06-30T22:32:47.024824Z",
"iopub.status.busy": "2026-06-30T22:32:47.024664Z",
"iopub.status.idle": "2026-06-30T22:32:47.030345Z",
"shell.execute_reply": "2026-06-30T22:32:47.029350Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\u001b[1;36mPeak profile type for experiment \u001b[0m\u001b[32m'hrpt'\u001b[0m\u001b[1;36m changed to\u001b[0m\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"pseudo-voigt\n"
]
}
],
"source": [
"project.experiments['hrpt'].peak.type = 'pseudo-voigt'"
]
},
{
"cell_type": "markdown",
"id": "60",
"metadata": {},
"source": [
"Modify default peak profile parameters."
]
},
{
"cell_type": "code",
"execution_count": 31,
"id": "61",
"metadata": {
"execution": {
"iopub.execute_input": "2026-06-30T22:32:47.031811Z",
"iopub.status.busy": "2026-06-30T22:32:47.031662Z",
"iopub.status.idle": "2026-06-30T22:32:47.035443Z",
"shell.execute_reply": "2026-06-30T22:32:47.034540Z"
}
},
"outputs": [],
"source": [
"project.experiments['hrpt'].peak.broad_gauss_u = 0.1\n",
"project.experiments['hrpt'].peak.broad_gauss_v = -0.1\n",
"project.experiments['hrpt'].peak.broad_gauss_w = 0.1\n",
"project.experiments['hrpt'].peak.broad_lorentz_x = 0\n",
"project.experiments['hrpt'].peak.broad_lorentz_y = 0.1"
]
},
{
"cell_type": "markdown",
"id": "62",
"metadata": {},
"source": [
"### Set Background"
]
},
{
"cell_type": "markdown",
"id": "63",
"metadata": {},
"source": [
"Show supported background types."
]
},
{
"cell_type": "code",
"execution_count": 32,
"id": "64",
"metadata": {
"execution": {
"iopub.execute_input": "2026-06-30T22:32:47.036872Z",
"iopub.status.busy": "2026-06-30T22:32:47.036724Z",
"iopub.status.idle": "2026-06-30T22:32:47.043414Z",
"shell.execute_reply": "2026-06-30T22:32:47.042706Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\u001b[1;36mBackground types\u001b[0m\n"
]
},
{
"data": {
"text/html": [
" | | Type | Description |
|---|
| 1 | | chebyshev | Chebyshev polynomial background |
|---|
| 2 | * | line-segment | Linear interpolation between points |
|---|
"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"project.experiments['hrpt'].background.show_supported()"
]
},
{
"cell_type": "markdown",
"id": "65",
"metadata": {},
"source": [
"Select the desired background type."
]
},
{
"cell_type": "code",
"execution_count": 33,
"id": "66",
"metadata": {
"execution": {
"iopub.execute_input": "2026-06-30T22:32:47.045562Z",
"iopub.status.busy": "2026-06-30T22:32:47.045403Z",
"iopub.status.idle": "2026-06-30T22:32:47.049866Z",
"shell.execute_reply": "2026-06-30T22:32:47.049152Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\u001b[1;36mBackground type for experiment \u001b[0m\u001b[32m'hrpt'\u001b[0m\u001b[1;36m already set to\u001b[0m\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"line-segment\n"
]
}
],
"source": [
"project.experiments['hrpt'].background.type = 'line-segment'"
]
},
{
"cell_type": "markdown",
"id": "67",
"metadata": {},
"source": [
"Add background points."
]
},
{
"cell_type": "code",
"execution_count": 34,
"id": "68",
"metadata": {
"execution": {
"iopub.execute_input": "2026-06-30T22:32:47.051302Z",
"iopub.status.busy": "2026-06-30T22:32:47.051145Z",
"iopub.status.idle": "2026-06-30T22:32:47.056616Z",
"shell.execute_reply": "2026-06-30T22:32:47.055719Z"
}
},
"outputs": [],
"source": [
"project.experiments['hrpt'].background.create(id='10', position=10, intensity=170)\n",
"project.experiments['hrpt'].background.create(id='30', position=30, intensity=170)\n",
"project.experiments['hrpt'].background.create(id='50', position=50, intensity=170)\n",
"project.experiments['hrpt'].background.create(id='110', position=110, intensity=170)\n",
"project.experiments['hrpt'].background.create(id='165', position=165, intensity=170)"
]
},
{
"cell_type": "markdown",
"id": "69",
"metadata": {},
"source": [
"Show current background points."
]
},
{
"cell_type": "code",
"execution_count": 35,
"id": "70",
"metadata": {
"execution": {
"iopub.execute_input": "2026-06-30T22:32:47.058254Z",
"iopub.status.busy": "2026-06-30T22:32:47.058070Z",
"iopub.status.idle": "2026-06-30T22:32:47.065616Z",
"shell.execute_reply": "2026-06-30T22:32:47.064688Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\u001b[1;36mLine-segment background points\u001b[0m\n"
]
},
{
"data": {
"text/html": [
" | Position | Intensity |
|---|
| 1 | 10 | 170 |
|---|
| 2 | 30 | 170 |
|---|
| 3 | 50 | 170 |
|---|
| 4 | 110 | 170 |
|---|
| 5 | 165 | 170 |
|---|
"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"project.experiments['hrpt'].background.show()"
]
},
{
"cell_type": "markdown",
"id": "71",
"metadata": {},
"source": [
"### Set Linked Structures\n",
"\n",
"Link the structure defined in the previous step to the experiment."
]
},
{
"cell_type": "code",
"execution_count": 36,
"id": "72",
"metadata": {
"execution": {
"iopub.execute_input": "2026-06-30T22:32:47.067251Z",
"iopub.status.busy": "2026-06-30T22:32:47.067014Z",
"iopub.status.idle": "2026-06-30T22:32:47.070858Z",
"shell.execute_reply": "2026-06-30T22:32:47.070060Z"
}
},
"outputs": [],
"source": [
"project.experiments['hrpt'].linked_structures.create(structure_id='lbco', scale=10.0)"
]
},
{
"cell_type": "markdown",
"id": "73",
"metadata": {},
"source": [
"### Show Experiment as Text"
]
},
{
"cell_type": "code",
"execution_count": 37,
"id": "74",
"metadata": {
"execution": {
"iopub.execute_input": "2026-06-30T22:32:47.072371Z",
"iopub.status.busy": "2026-06-30T22:32:47.072208Z",
"iopub.status.idle": "2026-06-30T22:32:47.362515Z",
"shell.execute_reply": "2026-06-30T22:32:47.361573Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\u001b[1;36mExperiment π¬ \u001b[0m\u001b[32m'hrpt'\u001b[0m\u001b[1;36m as text\u001b[0m\n"
]
},
{
"data": {
"text/html": [
" | Edi |
|---|
| 1 | data_hrpt |
|---|
| 2 | |
|---|
| 3 | _experiment_type.sample_form powder |
|---|
| 4 | _experiment_type.beam_mode "constant wavelength" |
|---|
| 5 | _experiment_type.radiation_probe neutron |
|---|
| 6 | _experiment_type.scattering_type bragg |
|---|
| 7 | |
|---|
| 8 | _diffrn.ambient_temperature ? |
|---|
| 9 | _diffrn.ambient_pressure ? |
|---|
| 10 | _diffrn.ambient_magnetic_field ? |
|---|
| 11 | _diffrn.ambient_electric_field ? |
|---|
| 12 | |
|---|
| 13 | _calculator.type cryspy |
|---|
| 14 | |
|---|
| 15 | _peak.broad_gauss_u 0.1 |
|---|
| 16 | _peak.broad_gauss_v -0.1 |
|---|
| 17 | _peak.broad_gauss_w 0.1 |
|---|
| 18 | _peak.broad_lorentz_x 0. |
|---|
| 19 | _peak.broad_lorentz_y 0.1 |
|---|
| 20 | _peak.cutoff_fwhm 0. |
|---|
| 21 | _peak.type cwl-pseudo-voigt |
|---|
| 22 | |
|---|
| 23 | _instrument.setup_wavelength 1.494 |
|---|
| 24 | _instrument.setup_wavelength_2 0. |
|---|
| 25 | _instrument.setup_wavelength_2_to_1_ratio 0. |
|---|
| 26 | _instrument.calib_twotheta_offset 0.6 |
|---|
| 27 | _instrument.calib_sample_displacement 0. |
|---|
| 28 | _instrument.calib_sample_transparency 0. |
|---|
| 29 | |
|---|
| 30 | _absorption.type none |
|---|
| 31 | |
|---|
| 32 | loop_ |
|---|
| 33 | _linked_structure.structure_id |
|---|
| 34 | _linked_structure.scale |
|---|
| 35 | lbco 10. |
|---|
| 36 | |
|---|
| 37 | _background.type line-segment |
|---|
| 38 | |
|---|
| 39 | loop_ |
|---|
| 40 | _background.id |
|---|
| 41 | _background.position |
|---|
| 42 | _background.intensity |
|---|
| 43 | 10 10 170 |
|---|
| 44 | 30 30 170 |
|---|
| 45 | 50 50 170 |
|---|
| 46 | 110 110 170 |
|---|
| 47 | 165 165 170 |
|---|
| 48 | |
|---|
| 49 | loop_ |
|---|
| 50 | _data.two_theta |
|---|
| 51 | _data.id |
|---|
| 52 | _data.d_spacing |
|---|
| 53 | _data.intensity_meas |
|---|
| 54 | _data.intensity_meas_su |
|---|
| 55 | _data.intensity_calc |
|---|
| 56 | _data.intensity_bkg |
|---|
| 57 | _data.calc_status |
|---|
| 58 | 10. 1 8.57086379 167. 12.6 172.32780248 170. incl |
|---|
| 59 | 10.05 2 8.52833125 157. 12.5 172.30859914 170. incl |
|---|
| 60 | 10.1 3 8.48622036 187. 13.3 172.28969336 170. incl |
|---|
| 61 | 10.15 4 8.4445249 197. 14. 172.27107915 170. incl |
|---|
| 62 | 10.2 5 8.40323875 164. 12.5 172.25275064 170. incl |
|---|
| 63 | 10.25 6 8.36235592 171. 13. 172.23470212 170. incl |
|---|
| 64 | 10.3 7 8.32187055 190. 13.4 172.21692803 170. incl |
|---|
| 65 | 10.35 8 8.28177687 182. 13.5 172.19942295 170. incl |
|---|
| 66 | 10.4 9 8.24206922 166. 12.6 172.18218159 170. incl |
|---|
| 67 | 10.45 10 8.20274208 203. 14.3 172.1651988 170. incl |
|---|
| 68 | ... |
|---|
| 69 | 164.4 3089 0.75397591 202. 18.5 172.60037118 170. incl |
|---|
| 70 | 164.45 3090 0.75393091 178. 20.4 172.59695823 170. incl |
|---|
| 71 | 164.5 3091 0.75388607 153. 18. 172.59381336 170. incl |
|---|
| 72 | 164.55 3092 0.75384138 197. 25.3 172.59093099 170. incl |
|---|
| 73 | 164.6 3093 0.75379684 153. 20.7 172.58830579 170. incl |
|---|
| 74 | 164.65 3094 0.75375244 173. 30.1 172.58593268 170. incl |
|---|
| 75 | 164.7 3095 0.75370819 187. 27.9 172.5838068 170. incl |
|---|
| 76 | 164.75 3096 0.7536641 175. 38.2 172.58192354 170. incl |
|---|
| 77 | 164.8 3097 0.75362015 168. 30.9 172.58027848 170. incl |
|---|
| 78 | 164.85 3098 0.75357634 109. 41.2 172.57886743 170. incl |
|---|
| 79 | |
|---|
| 80 | loop_ |
|---|
| 81 | _refln.id |
|---|
| 82 | _refln.structure_id |
|---|
| 83 | _refln.d_spacing |
|---|
| 84 | _refln.sin_theta_over_lambda |
|---|
| 85 | _refln.index_h |
|---|
| 86 | _refln.index_k |
|---|
| 87 | _refln.index_l |
|---|
| 88 | _refln.f_calc |
|---|
| 89 | _refln.f_squared_calc |
|---|
| 90 | _refln.two_theta |
|---|
| 91 | 1 lbco 3.88 0.12886598 1 0 0 0.16244556 0.02638856 22.80044453 |
|---|
| 92 | 2 lbco 2.74357431 0.18224402 1 1 0 0.32869596 0.10804103 32.19908449 |
|---|
| 93 | 3 lbco 2.24011904 0.22320242 1 1 1 2.1043237 4.42817823 39.5583744 |
|---|
| 94 | 4 lbco 1.94 0.25773196 2 0 0 2.56865501 6.59798858 45.89388073 |
|---|
| 95 | 5 lbco 1.73518875 0.28815309 2 1 0 0.15713889 0.02469263 51.5986821 |
|---|
| 96 | 6 lbco 1.58400337 0.31565589 2 1 1 0.31795832 0.10109749 56.8751008 |
|---|
| 97 | 7 lbco 1.37178716 0.36448803 2 2 0 2.48474376 6.17395156 66.58716829 |
|---|
| 98 | 8 lbco 1.29333333 0.38659794 2 2 1 0.15200557 0.02310569 71.16064798 |
|---|
| 99 | 9 lbco 1.29333333 0.38659794 3 0 0 0.15200557 0.02310569 71.16064798 |
|---|
| 100 | 10 lbco 1.22696373 0.40751001 3 1 0 0.30757145 0.0946002 75.60845321 |
|---|
| 101 | ... |
|---|
| 102 | 19 lbco 0.91452477 0.54673205 4 1 1 0.28780456 0.08283147 110.13497669 |
|---|
| 103 | 20 lbco 0.89013305 0.56171378 3 3 1 1.84253549 3.39493703 114.71155759 |
|---|
| 104 | 21 lbco 0.86759438 0.57630618 4 2 0 2.24910171 5.0584585 119.45842061 |
|---|
| 105 | 22 lbco 0.84668541 0.59053811 4 2 1 0.13759004 0.01893102 124.43335485 |
|---|
| 106 | 23 lbco 0.82721878 0.60443502 3 3 2 0.27840274 0.07750809 129.7174128 |
|---|
| 107 | 24 lbco 0.79200168 0.63131179 4 2 2 2.17562943 4.73336341 141.78522183 |
|---|
| 108 | 25 lbco 0.776 0.6443299 4 3 0 0.13309533 0.01771437 149.17338292 |
|---|
| 109 | 26 lbco 0.776 0.6443299 5 0 0 0.13309533 0.01771437 149.17338292 |
|---|
| 110 | 27 lbco 0.7609306 0.65709014 4 3 1 0.26930805 0.07252683 158.63936579 |
|---|
| 111 | 28 lbco 0.7609306 0.65709014 5 1 0 0.26930805 0.07252683 158.63936579 |
|---|
"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"project.experiments['hrpt'].show_as_text()"
]
},
{
"cell_type": "markdown",
"id": "75",
"metadata": {},
"source": [
"### Save Project State"
]
},
{
"cell_type": "code",
"execution_count": 38,
"id": "76",
"metadata": {
"execution": {
"iopub.execute_input": "2026-06-30T22:32:47.364044Z",
"iopub.status.busy": "2026-06-30T22:32:47.363870Z",
"iopub.status.idle": "2026-06-30T22:32:47.698295Z",
"shell.execute_reply": "2026-06-30T22:32:47.697401Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\u001b[1;36mSaving project π¦ \u001b[0m\u001b[32m'lbco_hrpt'\u001b[0m\u001b[1;36m to \u001b[0m\u001b[32m'../../../projects/refine-lbco-hrpt-report'\u001b[0m\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"βββ π project.edi\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"βββ π structures/\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"β βββ π lbco.edi\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"βββ π experiments/\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"β βββ π hrpt.edi\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"βββ π analysis/\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"β βββ π analysis.edi\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"βββ π reports/\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
" βββ π lbco_hrpt.html\n"
]
}
],
"source": [
"project.save()"
]
},
{
"cell_type": "markdown",
"id": "77",
"metadata": {},
"source": [
"## π Perform Analysis\n",
"\n",
"This section explains the analysis process, including how to set up\n",
"calculation and fitting engines.\n",
"\n",
"### Set Calculator\n",
"\n",
"Show supported calculation engines for this experiment."
]
},
{
"cell_type": "code",
"execution_count": 39,
"id": "78",
"metadata": {
"execution": {
"iopub.execute_input": "2026-06-30T22:32:47.699992Z",
"iopub.status.busy": "2026-06-30T22:32:47.699812Z",
"iopub.status.idle": "2026-06-30T22:32:47.707189Z",
"shell.execute_reply": "2026-06-30T22:32:47.706343Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\u001b[1;36mCalculator types\u001b[0m\n"
]
},
{
"data": {
"text/html": [
" | | Type | Description |
|---|
| 1 | | crysfml | CrysFML library for crystallographic calculations |
|---|
| 2 | * | cryspy | CrysPy library for crystallographic calculations |
|---|
"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"project.experiments['hrpt'].calculator.show_supported()"
]
},
{
"cell_type": "markdown",
"id": "79",
"metadata": {},
"source": [
"Select the desired calculation engine."
]
},
{
"cell_type": "code",
"execution_count": 40,
"id": "80",
"metadata": {
"execution": {
"iopub.execute_input": "2026-06-30T22:32:47.709123Z",
"iopub.status.busy": "2026-06-30T22:32:47.708925Z",
"iopub.status.idle": "2026-06-30T22:32:47.714447Z",
"shell.execute_reply": "2026-06-30T22:32:47.713660Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\u001b[1;36mCalculator for experiment \u001b[0m\u001b[32m'hrpt'\u001b[0m\u001b[1;36m already set to\u001b[0m\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"cryspy\n"
]
}
],
"source": [
"project.experiments['hrpt'].calculator.type = 'cryspy'"
]
},
{
"cell_type": "markdown",
"id": "81",
"metadata": {},
"source": [
"### Set Plotting Engine\n",
"\n",
"EasyDiffraction can plot the measured and calculated patterns using different rendering engines.\n",
"The default `auto` engine resolves to an interactive `plotly` view inside Jupyter and a\n",
"static `asciichartpy` plot for schematic representation in a terminal.\n",
"\n",
"Show supported data plotting engines."
]
},
{
"cell_type": "code",
"execution_count": 41,
"id": "82",
"metadata": {
"execution": {
"iopub.execute_input": "2026-06-30T22:32:47.716230Z",
"iopub.status.busy": "2026-06-30T22:32:47.716038Z",
"iopub.status.idle": "2026-06-30T22:32:47.723951Z",
"shell.execute_reply": "2026-06-30T22:32:47.722675Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\u001b[1;36mRendering Plot types\u001b[0m\n"
]
},
{
"data": {
"text/html": [
" | | Type | Description |
|---|
| 1 | * | auto | Environment default rendering_plot engine |
|---|
| 2 | | asciichartpy | Console ASCII line charts |
|---|
| 3 | | plotly | Interactive browser-based graphing library |
|---|
"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"project.rendering_plot.show_supported()"
]
},
{
"cell_type": "markdown",
"id": "83",
"metadata": {},
"source": [
"Show all public attributes of the data rendering engine."
]
},
{
"cell_type": "code",
"execution_count": 42,
"id": "84",
"metadata": {
"execution": {
"iopub.execute_input": "2026-06-30T22:32:47.725562Z",
"iopub.status.busy": "2026-06-30T22:32:47.725384Z",
"iopub.status.idle": "2026-06-30T22:32:47.735370Z",
"shell.execute_reply": "2026-06-30T22:32:47.734543Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\u001b[1;36mProperties\u001b[0m\n"
]
},
{
"data": {
"text/html": [
" | Name | Writable | Description |
|---|
| 1 | as_cif | | Return CIF representation of this object. |
|---|
| 2 | parameters | | All GenericDescriptorBase instances on this item. |
|---|
| 3 | plotter | | Live plotting facade bound to the owning project. |
|---|
| 4 | type | β | Active factory tag for this category. |
|---|
| 5 | unique_name | | Fully qualified name: datablock, category, entry. |
|---|
"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"\u001b[1;36mMethods\u001b[0m\n"
]
},
{
"data": {
"text/html": [
" | Name | Description |
|---|
| 1 | from_cif() | Populate this rendering_plot category from a CIF block. |
|---|
| 2 | help() | Print parameters, other properties, and methods. |
|---|
| 3 | show_supported() | Print supported types and mark the active one. |
|---|
"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"project.rendering_plot.help()"
]
},
{
"cell_type": "markdown",
"id": "85",
"metadata": {},
"source": [
"### Display Pattern"
]
},
{
"cell_type": "code",
"execution_count": 43,
"id": "86",
"metadata": {
"execution": {
"iopub.execute_input": "2026-06-30T22:32:47.736868Z",
"iopub.status.busy": "2026-06-30T22:32:47.736706Z",
"iopub.status.idle": "2026-06-30T22:32:47.795266Z",
"shell.execute_reply": "2026-06-30T22:32:47.794488Z"
}
},
"outputs": [
{
"data": {
"text/html": [
""
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"project.display.pattern(expt_name='hrpt')"
]
},
{
"cell_type": "code",
"execution_count": 44,
"id": "87",
"metadata": {
"execution": {
"iopub.execute_input": "2026-06-30T22:32:47.799840Z",
"iopub.status.busy": "2026-06-30T22:32:47.799591Z",
"iopub.status.idle": "2026-06-30T22:32:47.857144Z",
"shell.execute_reply": "2026-06-30T22:32:47.856314Z"
}
},
"outputs": [
{
"data": {
"text/html": [
""
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"project.display.pattern(expt_name='hrpt', x_min=38, x_max=41)"
]
},
{
"cell_type": "markdown",
"id": "88",
"metadata": {},
"source": [
"### Display Parameters\n",
"\n",
"Show all parameters of the project."
]
},
{
"cell_type": "code",
"execution_count": 45,
"id": "89",
"metadata": {
"execution": {
"iopub.execute_input": "2026-06-30T22:32:47.858887Z",
"iopub.status.busy": "2026-06-30T22:32:47.858644Z",
"iopub.status.idle": "2026-06-30T22:32:48.038563Z",
"shell.execute_reply": "2026-06-30T22:32:48.037564Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\u001b[1;36mAll parameters for all structures \u001b[0m\u001b[1;36m(\u001b[0m\u001b[1;36mπ§© data blocks\u001b[0m\u001b[1;36m)\u001b[0m\n"
]
},
{
"data": {
"text/html": [
""
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"\u001b[1;36mAll parameters for all experiments \u001b[0m\u001b[1;36m(\u001b[0m\u001b[1;36m㪠data blocks\u001b[0m\u001b[1;36m)\u001b[0m\n"
]
},
{
"data": {
"text/html": [
""
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"project.display.parameters.all()"
]
},
{
"cell_type": "markdown",
"id": "90",
"metadata": {},
"source": [
"Show all fittable parameters."
]
},
{
"cell_type": "code",
"execution_count": 46,
"id": "91",
"metadata": {
"execution": {
"iopub.execute_input": "2026-06-30T22:32:48.040145Z",
"iopub.status.busy": "2026-06-30T22:32:48.039971Z",
"iopub.status.idle": "2026-06-30T22:32:48.108581Z",
"shell.execute_reply": "2026-06-30T22:32:48.107571Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\u001b[1;36mFittable parameters for all structures \u001b[0m\u001b[1;36m(\u001b[0m\u001b[1;36mπ§© data blocks\u001b[0m\u001b[1;36m)\u001b[0m\n"
]
},
{
"data": {
"text/html": [
" | datablock | category | entry | parameter | value | uncertainty | units | free |
|---|
| 1 | lbco | cell | | length_a | 3.88000 | | Γ
| False |
|---|
| 2 | lbco | atom_site | La | occupancy | 0.50000 | | | False |
|---|
| 3 | lbco | atom_site | La | adp_iso | 0.50000 | | Γ
Β² | False |
|---|
| 4 | lbco | atom_site | Ba | occupancy | 0.50000 | | | False |
|---|
| 5 | lbco | atom_site | Ba | adp_iso | 0.50000 | | Γ
Β² | False |
|---|
| 6 | lbco | atom_site | Co | occupancy | 1.00000 | | | False |
|---|
| 7 | lbco | atom_site | Co | adp_iso | 0.50000 | | Γ
Β² | False |
|---|
| 8 | lbco | atom_site | O | occupancy | 1.00000 | | | False |
|---|
| 9 | lbco | atom_site | O | adp_iso | 0.50000 | | Γ
Β² | False |
|---|
"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"\u001b[1;36mFittable parameters for all experiments \u001b[0m\u001b[1;36m(\u001b[0m\u001b[1;36m㪠data blocks\u001b[0m\u001b[1;36m)\u001b[0m\n"
]
},
{
"data": {
"text/html": [
""
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"project.display.parameters.fittable()"
]
},
{
"cell_type": "markdown",
"id": "92",
"metadata": {},
"source": [
"Show only free parameters."
]
},
{
"cell_type": "code",
"execution_count": 47,
"id": "93",
"metadata": {
"execution": {
"iopub.execute_input": "2026-06-30T22:32:48.110141Z",
"iopub.status.busy": "2026-06-30T22:32:48.109965Z",
"iopub.status.idle": "2026-06-30T22:32:48.134014Z",
"shell.execute_reply": "2026-06-30T22:32:48.133184Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"β οΈ No free parameters found. \n"
]
}
],
"source": [
"project.display.parameters.free()"
]
},
{
"cell_type": "markdown",
"id": "94",
"metadata": {},
"source": [
"Show how to access parameters in the code."
]
},
{
"cell_type": "code",
"execution_count": 48,
"id": "95",
"metadata": {
"execution": {
"iopub.execute_input": "2026-06-30T22:32:48.135641Z",
"iopub.status.busy": "2026-06-30T22:32:48.135489Z",
"iopub.status.idle": "2026-06-30T22:32:48.285277Z",
"shell.execute_reply": "2026-06-30T22:32:48.284522Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\u001b[1;36mHow to access parameters\u001b[0m\n"
]
},
{
"data": {
"text/html": [
" | datablock | category | entry | parameter | How to Access in Python Code |
|---|
| 1 | lbco | cell | | length_a | project.structures['lbco'].cell.length_a |
|---|
| 2 | lbco | cell | | length_b | project.structures['lbco'].cell.length_b |
|---|
| 3 | lbco | cell | | length_c | project.structures['lbco'].cell.length_c |
|---|
| 4 | lbco | cell | | angle_alpha | project.structures['lbco'].cell.angle_alpha |
|---|
| 5 | lbco | cell | | angle_beta | project.structures['lbco'].cell.angle_beta |
|---|
| 6 | lbco | cell | | angle_gamma | project.structures['lbco'].cell.angle_gamma |
|---|
| 7 | lbco | space_group | | name_h_m | project.structures['lbco'].space_group.name_h_m |
|---|
| 8 | lbco | space_group | | coord_system_code | project.structures['lbco'].space_group.coord_system_code |
|---|
| 9 | lbco | atom_site | La | id | project.structures['lbco'].atom_site['La'].id |
|---|
| 10 | lbco | atom_site | La | type_symbol | project.structures['lbco'].atom_site['La'].type_symbol |
|---|
| 11 | lbco | atom_site | La | fract_x | project.structures['lbco'].atom_site['La'].fract_x |
|---|
| 12 | lbco | atom_site | La | fract_y | project.structures['lbco'].atom_site['La'].fract_y |
|---|
| 13 | lbco | atom_site | La | fract_z | project.structures['lbco'].atom_site['La'].fract_z |
|---|
| 14 | lbco | atom_site | La | wyckoff_letter | project.structures['lbco'].atom_site['La'].wyckoff_letter |
|---|
| 15 | lbco | atom_site | La | multiplicity | project.structures['lbco'].atom_site['La'].multiplicity |
|---|
| 16 | lbco | atom_site | La | occupancy | project.structures['lbco'].atom_site['La'].occupancy |
|---|
| 17 | lbco | atom_site | La | adp_iso | project.structures['lbco'].atom_site['La'].adp_iso |
|---|
| 18 | lbco | atom_site | La | adp_type | project.structures['lbco'].atom_site['La'].adp_type |
|---|
| 19 | lbco | atom_site | Ba | id | project.structures['lbco'].atom_site['Ba'].id |
|---|
| 20 | lbco | atom_site | Ba | type_symbol | project.structures['lbco'].atom_site['Ba'].type_symbol |
|---|
| 21 | lbco | atom_site | Ba | fract_x | project.structures['lbco'].atom_site['Ba'].fract_x |
|---|
| 22 | lbco | atom_site | Ba | fract_y | project.structures['lbco'].atom_site['Ba'].fract_y |
|---|
| 23 | lbco | atom_site | Ba | fract_z | project.structures['lbco'].atom_site['Ba'].fract_z |
|---|
| 24 | lbco | atom_site | Ba | wyckoff_letter | project.structures['lbco'].atom_site['Ba'].wyckoff_letter |
|---|
| 25 | lbco | atom_site | Ba | multiplicity | project.structures['lbco'].atom_site['Ba'].multiplicity |
|---|
| 26 | lbco | atom_site | Ba | occupancy | project.structures['lbco'].atom_site['Ba'].occupancy |
|---|
| 27 | lbco | atom_site | Ba | adp_iso | project.structures['lbco'].atom_site['Ba'].adp_iso |
|---|
| 28 | lbco | atom_site | Ba | adp_type | project.structures['lbco'].atom_site['Ba'].adp_type |
|---|
| 29 | lbco | atom_site | Co | id | project.structures['lbco'].atom_site['Co'].id |
|---|
| 30 | lbco | atom_site | Co | type_symbol | project.structures['lbco'].atom_site['Co'].type_symbol |
|---|
| 31 | lbco | atom_site | Co | fract_x | project.structures['lbco'].atom_site['Co'].fract_x |
|---|
| 32 | lbco | atom_site | Co | fract_y | project.structures['lbco'].atom_site['Co'].fract_y |
|---|
| 33 | lbco | atom_site | Co | fract_z | project.structures['lbco'].atom_site['Co'].fract_z |
|---|
| 34 | lbco | atom_site | Co | wyckoff_letter | project.structures['lbco'].atom_site['Co'].wyckoff_letter |
|---|
| 35 | lbco | atom_site | Co | multiplicity | project.structures['lbco'].atom_site['Co'].multiplicity |
|---|
| 36 | lbco | atom_site | Co | occupancy | project.structures['lbco'].atom_site['Co'].occupancy |
|---|
| 37 | lbco | atom_site | Co | adp_iso | project.structures['lbco'].atom_site['Co'].adp_iso |
|---|
| 38 | lbco | atom_site | Co | adp_type | project.structures['lbco'].atom_site['Co'].adp_type |
|---|
| 39 | lbco | atom_site | O | id | project.structures['lbco'].atom_site['O'].id |
|---|
| 40 | lbco | atom_site | O | type_symbol | project.structures['lbco'].atom_site['O'].type_symbol |
|---|
| 41 | lbco | atom_site | O | fract_x | project.structures['lbco'].atom_site['O'].fract_x |
|---|
| 42 | lbco | atom_site | O | fract_y | project.structures['lbco'].atom_site['O'].fract_y |
|---|
| 43 | lbco | atom_site | O | fract_z | project.structures['lbco'].atom_site['O'].fract_z |
|---|
| 44 | lbco | atom_site | O | wyckoff_letter | project.structures['lbco'].atom_site['O'].wyckoff_letter |
|---|
| 45 | lbco | atom_site | O | multiplicity | project.structures['lbco'].atom_site['O'].multiplicity |
|---|
| 46 | lbco | atom_site | O | occupancy | project.structures['lbco'].atom_site['O'].occupancy |
|---|
| 47 | lbco | atom_site | O | adp_iso | project.structures['lbco'].atom_site['O'].adp_iso |
|---|
| 48 | lbco | atom_site | O | adp_type | project.structures['lbco'].atom_site['O'].adp_type |
|---|
| 49 | lbco | geom | | min_bond_distance_cutoff | project.structures['lbco'].geom.min_bond_distance_cutoff |
|---|
| 50 | lbco | geom | | bond_distance_inc | project.structures['lbco'].geom.bond_distance_inc |
|---|
| 51 | hrpt | experiment_type | | sample_form | project.experiments['hrpt'].experiment_type.sample_form |
|---|
| 52 | hrpt | experiment_type | | beam_mode | project.experiments['hrpt'].experiment_type.beam_mode |
|---|
| 53 | hrpt | experiment_type | | radiation_probe | project.experiments['hrpt'].experiment_type.radiation_probe |
|---|
| 54 | hrpt | experiment_type | | scattering_type | project.experiments['hrpt'].experiment_type.scattering_type |
|---|
| 55 | hrpt | diffrn | | ambient_temperature | project.experiments['hrpt'].diffrn.ambient_temperature |
|---|
| 56 | hrpt | diffrn | | ambient_pressure | project.experiments['hrpt'].diffrn.ambient_pressure |
|---|
| 57 | hrpt | diffrn | | ambient_magnetic_field | project.experiments['hrpt'].diffrn.ambient_magnetic_field |
|---|
| 58 | hrpt | diffrn | | ambient_electric_field | project.experiments['hrpt'].diffrn.ambient_electric_field |
|---|
| 59 | hrpt | calculator | | type | project.experiments['hrpt'].calculator.type |
|---|
| 60 | hrpt | linked_structure | lbco | structure_id | project.experiments['hrpt'].linked_structure['lbco'].structure_id |
|---|
| 61 | hrpt | linked_structure | lbco | scale | project.experiments['hrpt'].linked_structure['lbco'].scale |
|---|
| 62 | hrpt | data_range | | two_theta_min | project.experiments['hrpt'].data_range.two_theta_min |
|---|
| 63 | hrpt | data_range | | two_theta_max | project.experiments['hrpt'].data_range.two_theta_max |
|---|
| 64 | hrpt | data_range | | two_theta_inc | project.experiments['hrpt'].data_range.two_theta_inc |
|---|
| 65 | hrpt | peak | | broad_gauss_u | project.experiments['hrpt'].peak.broad_gauss_u |
|---|
| 66 | hrpt | peak | | broad_gauss_v | project.experiments['hrpt'].peak.broad_gauss_v |
|---|
| 67 | hrpt | peak | | broad_gauss_w | project.experiments['hrpt'].peak.broad_gauss_w |
|---|
| 68 | hrpt | peak | | broad_lorentz_x | project.experiments['hrpt'].peak.broad_lorentz_x |
|---|
| 69 | hrpt | peak | | broad_lorentz_y | project.experiments['hrpt'].peak.broad_lorentz_y |
|---|
| 70 | hrpt | peak | | cutoff_fwhm | project.experiments['hrpt'].peak.cutoff_fwhm |
|---|
| 71 | hrpt | peak | | type | project.experiments['hrpt'].peak.type |
|---|
| 72 | hrpt | instrument | | wavelength | project.experiments['hrpt'].instrument.wavelength |
|---|
| 73 | hrpt | instrument | | wavelength_2 | project.experiments['hrpt'].instrument.wavelength_2 |
|---|
| 74 | hrpt | instrument | | wavelength_2_to_1_ratio | project.experiments['hrpt'].instrument.wavelength_2_to_1_ratio |
|---|
| 75 | hrpt | instrument | | twotheta_offset | project.experiments['hrpt'].instrument.twotheta_offset |
|---|
| 76 | hrpt | instrument | | sample_displacement | project.experiments['hrpt'].instrument.sample_displacement |
|---|
| 77 | hrpt | instrument | | sample_transparency | project.experiments['hrpt'].instrument.sample_transparency |
|---|
| 78 | hrpt | background | 10 | id | project.experiments['hrpt'].background['10'].id |
|---|
| 79 | hrpt | background | 10 | position | project.experiments['hrpt'].background['10'].position |
|---|
| 80 | hrpt | background | 10 | intensity | project.experiments['hrpt'].background['10'].intensity |
|---|
| 81 | hrpt | background | 30 | id | project.experiments['hrpt'].background['30'].id |
|---|
| 82 | hrpt | background | 30 | position | project.experiments['hrpt'].background['30'].position |
|---|
| 83 | hrpt | background | 30 | intensity | project.experiments['hrpt'].background['30'].intensity |
|---|
| 84 | hrpt | background | 50 | id | project.experiments['hrpt'].background['50'].id |
|---|
| 85 | hrpt | background | 50 | position | project.experiments['hrpt'].background['50'].position |
|---|
| 86 | hrpt | background | 50 | intensity | project.experiments['hrpt'].background['50'].intensity |
|---|
| 87 | hrpt | background | 110 | id | project.experiments['hrpt'].background['110'].id |
|---|
| 88 | hrpt | background | 110 | position | project.experiments['hrpt'].background['110'].position |
|---|
| 89 | hrpt | background | 110 | intensity | project.experiments['hrpt'].background['110'].intensity |
|---|
| 90 | hrpt | background | 165 | id | project.experiments['hrpt'].background['165'].id |
|---|
| 91 | hrpt | background | 165 | position | project.experiments['hrpt'].background['165'].position |
|---|
| 92 | hrpt | background | 165 | intensity | project.experiments['hrpt'].background['165'].intensity |
|---|
| 93 | hrpt | absorption | | type | project.experiments['hrpt'].absorption.type |
|---|
"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"project.display.parameters.access()"
]
},
{
"cell_type": "markdown",
"id": "96",
"metadata": {},
"source": [
"### Set Fit Mode\n",
"\n",
"Show supported fit modes."
]
},
{
"cell_type": "code",
"execution_count": 49,
"id": "97",
"metadata": {
"execution": {
"iopub.execute_input": "2026-06-30T22:32:48.287157Z",
"iopub.status.busy": "2026-06-30T22:32:48.286969Z",
"iopub.status.idle": "2026-06-30T22:32:48.294542Z",
"shell.execute_reply": "2026-06-30T22:32:48.293633Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\u001b[1;36mFitting Mode types\u001b[0m\n"
]
},
{
"data": {
"text/html": [
" | | Type | Description |
|---|
| 1 | * | single | Fit one experiment at a time. |
|---|
| 2 | | sequential | Fit one experiment against a series of data files. |
|---|
"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"project.analysis.fitting_mode.show_supported()"
]
},
{
"cell_type": "markdown",
"id": "98",
"metadata": {},
"source": [
"Select desired fit mode."
]
},
{
"cell_type": "code",
"execution_count": 50,
"id": "99",
"metadata": {
"execution": {
"iopub.execute_input": "2026-06-30T22:32:48.296149Z",
"iopub.status.busy": "2026-06-30T22:32:48.295968Z",
"iopub.status.idle": "2026-06-30T22:32:48.300835Z",
"shell.execute_reply": "2026-06-30T22:32:48.299972Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\u001b[1;36mFitting mode changed to\u001b[0m\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"single\n"
]
}
],
"source": [
"project.analysis.fitting_mode.type = 'single'"
]
},
{
"cell_type": "markdown",
"id": "100",
"metadata": {},
"source": [
"### Set Minimizer\n",
"\n",
"Show supported fitting engines."
]
},
{
"cell_type": "code",
"execution_count": 51,
"id": "101",
"metadata": {
"execution": {
"iopub.execute_input": "2026-06-30T22:32:48.302347Z",
"iopub.status.busy": "2026-06-30T22:32:48.302185Z",
"iopub.status.idle": "2026-06-30T22:32:48.308566Z",
"shell.execute_reply": "2026-06-30T22:32:48.307911Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\u001b[1;36mMinimizer types\u001b[0m\n"
]
},
{
"data": {
"text/html": [
" | | Type | Description |
|---|
| 1 | | bumps | BUMPS library using the default Levenberg-Marquardt method |
|---|
| 2 | | bumps (amoeba) | BUMPS library with Nelder-Mead simplex method |
|---|
| 3 | | bumps (de) | BUMPS library with differential evolution method |
|---|
| 4 | | bumps (dream) | BUMPS library with DREAM Bayesian sampling |
|---|
| 5 | | bumps (lm) | BUMPS library with Levenberg-Marquardt method |
|---|
| 6 | | dfols | DFO-LS library for derivative-free least-squares optimization |
|---|
| 7 | | emcee | emcee affine-invariant ensemble Bayesian sampling |
|---|
| 8 | | lmfit | LMFIT library using the default Levenberg-Marquardt method |
|---|
| 9 | | lmfit (least_squares) | LMFIT library with SciPy's trust region reflective algorithm |
|---|
| 10 | * | lmfit (leastsq) | LMFIT library with Levenberg-Marquardt least squares method |
|---|
"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"project.analysis.minimizer.show_supported()"
]
},
{
"cell_type": "markdown",
"id": "102",
"metadata": {},
"source": [
"Select desired fitting engine."
]
},
{
"cell_type": "code",
"execution_count": 52,
"id": "103",
"metadata": {
"execution": {
"iopub.execute_input": "2026-06-30T22:32:48.310274Z",
"iopub.status.busy": "2026-06-30T22:32:48.310021Z",
"iopub.status.idle": "2026-06-30T22:32:48.316741Z",
"shell.execute_reply": "2026-06-30T22:32:48.315948Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\u001b[1;36mCurrent minimizer changed to\u001b[0m\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"lmfit\n"
]
}
],
"source": [
"project.analysis.minimizer.type = 'lmfit'"
]
},
{
"cell_type": "markdown",
"id": "104",
"metadata": {},
"source": [
"### Perform Fit 1/5\n",
"\n",
"Set structure parameters to be refined."
]
},
{
"cell_type": "code",
"execution_count": 53,
"id": "105",
"metadata": {
"execution": {
"iopub.execute_input": "2026-06-30T22:32:48.318310Z",
"iopub.status.busy": "2026-06-30T22:32:48.318152Z",
"iopub.status.idle": "2026-06-30T22:32:48.321346Z",
"shell.execute_reply": "2026-06-30T22:32:48.320605Z"
}
},
"outputs": [],
"source": [
"project.structures['lbco'].cell.length_a.free = True"
]
},
{
"cell_type": "markdown",
"id": "106",
"metadata": {},
"source": [
"Set experiment parameters to be refined."
]
},
{
"cell_type": "code",
"execution_count": 54,
"id": "107",
"metadata": {
"execution": {
"iopub.execute_input": "2026-06-30T22:32:48.322790Z",
"iopub.status.busy": "2026-06-30T22:32:48.322638Z",
"iopub.status.idle": "2026-06-30T22:32:48.326407Z",
"shell.execute_reply": "2026-06-30T22:32:48.325516Z"
}
},
"outputs": [],
"source": [
"project.experiments['hrpt'].linked_structures['lbco'].scale.free = True\n",
"project.experiments['hrpt'].instrument.calib_twotheta_offset.free = True\n",
"project.experiments['hrpt'].background['10'].intensity.free = True\n",
"project.experiments['hrpt'].background['30'].intensity.free = True\n",
"project.experiments['hrpt'].background['50'].intensity.free = True\n",
"project.experiments['hrpt'].background['110'].intensity.free = True\n",
"project.experiments['hrpt'].background['165'].intensity.free = True"
]
},
{
"cell_type": "markdown",
"id": "108",
"metadata": {},
"source": [
"Show free parameters after selection."
]
},
{
"cell_type": "code",
"execution_count": 55,
"id": "109",
"metadata": {
"execution": {
"iopub.execute_input": "2026-06-30T22:32:48.327943Z",
"iopub.status.busy": "2026-06-30T22:32:48.327739Z",
"iopub.status.idle": "2026-06-30T22:32:48.369167Z",
"shell.execute_reply": "2026-06-30T22:32:48.368307Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\u001b[1;36mFree parameters for both structures \u001b[0m\u001b[1;36m(\u001b[0m\u001b[1;36mπ§© data blocks\u001b[0m\u001b[1;36m)\u001b[0m\u001b[1;36m and experiments \u001b[0m\u001b[1;36m(\u001b[0m\u001b[1;36mπ¬ data blocks\u001b[0m\u001b[1;36m)\u001b[0m\n"
]
},
{
"data": {
"text/html": [
" | datablock | category | entry | parameter | value | uncertainty | min | max | units |
|---|
| 1 | lbco | cell | | length_a | 3.88000 | | -inf | inf | Γ
|
|---|
| 2 | hrpt | linked_structure | lbco | scale | 10.00000 | | -inf | inf | |
|---|
| 3 | hrpt | instrument | | twotheta_offset | 0.60000 | | -inf | inf | deg |
|---|
| 4 | hrpt | background | 10 | intensity | 170.00000 | | -inf | inf | |
|---|
| 5 | hrpt | background | 30 | intensity | 170.00000 | | -inf | inf | |
|---|
| 6 | hrpt | background | 50 | intensity | 170.00000 | | -inf | inf | |
|---|
| 7 | hrpt | background | 110 | intensity | 170.00000 | | -inf | inf | |
|---|
| 8 | hrpt | background | 165 | intensity | 170.00000 | | -inf | inf | |
|---|
"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"project.display.parameters.free()"
]
},
{
"cell_type": "markdown",
"id": "110",
"metadata": {},
"source": [
"#### Run Fitting"
]
},
{
"cell_type": "code",
"execution_count": 56,
"id": "111",
"metadata": {
"execution": {
"iopub.execute_input": "2026-06-30T22:32:48.371199Z",
"iopub.status.busy": "2026-06-30T22:32:48.371034Z",
"iopub.status.idle": "2026-06-30T22:32:51.802088Z",
"shell.execute_reply": "2026-06-30T22:32:51.801285Z"
}
},
"outputs": [
{
"data": {
"text/html": [],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"application/javascript": [
"\n",
"(function() {\n",
" const button = document.getElementById('ed-fit-stop-de50e93fbf624b91b03e96d6c98d1632-button');\n",
" const status = document.getElementById('ed-fit-stop-de50e93fbf624b91b03e96d6c98d1632-status');\n",
" const kernelId = '';\n",
" if (!button) {\n",
" return;\n",
" }\n",
"\n",
" function setStatus(text) {\n",
" if (status) {\n",
" status.textContent = text;\n",
" }\n",
" }\n",
"\n",
" function pageConfig() {\n",
" const element = document.getElementById('jupyter-config-data');\n",
" if (!element || !element.textContent) {\n",
" return {};\n",
" }\n",
" try {\n",
" return JSON.parse(element.textContent);\n",
" } catch (error) {\n",
" return {};\n",
" }\n",
" }\n",
"\n",
" function baseUrl(config) {\n",
" const configured = config.baseUrl || config.base_url ||\n",
" (window.Jupyter && Jupyter.notebook && Jupyter.notebook.base_url);\n",
" if (configured) {\n",
" return configured.endsWith('/') ? configured : configured + '/';\n",
" }\n",
" const markers = ['/lab/', '/notebooks/', '/tree/'];\n",
" for (const marker of markers) {\n",
" const index = window.location.pathname.indexOf(marker);\n",
" if (index >= 0) {\n",
" return window.location.pathname.slice(0, index + 1);\n",
" }\n",
" }\n",
" return '/';\n",
" }\n",
"\n",
" function token(config) {\n",
" return config.token || new URLSearchParams(window.location.search).get('token') || '';\n",
" }\n",
"\n",
" function cookie(name) {\n",
" const prefix = name + '=';\n",
" for (const part of document.cookie.split(';')) {\n",
" const trimmed = part.trim();\n",
" if (trimmed.startsWith(prefix)) {\n",
" return decodeURIComponent(trimmed.slice(prefix.length));\n",
" }\n",
" }\n",
" return '';\n",
" }\n",
"\n",
" function notebookPath() {\n",
" const decoded = decodeURIComponent(window.location.pathname);\n",
" const markers = ['/lab/tree/', '/notebooks/', '/tree/'];\n",
" for (const marker of markers) {\n",
" const index = decoded.indexOf(marker);\n",
" if (index >= 0) {\n",
" return decoded.slice(index + marker.length);\n",
" }\n",
" }\n",
" return '';\n",
" }\n",
"\n",
" async function kernelFromSessions(config) {\n",
" const url = new URL(baseUrl(config) + 'api/sessions', window.location.origin);\n",
" const authToken = token(config);\n",
" if (authToken) {\n",
" url.searchParams.set('token', authToken);\n",
" }\n",
" const response = await fetch(url, {credentials: 'same-origin'});\n",
" if (!response.ok) {\n",
" return '';\n",
" }\n",
" const sessions = await response.json();\n",
" const path = notebookPath();\n",
" const session = sessions.find((item) => item.path === path) || sessions[0];\n",
" return session && session.kernel ? session.kernel.id : '';\n",
" }\n",
"\n",
" async function interruptKernel(config, resolvedKernelId) {\n",
" const url = new URL(\n",
" baseUrl(config) + 'api/kernels/' + resolvedKernelId + '/interrupt',\n",
" window.location.origin\n",
" );\n",
" const authToken = token(config);\n",
" if (authToken) {\n",
" url.searchParams.set('token', authToken);\n",
" }\n",
" const xsrfToken = cookie('_xsrf');\n",
" const headers = {};\n",
" if (xsrfToken) {\n",
" headers['X-XSRFToken'] = xsrfToken;\n",
" }\n",
" const response = await fetch(url, {\n",
" method: 'POST',\n",
" credentials: 'same-origin',\n",
" headers: headers\n",
" });\n",
" return response.ok;\n",
" }\n",
"\n",
" button.addEventListener('click', async function() {\n",
" button.disabled = true;\n",
" setStatus('Stopping...');\n",
" const config = pageConfig();\n",
" try {\n",
" const resolvedKernelId = kernelId || await kernelFromSessions(config);\n",
" if (!resolvedKernelId) {\n",
" throw new Error('Could not resolve the current kernel id.');\n",
" }\n",
" const interrupted = await interruptKernel(config, resolvedKernelId);\n",
" if (!interrupted) {\n",
" throw new Error('Jupyter Server rejected the interrupt request.');\n",
" }\n",
" setStatus('Interrupt sent...');\n",
" } catch (error) {\n",
" button.disabled = false;\n",
" setStatus('Use Kernel > Interrupt to stop this fit.');\n",
" }\n",
" });\n",
"})();\n"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"\u001b[1;36mStandard fitting\u001b[0m\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"π Using experiment π¬ \u001b[32m'hrpt'\u001b[0m for \u001b[32m'single'\u001b[0m fitting\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"π Starting fit process with \u001b[32m'lmfit \u001b[0m\u001b[32m(\u001b[0m\u001b[32mleastsq\u001b[0m\u001b[32m)\u001b[0m\u001b[32m'\u001b[0m\u001b[33m...\u001b[0m\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"π Goodness-of-fit progress:\n"
]
},
{
"data": {
"text/html": [
" | iteration | time (s) | ΟΒ² | change / status |
|---|
| 1 | 1 | 0.03 | 164.59 | |
|---|
| 2 | 12 | 0.37 | 33.43 | 79.7% β |
|---|
| 3 | 21 | 0.84 | 13.22 | 60.4% β |
|---|
| 4 | 30 | 1.15 | 5.78 | 56.3% β |
|---|
| 5 | 39 | 1.43 | 3.15 | 45.6% β |
|---|
| 6 | 77 | 2.66 | 3.14 | |
|---|
"
],
"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.14\u001b[0m at iteration \u001b[1;36m69\u001b[0m\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"β
Fitting complete.\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"\u001b[1;36mSaving project π¦ \u001b[0m\u001b[32m'lbco_hrpt'\u001b[0m\u001b[1;36m to \u001b[0m\u001b[32m'../../../projects/refine-lbco-hrpt-report'\u001b[0m\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"βββ π project.edi\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"βββ π structures/\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"β βββ π lbco.edi\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"βββ π experiments/\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"β βββ π hrpt.edi\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"βββ π analysis/\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"β βββ π analysis.edi\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"βββ π reports/\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
" βββ π lbco_hrpt.html\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"βοΈ Settings used:\n"
]
},
{
"data": {
"text/html": [
" | Name | Value | Description |
|---|
| 1 | max_iterations | 1000 | Maximum solver iterations. |
|---|
"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"π Least-squares fit results:\n"
]
},
{
"data": {
"text/html": [
" | Metric | Value |
|---|
| 1 | π§ͺ Minimizer | lmfit |
|---|
| 2 | β
Overall status | success |
|---|
| 3 | β±οΈ Fitting time (seconds) | 2.66 |
|---|
| 4 | π Iterations | 74 |
|---|
| 5 | π Goodness-of-fit (reduced ΟΒ²) | 3.14 |
|---|
| 6 | π R-factor (Rf, %) | 8.42 |
|---|
| 7 | π R-factor squared (RfΒ², %) | 11.79 |
|---|
| 8 | π Weighted R-factor (wR, %) | 11.62 |
|---|
"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"π Refined parameters:\n"
]
},
{
"data": {
"text/html": [
" | datablock | category | entry | parameter | units | start | value | s.u. | change |
|---|
| 1 | lbco | cell | | length_a | Γ
| 3.8800 | 3.8910 | 0.0001 | 0.28 % β |
|---|
| 2 | hrpt | linked_structure | lbco | scale | | 10.0000 | 7.3409 | 0.0350 | 26.59 % β |
|---|
| 3 | hrpt | instrument | | twotheta_offset | deg | 0.6000 | 0.6243 | 0.0018 | 4.05 % β |
|---|
| 4 | hrpt | background | 10 | intensity | | 170.0000 | 167.7066 | 2.1300 | 1.35 % β |
|---|
| 5 | hrpt | background | 30 | intensity | | 170.0000 | 166.0338 | 1.5404 | 2.33 % β |
|---|
| 6 | hrpt | background | 50 | intensity | | 170.0000 | 169.9495 | 1.1025 | 0.03 % β |
|---|
| 7 | hrpt | background | 110 | intensity | | 170.0000 | 170.0802 | 0.9788 | 0.05 % β |
|---|
| 8 | hrpt | background | 165 | intensity | | 170.0000 | 179.6656 | 1.3289 | 5.69 % β |
|---|
"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
" β’ start = parameter value before refinement
β’ value = refined value from least-squares minimization
β’ s.u. = standard uncertainty (one sigma), from the covariance matrix
β’ change = relative change from start, in %; β = increase, β = decrease
"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"project.analysis.fit()\n",
"project.display.fit.results()"
]
},
{
"cell_type": "markdown",
"id": "112",
"metadata": {},
"source": [
"#### Display Pattern"
]
},
{
"cell_type": "code",
"execution_count": 57,
"id": "113",
"metadata": {
"execution": {
"iopub.execute_input": "2026-06-30T22:32:51.803583Z",
"iopub.status.busy": "2026-06-30T22:32:51.803419Z",
"iopub.status.idle": "2026-06-30T22:32:51.860797Z",
"shell.execute_reply": "2026-06-30T22:32:51.859912Z"
}
},
"outputs": [
{
"data": {
"text/html": [
""
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"project.display.pattern(expt_name='hrpt')"
]
},
{
"cell_type": "code",
"execution_count": 58,
"id": "114",
"metadata": {
"execution": {
"iopub.execute_input": "2026-06-30T22:32:51.864997Z",
"iopub.status.busy": "2026-06-30T22:32:51.864825Z",
"iopub.status.idle": "2026-06-30T22:32:51.915031Z",
"shell.execute_reply": "2026-06-30T22:32:51.914330Z"
}
},
"outputs": [
{
"data": {
"text/html": [
""
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"project.display.pattern(expt_name='hrpt', x_min=38, x_max=41)"
]
},
{
"cell_type": "markdown",
"id": "115",
"metadata": {},
"source": [
"### Perform Fit 2/5\n",
"\n",
"Set more parameters to be refined."
]
},
{
"cell_type": "code",
"execution_count": 59,
"id": "116",
"metadata": {
"execution": {
"iopub.execute_input": "2026-06-30T22:32:51.916902Z",
"iopub.status.busy": "2026-06-30T22:32:51.916741Z",
"iopub.status.idle": "2026-06-30T22:32:51.920129Z",
"shell.execute_reply": "2026-06-30T22:32:51.919256Z"
}
},
"outputs": [],
"source": [
"project.experiments['hrpt'].peak.broad_gauss_u.free = True\n",
"project.experiments['hrpt'].peak.broad_gauss_v.free = True\n",
"project.experiments['hrpt'].peak.broad_gauss_w.free = True\n",
"project.experiments['hrpt'].peak.broad_lorentz_y.free = True"
]
},
{
"cell_type": "markdown",
"id": "117",
"metadata": {},
"source": [
"Show free parameters after selection."
]
},
{
"cell_type": "code",
"execution_count": 60,
"id": "118",
"metadata": {
"execution": {
"iopub.execute_input": "2026-06-30T22:32:51.921866Z",
"iopub.status.busy": "2026-06-30T22:32:51.921648Z",
"iopub.status.idle": "2026-06-30T22:32:51.972159Z",
"shell.execute_reply": "2026-06-30T22:32:51.971270Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\u001b[1;36mFree parameters for both structures \u001b[0m\u001b[1;36m(\u001b[0m\u001b[1;36mπ§© data blocks\u001b[0m\u001b[1;36m)\u001b[0m\u001b[1;36m and experiments \u001b[0m\u001b[1;36m(\u001b[0m\u001b[1;36mπ¬ data blocks\u001b[0m\u001b[1;36m)\u001b[0m\n"
]
},
{
"data": {
"text/html": [
""
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"project.display.parameters.free()"
]
},
{
"cell_type": "markdown",
"id": "119",
"metadata": {},
"source": [
"#### Run Fitting"
]
},
{
"cell_type": "code",
"execution_count": 61,
"id": "120",
"metadata": {
"execution": {
"iopub.execute_input": "2026-06-30T22:32:51.974106Z",
"iopub.status.busy": "2026-06-30T22:32:51.973947Z",
"iopub.status.idle": "2026-06-30T22:32:55.410578Z",
"shell.execute_reply": "2026-06-30T22:32:55.409744Z"
}
},
"outputs": [
{
"data": {
"text/html": [],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"application/javascript": [
"\n",
"(function() {\n",
" const button = document.getElementById('ed-fit-stop-d619fbaf6aba4924892cdf0b2669e578-button');\n",
" const status = document.getElementById('ed-fit-stop-d619fbaf6aba4924892cdf0b2669e578-status');\n",
" const kernelId = '';\n",
" if (!button) {\n",
" return;\n",
" }\n",
"\n",
" function setStatus(text) {\n",
" if (status) {\n",
" status.textContent = text;\n",
" }\n",
" }\n",
"\n",
" function pageConfig() {\n",
" const element = document.getElementById('jupyter-config-data');\n",
" if (!element || !element.textContent) {\n",
" return {};\n",
" }\n",
" try {\n",
" return JSON.parse(element.textContent);\n",
" } catch (error) {\n",
" return {};\n",
" }\n",
" }\n",
"\n",
" function baseUrl(config) {\n",
" const configured = config.baseUrl || config.base_url ||\n",
" (window.Jupyter && Jupyter.notebook && Jupyter.notebook.base_url);\n",
" if (configured) {\n",
" return configured.endsWith('/') ? configured : configured + '/';\n",
" }\n",
" const markers = ['/lab/', '/notebooks/', '/tree/'];\n",
" for (const marker of markers) {\n",
" const index = window.location.pathname.indexOf(marker);\n",
" if (index >= 0) {\n",
" return window.location.pathname.slice(0, index + 1);\n",
" }\n",
" }\n",
" return '/';\n",
" }\n",
"\n",
" function token(config) {\n",
" return config.token || new URLSearchParams(window.location.search).get('token') || '';\n",
" }\n",
"\n",
" function cookie(name) {\n",
" const prefix = name + '=';\n",
" for (const part of document.cookie.split(';')) {\n",
" const trimmed = part.trim();\n",
" if (trimmed.startsWith(prefix)) {\n",
" return decodeURIComponent(trimmed.slice(prefix.length));\n",
" }\n",
" }\n",
" return '';\n",
" }\n",
"\n",
" function notebookPath() {\n",
" const decoded = decodeURIComponent(window.location.pathname);\n",
" const markers = ['/lab/tree/', '/notebooks/', '/tree/'];\n",
" for (const marker of markers) {\n",
" const index = decoded.indexOf(marker);\n",
" if (index >= 0) {\n",
" return decoded.slice(index + marker.length);\n",
" }\n",
" }\n",
" return '';\n",
" }\n",
"\n",
" async function kernelFromSessions(config) {\n",
" const url = new URL(baseUrl(config) + 'api/sessions', window.location.origin);\n",
" const authToken = token(config);\n",
" if (authToken) {\n",
" url.searchParams.set('token', authToken);\n",
" }\n",
" const response = await fetch(url, {credentials: 'same-origin'});\n",
" if (!response.ok) {\n",
" return '';\n",
" }\n",
" const sessions = await response.json();\n",
" const path = notebookPath();\n",
" const session = sessions.find((item) => item.path === path) || sessions[0];\n",
" return session && session.kernel ? session.kernel.id : '';\n",
" }\n",
"\n",
" async function interruptKernel(config, resolvedKernelId) {\n",
" const url = new URL(\n",
" baseUrl(config) + 'api/kernels/' + resolvedKernelId + '/interrupt',\n",
" window.location.origin\n",
" );\n",
" const authToken = token(config);\n",
" if (authToken) {\n",
" url.searchParams.set('token', authToken);\n",
" }\n",
" const xsrfToken = cookie('_xsrf');\n",
" const headers = {};\n",
" if (xsrfToken) {\n",
" headers['X-XSRFToken'] = xsrfToken;\n",
" }\n",
" const response = await fetch(url, {\n",
" method: 'POST',\n",
" credentials: 'same-origin',\n",
" headers: headers\n",
" });\n",
" return response.ok;\n",
" }\n",
"\n",
" button.addEventListener('click', async function() {\n",
" button.disabled = true;\n",
" setStatus('Stopping...');\n",
" const config = pageConfig();\n",
" try {\n",
" const resolvedKernelId = kernelId || await kernelFromSessions(config);\n",
" if (!resolvedKernelId) {\n",
" throw new Error('Could not resolve the current kernel id.');\n",
" }\n",
" const interrupted = await interruptKernel(config, resolvedKernelId);\n",
" if (!interrupted) {\n",
" throw new Error('Jupyter Server rejected the interrupt request.');\n",
" }\n",
" setStatus('Interrupt sent...');\n",
" } catch (error) {\n",
" button.disabled = false;\n",
" setStatus('Use Kernel > Interrupt to stop this fit.');\n",
" }\n",
" });\n",
"})();\n"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"\u001b[1;36mStandard fitting\u001b[0m\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"π Using experiment π¬ \u001b[32m'hrpt'\u001b[0m for \u001b[32m'single'\u001b[0m fitting\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"π Starting fit process with \u001b[32m'lmfit \u001b[0m\u001b[32m(\u001b[0m\u001b[32mleastsq\u001b[0m\u001b[32m)\u001b[0m\u001b[32m'\u001b[0m\u001b[33m...\u001b[0m\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"π Goodness-of-fit progress:\n"
]
},
{
"data": {
"text/html": [
" | iteration | time (s) | ΟΒ² | change / status |
|---|
| 1 | 1 | 0.04 | 3.14 | |
|---|
| 2 | 16 | 0.57 | 2.85 | 9.1% β |
|---|
| 3 | 69 | 2.48 | 2.85 | |
|---|
"
],
"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;36m2.85\u001b[0m at iteration \u001b[1;36m68\u001b[0m\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"β
Fitting complete.\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"\u001b[1;36mSaving project π¦ \u001b[0m\u001b[32m'lbco_hrpt'\u001b[0m\u001b[1;36m to \u001b[0m\u001b[32m'../../../projects/refine-lbco-hrpt-report'\u001b[0m\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"βββ π project.edi\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"βββ π structures/\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"β βββ π lbco.edi\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"βββ π experiments/\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"β βββ π hrpt.edi\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"βββ π analysis/\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"β βββ π analysis.edi\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"βββ π reports/\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
" βββ π lbco_hrpt.html\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"βοΈ Settings used:\n"
]
},
{
"data": {
"text/html": [
" | Name | Value | Description |
|---|
| 1 | max_iterations | 1000 | Maximum solver iterations. |
|---|
"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"π Least-squares fit results:\n"
]
},
{
"data": {
"text/html": [
" | Metric | Value |
|---|
| 1 | π§ͺ Minimizer | lmfit |
|---|
| 2 | β
Overall status | success |
|---|
| 3 | β±οΈ Fitting time (seconds) | 2.48 |
|---|
| 4 | π Iterations | 66 |
|---|
| 5 | π Goodness-of-fit (reduced ΟΒ²) | 2.85 |
|---|
| 6 | π R-factor (Rf, %) | 8.30 |
|---|
| 7 | π R-factor squared (RfΒ², %) | 11.85 |
|---|
| 8 | π Weighted R-factor (wR, %) | 11.91 |
|---|
"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"π Refined parameters:\n"
]
},
{
"data": {
"text/html": [
" | datablock | category | entry | parameter | units | start | value | s.u. | change |
|---|
| 1 | lbco | cell | | length_a | Γ
| 3.8910 | 3.8909 | 0.0001 | 0.00 % β |
|---|
| 2 | hrpt | linked_structure | lbco | scale | | 7.3409 | 7.2120 | 0.0406 | 1.76 % β |
|---|
| 3 | hrpt | peak | | broad_gauss_u | degΒ² | 0.1000 | 0.0803 | 0.0047 | 19.74 % β |
|---|
| 4 | hrpt | peak | | broad_gauss_v | degΒ² | -0.1000 | -0.1029 | 0.0104 | 2.93 % β |
|---|
| 5 | hrpt | peak | | broad_gauss_w | degΒ² | 0.1000 | 0.1077 | 0.0051 | 7.66 % β |
|---|
| 6 | hrpt | peak | | broad_lorentz_y | deg | 0.1000 | 0.0893 | 0.0032 | 10.67 % β |
|---|
| 7 | hrpt | instrument | | twotheta_offset | deg | 0.6243 | 0.6231 | 0.0017 | 0.19 % β |
|---|
| 8 | hrpt | background | 10 | intensity | | 167.7066 | 167.5167 | 2.0311 | 0.11 % β |
|---|
| 9 | hrpt | background | 30 | intensity | | 166.0338 | 166.7627 | 1.4794 | 0.44 % β |
|---|
| 10 | hrpt | background | 50 | intensity | | 169.9495 | 170.8330 | 1.0808 | 0.52 % β |
|---|
| 11 | hrpt | background | 110 | intensity | | 170.0802 | 172.2546 | 0.9660 | 1.28 % β |
|---|
| 12 | hrpt | background | 165 | intensity | | 179.6656 | 180.6405 | 1.2737 | 0.54 % β |
|---|
"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
" β’ start = parameter value before refinement
β’ value = refined value from least-squares minimization
β’ s.u. = standard uncertainty (one sigma), from the covariance matrix
β’ change = relative change from start, in %; β = increase, β = decrease
"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"project.analysis.fit()\n",
"project.display.fit.results()"
]
},
{
"cell_type": "markdown",
"id": "121",
"metadata": {},
"source": [
"#### Display Pattern"
]
},
{
"cell_type": "code",
"execution_count": 62,
"id": "122",
"metadata": {
"execution": {
"iopub.execute_input": "2026-06-30T22:32:55.412260Z",
"iopub.status.busy": "2026-06-30T22:32:55.412057Z",
"iopub.status.idle": "2026-06-30T22:32:55.470707Z",
"shell.execute_reply": "2026-06-30T22:32:55.470040Z"
}
},
"outputs": [
{
"data": {
"text/html": [
""
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"project.display.pattern(expt_name='hrpt')"
]
},
{
"cell_type": "code",
"execution_count": 63,
"id": "123",
"metadata": {
"execution": {
"iopub.execute_input": "2026-06-30T22:32:55.477382Z",
"iopub.status.busy": "2026-06-30T22:32:55.477199Z",
"iopub.status.idle": "2026-06-30T22:32:55.527815Z",
"shell.execute_reply": "2026-06-30T22:32:55.526966Z"
}
},
"outputs": [
{
"data": {
"text/html": [
""
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"project.display.pattern(expt_name='hrpt', x_min=38, x_max=41)"
]
},
{
"cell_type": "markdown",
"id": "124",
"metadata": {},
"source": [
"#### Save Project State"
]
},
{
"cell_type": "code",
"execution_count": 64,
"id": "125",
"metadata": {
"execution": {
"iopub.execute_input": "2026-06-30T22:32:55.529791Z",
"iopub.status.busy": "2026-06-30T22:32:55.529628Z",
"iopub.status.idle": "2026-06-30T22:32:55.882023Z",
"shell.execute_reply": "2026-06-30T22:32:55.881194Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\u001b[1;36mSaving project π¦ \u001b[0m\u001b[32m'lbco_hrpt'\u001b[0m\u001b[1;36m to \u001b[0m\u001b[32m'../../../projects/refine-lbco-hrpt-report'\u001b[0m\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"βββ π project.edi\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"βββ π structures/\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"β βββ π lbco.edi\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"βββ π experiments/\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"β βββ π hrpt.edi\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"βββ π analysis/\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"β βββ π analysis.edi\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"βββ π reports/\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
" βββ π lbco_hrpt.html\n"
]
}
],
"source": [
"project.save()"
]
},
{
"cell_type": "markdown",
"id": "126",
"metadata": {},
"source": [
"### Perform Fit 3/5\n",
"\n",
"Set more parameters to be refined."
]
},
{
"cell_type": "code",
"execution_count": 65,
"id": "127",
"metadata": {
"execution": {
"iopub.execute_input": "2026-06-30T22:32:55.884027Z",
"iopub.status.busy": "2026-06-30T22:32:55.883804Z",
"iopub.status.idle": "2026-06-30T22:32:55.888287Z",
"shell.execute_reply": "2026-06-30T22:32:55.887122Z"
}
},
"outputs": [],
"source": [
"project.structures['lbco'].atom_sites['La'].adp_iso.free = True\n",
"project.structures['lbco'].atom_sites['Ba'].adp_iso.free = True\n",
"project.structures['lbco'].atom_sites['Co'].adp_iso.free = True\n",
"project.structures['lbco'].atom_sites['O'].adp_iso.free = True"
]
},
{
"cell_type": "markdown",
"id": "128",
"metadata": {},
"source": [
"Show free parameters after selection."
]
},
{
"cell_type": "code",
"execution_count": 66,
"id": "129",
"metadata": {
"execution": {
"iopub.execute_input": "2026-06-30T22:32:55.889796Z",
"iopub.status.busy": "2026-06-30T22:32:55.889628Z",
"iopub.status.idle": "2026-06-30T22:32:55.938774Z",
"shell.execute_reply": "2026-06-30T22:32:55.937896Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\u001b[1;36mFree parameters for both structures \u001b[0m\u001b[1;36m(\u001b[0m\u001b[1;36mπ§© data blocks\u001b[0m\u001b[1;36m)\u001b[0m\u001b[1;36m and experiments \u001b[0m\u001b[1;36m(\u001b[0m\u001b[1;36mπ¬ data blocks\u001b[0m\u001b[1;36m)\u001b[0m\n"
]
},
{
"data": {
"text/html": [
" | datablock | category | entry | parameter | value | uncertainty | min | max | units |
|---|
| 1 | lbco | cell | | length_a | 3.89091 | 0.00005 | -inf | inf | Γ
|
|---|
| 2 | lbco | atom_site | La | adp_iso | 0.50000 | | -inf | inf | Γ
Β² |
|---|
| 3 | lbco | atom_site | Ba | adp_iso | 0.50000 | | -inf | inf | Γ
Β² |
|---|
| 4 | lbco | atom_site | Co | adp_iso | 0.50000 | | -inf | inf | Γ
Β² |
|---|
| 5 | lbco | atom_site | O | adp_iso | 0.50000 | | -inf | inf | Γ
Β² |
|---|
| 6 | hrpt | linked_structure | lbco | scale | 7.21199 | 0.04057 | -inf | inf | |
|---|
| 7 | hrpt | peak | | broad_gauss_u | 0.08026 | 0.00472 | -inf | inf | degΒ² |
|---|
| 8 | hrpt | peak | | broad_gauss_v | -0.10293 | 0.01036 | -inf | inf | degΒ² |
|---|
| 9 | hrpt | peak | | broad_gauss_w | 0.10766 | 0.00515 | -inf | inf | degΒ² |
|---|
| 10 | hrpt | peak | | broad_lorentz_y | 0.08933 | 0.00320 | -inf | inf | deg |
|---|
| 11 | hrpt | instrument | | twotheta_offset | 0.62314 | 0.00167 | -inf | inf | deg |
|---|
| 12 | hrpt | background | 10 | intensity | 167.51669 | 2.03112 | -inf | inf | |
|---|
| 13 | hrpt | background | 30 | intensity | 166.76268 | 1.47937 | -inf | inf | |
|---|
| 14 | hrpt | background | 50 | intensity | 170.83305 | 1.08080 | -inf | inf | |
|---|
| 15 | hrpt | background | 110 | intensity | 172.25458 | 0.96599 | -inf | inf | |
|---|
| 16 | hrpt | background | 165 | intensity | 180.64054 | 1.27368 | -inf | inf | |
|---|
"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"project.display.parameters.free()"
]
},
{
"cell_type": "markdown",
"id": "130",
"metadata": {},
"source": [
"#### Run Fitting"
]
},
{
"cell_type": "code",
"execution_count": 67,
"id": "131",
"metadata": {
"execution": {
"iopub.execute_input": "2026-06-30T22:32:55.940453Z",
"iopub.status.busy": "2026-06-30T22:32:55.940288Z",
"iopub.status.idle": "2026-06-30T22:33:04.451566Z",
"shell.execute_reply": "2026-06-30T22:33:04.450879Z"
}
},
"outputs": [
{
"data": {
"text/html": [],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"application/javascript": [
"\n",
"(function() {\n",
" const button = document.getElementById('ed-fit-stop-fa78f3c7747e4be5a9064f2e245676f7-button');\n",
" const status = document.getElementById('ed-fit-stop-fa78f3c7747e4be5a9064f2e245676f7-status');\n",
" const kernelId = '';\n",
" if (!button) {\n",
" return;\n",
" }\n",
"\n",
" function setStatus(text) {\n",
" if (status) {\n",
" status.textContent = text;\n",
" }\n",
" }\n",
"\n",
" function pageConfig() {\n",
" const element = document.getElementById('jupyter-config-data');\n",
" if (!element || !element.textContent) {\n",
" return {};\n",
" }\n",
" try {\n",
" return JSON.parse(element.textContent);\n",
" } catch (error) {\n",
" return {};\n",
" }\n",
" }\n",
"\n",
" function baseUrl(config) {\n",
" const configured = config.baseUrl || config.base_url ||\n",
" (window.Jupyter && Jupyter.notebook && Jupyter.notebook.base_url);\n",
" if (configured) {\n",
" return configured.endsWith('/') ? configured : configured + '/';\n",
" }\n",
" const markers = ['/lab/', '/notebooks/', '/tree/'];\n",
" for (const marker of markers) {\n",
" const index = window.location.pathname.indexOf(marker);\n",
" if (index >= 0) {\n",
" return window.location.pathname.slice(0, index + 1);\n",
" }\n",
" }\n",
" return '/';\n",
" }\n",
"\n",
" function token(config) {\n",
" return config.token || new URLSearchParams(window.location.search).get('token') || '';\n",
" }\n",
"\n",
" function cookie(name) {\n",
" const prefix = name + '=';\n",
" for (const part of document.cookie.split(';')) {\n",
" const trimmed = part.trim();\n",
" if (trimmed.startsWith(prefix)) {\n",
" return decodeURIComponent(trimmed.slice(prefix.length));\n",
" }\n",
" }\n",
" return '';\n",
" }\n",
"\n",
" function notebookPath() {\n",
" const decoded = decodeURIComponent(window.location.pathname);\n",
" const markers = ['/lab/tree/', '/notebooks/', '/tree/'];\n",
" for (const marker of markers) {\n",
" const index = decoded.indexOf(marker);\n",
" if (index >= 0) {\n",
" return decoded.slice(index + marker.length);\n",
" }\n",
" }\n",
" return '';\n",
" }\n",
"\n",
" async function kernelFromSessions(config) {\n",
" const url = new URL(baseUrl(config) + 'api/sessions', window.location.origin);\n",
" const authToken = token(config);\n",
" if (authToken) {\n",
" url.searchParams.set('token', authToken);\n",
" }\n",
" const response = await fetch(url, {credentials: 'same-origin'});\n",
" if (!response.ok) {\n",
" return '';\n",
" }\n",
" const sessions = await response.json();\n",
" const path = notebookPath();\n",
" const session = sessions.find((item) => item.path === path) || sessions[0];\n",
" return session && session.kernel ? session.kernel.id : '';\n",
" }\n",
"\n",
" async function interruptKernel(config, resolvedKernelId) {\n",
" const url = new URL(\n",
" baseUrl(config) + 'api/kernels/' + resolvedKernelId + '/interrupt',\n",
" window.location.origin\n",
" );\n",
" const authToken = token(config);\n",
" if (authToken) {\n",
" url.searchParams.set('token', authToken);\n",
" }\n",
" const xsrfToken = cookie('_xsrf');\n",
" const headers = {};\n",
" if (xsrfToken) {\n",
" headers['X-XSRFToken'] = xsrfToken;\n",
" }\n",
" const response = await fetch(url, {\n",
" method: 'POST',\n",
" credentials: 'same-origin',\n",
" headers: headers\n",
" });\n",
" return response.ok;\n",
" }\n",
"\n",
" button.addEventListener('click', async function() {\n",
" button.disabled = true;\n",
" setStatus('Stopping...');\n",
" const config = pageConfig();\n",
" try {\n",
" const resolvedKernelId = kernelId || await kernelFromSessions(config);\n",
" if (!resolvedKernelId) {\n",
" throw new Error('Could not resolve the current kernel id.');\n",
" }\n",
" const interrupted = await interruptKernel(config, resolvedKernelId);\n",
" if (!interrupted) {\n",
" throw new Error('Jupyter Server rejected the interrupt request.');\n",
" }\n",
" setStatus('Interrupt sent...');\n",
" } catch (error) {\n",
" button.disabled = false;\n",
" setStatus('Use Kernel > Interrupt to stop this fit.');\n",
" }\n",
" });\n",
"})();\n"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"\u001b[1;36mStandard fitting\u001b[0m\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"π Using experiment π¬ \u001b[32m'hrpt'\u001b[0m for \u001b[32m'single'\u001b[0m fitting\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"π Starting fit process with \u001b[32m'lmfit \u001b[0m\u001b[32m(\u001b[0m\u001b[32mleastsq\u001b[0m\u001b[32m)\u001b[0m\u001b[32m'\u001b[0m\u001b[33m...\u001b[0m\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"π Goodness-of-fit progress:\n"
]
},
{
"data": {
"text/html": [
" | iteration | time (s) | ΟΒ² | change / status |
|---|
| 1 | 1 | 0.04 | 2.85 | |
|---|
| 2 | 28 | 1.01 | 2.28 | 19.9% β |
|---|
| 3 | 45 | 1.62 | 1.62 | 28.9% β |
|---|
| 4 | 62 | 2.30 | 1.47 | 9.6% β |
|---|
| 5 | 79 | 2.91 | 1.36 | 7.0% β |
|---|
| 6 | 97 | 3.56 | 1.29 | 5.4% β |
|---|
| 7 | 204 | 7.82 | 1.29 | |
|---|
"
],
"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;36m1.29\u001b[0m at iteration \u001b[1;36m187\u001b[0m\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"β
Fitting complete.\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"\u001b[1;36mSaving project π¦ \u001b[0m\u001b[32m'lbco_hrpt'\u001b[0m\u001b[1;36m to \u001b[0m\u001b[32m'../../../projects/refine-lbco-hrpt-report'\u001b[0m\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"βββ π project.edi\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"βββ π structures/\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"β βββ π lbco.edi\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"βββ π experiments/\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"β βββ π hrpt.edi\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"βββ π analysis/\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"β βββ π analysis.edi\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"βββ π reports/\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
" βββ π lbco_hrpt.html\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"βοΈ Settings used:\n"
]
},
{
"data": {
"text/html": [
" | Name | Value | Description |
|---|
| 1 | max_iterations | 1000 | Maximum solver iterations. |
|---|
"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"π Least-squares fit results:\n"
]
},
{
"data": {
"text/html": [
" | Metric | Value |
|---|
| 1 | π§ͺ Minimizer | lmfit |
|---|
| 2 | β
Overall status | success |
|---|
| 3 | β±οΈ Fitting time (seconds) | 7.82 |
|---|
| 4 | π Iterations | 201 |
|---|
| 5 | π Goodness-of-fit (reduced ΟΒ²) | 1.29 |
|---|
| 6 | π R-factor (Rf, %) | 5.63 |
|---|
| 7 | π R-factor squared (RfΒ², %) | 5.27 |
|---|
| 8 | π Weighted R-factor (wR, %) | 4.41 |
|---|
"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"π Refined parameters:\n"
]
},
{
"data": {
"text/html": [
" | datablock | category | entry | parameter | units | start | value | s.u. | change |
|---|
| 1 | lbco | cell | | length_a | Γ
| 3.8909 | 3.8909 | 0.0000 | 0.00 % β |
|---|
| 2 | lbco | atom_site | La | adp_iso | Γ
Β² | 0.5000 | 0.5051 | 1212.9478 | 1.02 % β |
|---|
| 3 | lbco | atom_site | Ba | adp_iso | Γ
Β² | 0.5000 | 0.5048 | 1971.1382 | 0.96 % β |
|---|
| 4 | lbco | atom_site | Co | adp_iso | Γ
Β² | 0.5000 | 0.2371 | 0.0612 | 52.59 % β |
|---|
| 5 | lbco | atom_site | O | adp_iso | Γ
Β² | 0.5000 | 1.3935 | 0.0167 | 178.71 % β |
|---|
| 6 | hrpt | linked_structure | lbco | scale | | 7.2120 | 9.1350 | 0.0641 | 26.66 % β |
|---|
| 7 | hrpt | peak | | broad_gauss_u | degΒ² | 0.0803 | 0.0816 | 0.0031 | 1.63 % β |
|---|
| 8 | hrpt | peak | | broad_gauss_v | degΒ² | -0.1029 | -0.1159 | 0.0067 | 12.62 % β |
|---|
| 9 | hrpt | peak | | broad_gauss_w | degΒ² | 0.1077 | 0.1204 | 0.0033 | 11.88 % β |
|---|
| 10 | hrpt | peak | | broad_lorentz_y | deg | 0.0893 | 0.0844 | 0.0021 | 5.47 % β |
|---|
| 11 | hrpt | instrument | | twotheta_offset | deg | 0.6231 | 0.6226 | 0.0010 | 0.09 % β |
|---|
| 12 | hrpt | background | 10 | intensity | | 167.5167 | 168.5585 | 1.3671 | 0.62 % β |
|---|
| 13 | hrpt | background | 30 | intensity | | 166.7627 | 164.3357 | 0.9992 | 1.46 % β |
|---|
| 14 | hrpt | background | 50 | intensity | | 170.8330 | 166.8881 | 0.7388 | 2.31 % β |
|---|
| 15 | hrpt | background | 110 | intensity | | 172.2546 | 175.4004 | 0.6571 | 1.83 % β |
|---|
| 16 | hrpt | background | 165 | intensity | | 180.6405 | 174.2811 | 0.9113 | 3.52 % β |
|---|
"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
" β’ start = parameter value before refinement
β’ value = refined value from least-squares minimization
β’ s.u. = standard uncertainty (one sigma), from the covariance matrix
β’ change = relative change from start, in %; β = increase, β = decrease
"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"β οΈ Red s.u.: exceeds the refined value (consider adding constraints)
"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"project.analysis.fit()\n",
"project.display.fit.results()"
]
},
{
"cell_type": "markdown",
"id": "132",
"metadata": {},
"source": [
"#### Display Pattern"
]
},
{
"cell_type": "code",
"execution_count": 68,
"id": "133",
"metadata": {
"execution": {
"iopub.execute_input": "2026-06-30T22:33:04.453450Z",
"iopub.status.busy": "2026-06-30T22:33:04.453298Z",
"iopub.status.idle": "2026-06-30T22:33:04.510153Z",
"shell.execute_reply": "2026-06-30T22:33:04.509257Z"
}
},
"outputs": [
{
"data": {
"text/html": [
""
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"project.display.pattern(expt_name='hrpt')"
]
},
{
"cell_type": "code",
"execution_count": 69,
"id": "134",
"metadata": {
"execution": {
"iopub.execute_input": "2026-06-30T22:33:04.514353Z",
"iopub.status.busy": "2026-06-30T22:33:04.514115Z",
"iopub.status.idle": "2026-06-30T22:33:04.569397Z",
"shell.execute_reply": "2026-06-30T22:33:04.568267Z"
}
},
"outputs": [
{
"data": {
"text/html": [
""
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"project.display.pattern(expt_name='hrpt', x_min=38, x_max=41)"
]
},
{
"cell_type": "markdown",
"id": "135",
"metadata": {},
"source": [
"### Perform Fit 4/5\n",
"\n",
"#### Set Constraints\n",
"\n",
"Set aliases for parameters."
]
},
{
"cell_type": "code",
"execution_count": 70,
"id": "136",
"metadata": {
"execution": {
"iopub.execute_input": "2026-06-30T22:33:04.570902Z",
"iopub.status.busy": "2026-06-30T22:33:04.570748Z",
"iopub.status.idle": "2026-06-30T22:33:04.574718Z",
"shell.execute_reply": "2026-06-30T22:33:04.573794Z"
}
},
"outputs": [],
"source": [
"project.analysis.aliases.create(\n",
" id='biso_La',\n",
" param=project.structures['lbco'].atom_sites['La'].adp_iso,\n",
")\n",
"project.analysis.aliases.create(\n",
" id='biso_Ba',\n",
" param=project.structures['lbco'].atom_sites['Ba'].adp_iso,\n",
")"
]
},
{
"cell_type": "markdown",
"id": "137",
"metadata": {},
"source": [
"Set constraints."
]
},
{
"cell_type": "code",
"execution_count": 71,
"id": "138",
"metadata": {
"execution": {
"iopub.execute_input": "2026-06-30T22:33:04.576210Z",
"iopub.status.busy": "2026-06-30T22:33:04.576046Z",
"iopub.status.idle": "2026-06-30T22:33:04.578973Z",
"shell.execute_reply": "2026-06-30T22:33:04.578367Z"
}
},
"outputs": [],
"source": [
"project.analysis.constraints.create(expression='biso_Ba = biso_La')"
]
},
{
"cell_type": "markdown",
"id": "139",
"metadata": {},
"source": [
"Show defined constraints."
]
},
{
"cell_type": "code",
"execution_count": 72,
"id": "140",
"metadata": {
"execution": {
"iopub.execute_input": "2026-06-30T22:33:04.580488Z",
"iopub.status.busy": "2026-06-30T22:33:04.580345Z",
"iopub.status.idle": "2026-06-30T22:33:04.587309Z",
"shell.execute_reply": "2026-06-30T22:33:04.586507Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\u001b[1;36mUser defined constraints\u001b[0m\n"
]
},
{
"data": {
"text/html": [
" | id | expression |
|---|
| 1 | biso_Ba | biso_Ba = biso_La |
|---|
"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"Constraints enabled: \u001b[3;92mTrue\u001b[0m\n"
]
}
],
"source": [
"project.analysis.constraints.show()"
]
},
{
"cell_type": "markdown",
"id": "141",
"metadata": {},
"source": [
"Show free parameters."
]
},
{
"cell_type": "code",
"execution_count": 73,
"id": "142",
"metadata": {
"execution": {
"iopub.execute_input": "2026-06-30T22:33:04.588810Z",
"iopub.status.busy": "2026-06-30T22:33:04.588622Z",
"iopub.status.idle": "2026-06-30T22:33:04.645802Z",
"shell.execute_reply": "2026-06-30T22:33:04.644866Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\u001b[1;36mFree parameters for both structures \u001b[0m\u001b[1;36m(\u001b[0m\u001b[1;36mπ§© data blocks\u001b[0m\u001b[1;36m)\u001b[0m\u001b[1;36m and experiments \u001b[0m\u001b[1;36m(\u001b[0m\u001b[1;36mπ¬ data blocks\u001b[0m\u001b[1;36m)\u001b[0m\n"
]
},
{
"data": {
"text/html": [
" | datablock | category | entry | parameter | value | uncertainty | min | max | units |
|---|
| 1 | lbco | cell | | length_a | 3.89087 | 0.00004 | -inf | inf | Γ
|
|---|
| 2 | lbco | atom_site | La | adp_iso | 0.50509 | 1212.94783 | -inf | inf | Γ
Β² |
|---|
| 3 | lbco | atom_site | Ba | adp_iso | 0.50481 | 1971.13815 | -inf | inf | Γ
Β² |
|---|
| 4 | lbco | atom_site | Co | adp_iso | 0.23707 | 0.06119 | -inf | inf | Γ
Β² |
|---|
| 5 | lbco | atom_site | O | adp_iso | 1.39354 | 0.01668 | -inf | inf | Γ
Β² |
|---|
| 6 | hrpt | linked_structure | lbco | scale | 9.13503 | 0.06407 | -inf | inf | |
|---|
| 7 | hrpt | peak | | broad_gauss_u | 0.08157 | 0.00314 | -inf | inf | degΒ² |
|---|
| 8 | hrpt | peak | | broad_gauss_v | -0.11592 | 0.00672 | -inf | inf | degΒ² |
|---|
| 9 | hrpt | peak | | broad_gauss_w | 0.12045 | 0.00328 | -inf | inf | degΒ² |
|---|
| 10 | hrpt | peak | | broad_lorentz_y | 0.08445 | 0.00215 | -inf | inf | deg |
|---|
| 11 | hrpt | instrument | | twotheta_offset | 0.62258 | 0.00104 | -inf | inf | deg |
|---|
| 12 | hrpt | background | 10 | intensity | 168.55849 | 1.36709 | -inf | inf | |
|---|
| 13 | hrpt | background | 30 | intensity | 164.33571 | 0.99917 | -inf | inf | |
|---|
| 14 | hrpt | background | 50 | intensity | 166.88814 | 0.73884 | -inf | inf | |
|---|
| 15 | hrpt | background | 110 | intensity | 175.40040 | 0.65707 | -inf | inf | |
|---|
| 16 | hrpt | background | 165 | intensity | 174.28113 | 0.91128 | -inf | inf | |
|---|
"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"project.display.parameters.free()"
]
},
{
"cell_type": "markdown",
"id": "143",
"metadata": {},
"source": [
"#### Run Fitting"
]
},
{
"cell_type": "code",
"execution_count": 74,
"id": "144",
"metadata": {
"execution": {
"iopub.execute_input": "2026-06-30T22:33:04.647350Z",
"iopub.status.busy": "2026-06-30T22:33:04.647182Z",
"iopub.status.idle": "2026-06-30T22:33:06.187693Z",
"shell.execute_reply": "2026-06-30T22:33:06.186884Z"
}
},
"outputs": [
{
"data": {
"text/html": [],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"application/javascript": [
"\n",
"(function() {\n",
" const button = document.getElementById('ed-fit-stop-1a98d9ccca8c4385bf9235e00d879051-button');\n",
" const status = document.getElementById('ed-fit-stop-1a98d9ccca8c4385bf9235e00d879051-status');\n",
" const kernelId = '';\n",
" if (!button) {\n",
" return;\n",
" }\n",
"\n",
" function setStatus(text) {\n",
" if (status) {\n",
" status.textContent = text;\n",
" }\n",
" }\n",
"\n",
" function pageConfig() {\n",
" const element = document.getElementById('jupyter-config-data');\n",
" if (!element || !element.textContent) {\n",
" return {};\n",
" }\n",
" try {\n",
" return JSON.parse(element.textContent);\n",
" } catch (error) {\n",
" return {};\n",
" }\n",
" }\n",
"\n",
" function baseUrl(config) {\n",
" const configured = config.baseUrl || config.base_url ||\n",
" (window.Jupyter && Jupyter.notebook && Jupyter.notebook.base_url);\n",
" if (configured) {\n",
" return configured.endsWith('/') ? configured : configured + '/';\n",
" }\n",
" const markers = ['/lab/', '/notebooks/', '/tree/'];\n",
" for (const marker of markers) {\n",
" const index = window.location.pathname.indexOf(marker);\n",
" if (index >= 0) {\n",
" return window.location.pathname.slice(0, index + 1);\n",
" }\n",
" }\n",
" return '/';\n",
" }\n",
"\n",
" function token(config) {\n",
" return config.token || new URLSearchParams(window.location.search).get('token') || '';\n",
" }\n",
"\n",
" function cookie(name) {\n",
" const prefix = name + '=';\n",
" for (const part of document.cookie.split(';')) {\n",
" const trimmed = part.trim();\n",
" if (trimmed.startsWith(prefix)) {\n",
" return decodeURIComponent(trimmed.slice(prefix.length));\n",
" }\n",
" }\n",
" return '';\n",
" }\n",
"\n",
" function notebookPath() {\n",
" const decoded = decodeURIComponent(window.location.pathname);\n",
" const markers = ['/lab/tree/', '/notebooks/', '/tree/'];\n",
" for (const marker of markers) {\n",
" const index = decoded.indexOf(marker);\n",
" if (index >= 0) {\n",
" return decoded.slice(index + marker.length);\n",
" }\n",
" }\n",
" return '';\n",
" }\n",
"\n",
" async function kernelFromSessions(config) {\n",
" const url = new URL(baseUrl(config) + 'api/sessions', window.location.origin);\n",
" const authToken = token(config);\n",
" if (authToken) {\n",
" url.searchParams.set('token', authToken);\n",
" }\n",
" const response = await fetch(url, {credentials: 'same-origin'});\n",
" if (!response.ok) {\n",
" return '';\n",
" }\n",
" const sessions = await response.json();\n",
" const path = notebookPath();\n",
" const session = sessions.find((item) => item.path === path) || sessions[0];\n",
" return session && session.kernel ? session.kernel.id : '';\n",
" }\n",
"\n",
" async function interruptKernel(config, resolvedKernelId) {\n",
" const url = new URL(\n",
" baseUrl(config) + 'api/kernels/' + resolvedKernelId + '/interrupt',\n",
" window.location.origin\n",
" );\n",
" const authToken = token(config);\n",
" if (authToken) {\n",
" url.searchParams.set('token', authToken);\n",
" }\n",
" const xsrfToken = cookie('_xsrf');\n",
" const headers = {};\n",
" if (xsrfToken) {\n",
" headers['X-XSRFToken'] = xsrfToken;\n",
" }\n",
" const response = await fetch(url, {\n",
" method: 'POST',\n",
" credentials: 'same-origin',\n",
" headers: headers\n",
" });\n",
" return response.ok;\n",
" }\n",
"\n",
" button.addEventListener('click', async function() {\n",
" button.disabled = true;\n",
" setStatus('Stopping...');\n",
" const config = pageConfig();\n",
" try {\n",
" const resolvedKernelId = kernelId || await kernelFromSessions(config);\n",
" if (!resolvedKernelId) {\n",
" throw new Error('Could not resolve the current kernel id.');\n",
" }\n",
" const interrupted = await interruptKernel(config, resolvedKernelId);\n",
" if (!interrupted) {\n",
" throw new Error('Jupyter Server rejected the interrupt request.');\n",
" }\n",
" setStatus('Interrupt sent...');\n",
" } catch (error) {\n",
" button.disabled = false;\n",
" setStatus('Use Kernel > Interrupt to stop this fit.');\n",
" }\n",
" });\n",
"})();\n"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"\u001b[1;36mStandard fitting\u001b[0m\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"π Using experiment π¬ \u001b[32m'hrpt'\u001b[0m for \u001b[32m'single'\u001b[0m fitting\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"π Starting fit process with \u001b[32m'lmfit \u001b[0m\u001b[32m(\u001b[0m\u001b[32mleastsq\u001b[0m\u001b[32m)\u001b[0m\u001b[32m'\u001b[0m\u001b[33m...\u001b[0m\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"π Goodness-of-fit progress:\n"
]
},
{
"data": {
"text/html": [
" | iteration | time (s) | ΟΒ² | change / status |
|---|
| 1 | 1 | 0.04 | 1.29 | |
|---|
| 2 | 20 | 0.78 | 1.29 | |
|---|
"
],
"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;36m1.29\u001b[0m at iteration \u001b[1;36m19\u001b[0m\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"β
Fitting complete.\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"\u001b[1;36mSaving project π¦ \u001b[0m\u001b[32m'lbco_hrpt'\u001b[0m\u001b[1;36m to \u001b[0m\u001b[32m'../../../projects/refine-lbco-hrpt-report'\u001b[0m\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"βββ π project.edi\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"βββ π structures/\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"β βββ π lbco.edi\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"βββ π experiments/\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"β βββ π hrpt.edi\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"βββ π analysis/\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"β βββ π analysis.edi\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"βββ π reports/\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
" βββ π lbco_hrpt.html\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"βοΈ Settings used:\n"
]
},
{
"data": {
"text/html": [
" | Name | Value | Description |
|---|
| 1 | max_iterations | 1000 | Maximum solver iterations. |
|---|
"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"π Least-squares fit results:\n"
]
},
{
"data": {
"text/html": [
" | Metric | Value |
|---|
| 1 | π§ͺ Minimizer | lmfit |
|---|
| 2 | β
Overall status | success |
|---|
| 3 | β±οΈ Fitting time (seconds) | 0.78 |
|---|
| 4 | π Iterations | 17 |
|---|
| 5 | π Goodness-of-fit (reduced ΟΒ²) | 1.29 |
|---|
| 6 | π R-factor (Rf, %) | 5.63 |
|---|
| 7 | π R-factor squared (RfΒ², %) | 5.27 |
|---|
| 8 | π Weighted R-factor (wR, %) | 4.41 |
|---|
"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"π Refined parameters:\n"
]
},
{
"data": {
"text/html": [
" | datablock | category | entry | parameter | units | start | value | s.u. | change |
|---|
| 1 | lbco | cell | | length_a | Γ
| 3.8909 | 3.8909 | 0.0000 | 0.00 % β |
|---|
| 2 | lbco | atom_site | La | adp_iso | Γ
Β² | 0.5051 | 0.5051 | 0.0278 | 0.00 % β |
|---|
| 3 | lbco | atom_site | Co | adp_iso | Γ
Β² | 0.2371 | 0.2370 | 0.0564 | 0.03 % β |
|---|
| 4 | lbco | atom_site | O | adp_iso | Γ
Β² | 1.3935 | 1.3935 | 0.0160 | 0.00 % β |
|---|
| 5 | hrpt | linked_structure | lbco | scale | | 9.1350 | 9.1351 | 0.0538 | 0.00 % β |
|---|
| 6 | hrpt | peak | | broad_gauss_u | degΒ² | 0.0816 | 0.0816 | 0.0031 | 0.00 % β |
|---|
| 7 | hrpt | peak | | broad_gauss_v | degΒ² | -0.1159 | -0.1159 | 0.0066 | 0.00 % β |
|---|
| 8 | hrpt | peak | | broad_gauss_w | degΒ² | 0.1204 | 0.1204 | 0.0032 | 0.00 % β |
|---|
| 9 | hrpt | peak | | broad_lorentz_y | deg | 0.0844 | 0.0844 | 0.0021 | 0.00 % β |
|---|
| 10 | hrpt | instrument | | twotheta_offset | deg | 0.6226 | 0.6226 | 0.0010 | 0.00 % β |
|---|
| 11 | hrpt | background | 10 | intensity | | 168.5585 | 168.5585 | 1.3669 | 0.00 % β |
|---|
| 12 | hrpt | background | 30 | intensity | | 164.3357 | 164.3357 | 0.9990 | 0.00 % β |
|---|
| 13 | hrpt | background | 50 | intensity | | 166.8881 | 166.8881 | 0.7386 | 0.00 % β |
|---|
| 14 | hrpt | background | 110 | intensity | | 175.4004 | 175.4006 | 0.6488 | 0.00 % β |
|---|
| 15 | hrpt | background | 165 | intensity | | 174.2811 | 174.2812 | 0.8944 | 0.00 % β |
|---|
"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
" β’ start = parameter value before refinement
β’ value = refined value from least-squares minimization
β’ s.u. = standard uncertainty (one sigma), from the covariance matrix
β’ change = relative change from start, in %; β = increase, β = decrease
"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"project.analysis.fit()\n",
"project.display.fit.results()"
]
},
{
"cell_type": "markdown",
"id": "145",
"metadata": {},
"source": [
"#### Display Pattern"
]
},
{
"cell_type": "code",
"execution_count": 75,
"id": "146",
"metadata": {
"execution": {
"iopub.execute_input": "2026-06-30T22:33:06.189305Z",
"iopub.status.busy": "2026-06-30T22:33:06.189139Z",
"iopub.status.idle": "2026-06-30T22:33:06.258460Z",
"shell.execute_reply": "2026-06-30T22:33:06.257732Z"
}
},
"outputs": [
{
"data": {
"text/html": [
""
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"project.display.pattern(expt_name='hrpt')"
]
},
{
"cell_type": "code",
"execution_count": 76,
"id": "147",
"metadata": {
"execution": {
"iopub.execute_input": "2026-06-30T22:33:06.262584Z",
"iopub.status.busy": "2026-06-30T22:33:06.262421Z",
"iopub.status.idle": "2026-06-30T22:33:06.328068Z",
"shell.execute_reply": "2026-06-30T22:33:06.327410Z"
}
},
"outputs": [
{
"data": {
"text/html": [
""
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"project.display.pattern(expt_name='hrpt', x_min=38, x_max=41)"
]
},
{
"cell_type": "markdown",
"id": "148",
"metadata": {},
"source": [
"### Perform Fit 5/5\n",
"\n",
"#### Set Constraints\n",
"\n",
"Set more aliases for parameters."
]
},
{
"cell_type": "code",
"execution_count": 77,
"id": "149",
"metadata": {
"execution": {
"iopub.execute_input": "2026-06-30T22:33:06.329816Z",
"iopub.status.busy": "2026-06-30T22:33:06.329654Z",
"iopub.status.idle": "2026-06-30T22:33:06.333256Z",
"shell.execute_reply": "2026-06-30T22:33:06.332439Z"
}
},
"outputs": [],
"source": [
"project.analysis.aliases.create(\n",
" id='occ_La',\n",
" param=project.structures['lbco'].atom_sites['La'].occupancy,\n",
")\n",
"project.analysis.aliases.create(\n",
" id='occ_Ba',\n",
" param=project.structures['lbco'].atom_sites['Ba'].occupancy,\n",
")"
]
},
{
"cell_type": "markdown",
"id": "150",
"metadata": {},
"source": [
"Set more constraints."
]
},
{
"cell_type": "code",
"execution_count": 78,
"id": "151",
"metadata": {
"execution": {
"iopub.execute_input": "2026-06-30T22:33:06.334890Z",
"iopub.status.busy": "2026-06-30T22:33:06.334734Z",
"iopub.status.idle": "2026-06-30T22:33:06.337585Z",
"shell.execute_reply": "2026-06-30T22:33:06.336827Z"
}
},
"outputs": [],
"source": [
"project.analysis.constraints.create(\n",
" expression='occ_Ba = 1 - occ_La',\n",
")"
]
},
{
"cell_type": "markdown",
"id": "152",
"metadata": {},
"source": [
"Show defined constraints."
]
},
{
"cell_type": "code",
"execution_count": 79,
"id": "153",
"metadata": {
"execution": {
"iopub.execute_input": "2026-06-30T22:33:06.339106Z",
"iopub.status.busy": "2026-06-30T22:33:06.338933Z",
"iopub.status.idle": "2026-06-30T22:33:06.346296Z",
"shell.execute_reply": "2026-06-30T22:33:06.345641Z"
},
"lines_to_next_cell": 2
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\u001b[1;36mUser defined constraints\u001b[0m\n"
]
},
{
"data": {
"text/html": [
" | id | expression |
|---|
| 1 | biso_Ba | biso_Ba = biso_La |
|---|
| 2 | occ_Ba | occ_Ba = 1 - occ_La |
|---|
"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"Constraints enabled: \u001b[3;92mTrue\u001b[0m\n"
]
}
],
"source": [
"project.analysis.constraints.show()"
]
},
{
"cell_type": "markdown",
"id": "154",
"metadata": {},
"source": [
"Set structure parameters to be refined."
]
},
{
"cell_type": "code",
"execution_count": 80,
"id": "155",
"metadata": {
"execution": {
"iopub.execute_input": "2026-06-30T22:33:06.348021Z",
"iopub.status.busy": "2026-06-30T22:33:06.347819Z",
"iopub.status.idle": "2026-06-30T22:33:06.350923Z",
"shell.execute_reply": "2026-06-30T22:33:06.350234Z"
}
},
"outputs": [],
"source": [
"project.structures['lbco'].atom_sites['La'].occupancy.free = True"
]
},
{
"cell_type": "markdown",
"id": "156",
"metadata": {},
"source": [
"Show free parameters after selection."
]
},
{
"cell_type": "code",
"execution_count": 81,
"id": "157",
"metadata": {
"execution": {
"iopub.execute_input": "2026-06-30T22:33:06.352862Z",
"iopub.status.busy": "2026-06-30T22:33:06.352712Z",
"iopub.status.idle": "2026-06-30T22:33:06.407115Z",
"shell.execute_reply": "2026-06-30T22:33:06.405923Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\u001b[1;36mFree parameters for both structures \u001b[0m\u001b[1;36m(\u001b[0m\u001b[1;36mπ§© data blocks\u001b[0m\u001b[1;36m)\u001b[0m\u001b[1;36m and experiments \u001b[0m\u001b[1;36m(\u001b[0m\u001b[1;36mπ¬ data blocks\u001b[0m\u001b[1;36m)\u001b[0m\n"
]
},
{
"data": {
"text/html": [
" | datablock | category | entry | parameter | value | uncertainty | min | max | units |
|---|
| 1 | lbco | cell | | length_a | 3.89087 | 0.00004 | -inf | inf | Γ
|
|---|
| 2 | lbco | atom_site | La | occupancy | 0.50000 | | -inf | inf | |
|---|
| 3 | lbco | atom_site | La | adp_iso | 0.50508 | 0.02777 | -inf | inf | Γ
Β² |
|---|
| 4 | lbco | atom_site | Co | adp_iso | 0.23699 | 0.05643 | -inf | inf | Γ
Β² |
|---|
| 5 | lbco | atom_site | O | adp_iso | 1.39355 | 0.01599 | -inf | inf | Γ
Β² |
|---|
| 6 | hrpt | linked_structure | lbco | scale | 9.13509 | 0.05380 | -inf | inf | |
|---|
| 7 | hrpt | peak | | broad_gauss_u | 0.08157 | 0.00310 | -inf | inf | degΒ² |
|---|
| 8 | hrpt | peak | | broad_gauss_v | -0.11593 | 0.00664 | -inf | inf | degΒ² |
|---|
| 9 | hrpt | peak | | broad_gauss_w | 0.12045 | 0.00325 | -inf | inf | degΒ² |
|---|
| 10 | hrpt | peak | | broad_lorentz_y | 0.08445 | 0.00214 | -inf | inf | deg |
|---|
| 11 | hrpt | instrument | | twotheta_offset | 0.62258 | 0.00103 | -inf | inf | deg |
|---|
| 12 | hrpt | background | 10 | intensity | 168.55849 | 1.36685 | -inf | inf | |
|---|
| 13 | hrpt | background | 30 | intensity | 164.33569 | 0.99900 | -inf | inf | |
|---|
| 14 | hrpt | background | 50 | intensity | 166.88808 | 0.73857 | -inf | inf | |
|---|
| 15 | hrpt | background | 110 | intensity | 175.40056 | 0.64879 | -inf | inf | |
|---|
| 16 | hrpt | background | 165 | intensity | 174.28124 | 0.89439 | -inf | inf | |
|---|
"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"project.display.parameters.free()"
]
},
{
"cell_type": "markdown",
"id": "158",
"metadata": {},
"source": [
"#### Run Fitting"
]
},
{
"cell_type": "code",
"execution_count": 82,
"id": "159",
"metadata": {
"execution": {
"iopub.execute_input": "2026-06-30T22:33:06.408886Z",
"iopub.status.busy": "2026-06-30T22:33:06.408668Z",
"iopub.status.idle": "2026-06-30T22:33:09.464146Z",
"shell.execute_reply": "2026-06-30T22:33:09.463355Z"
}
},
"outputs": [
{
"data": {
"text/html": [],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"application/javascript": [
"\n",
"(function() {\n",
" const button = document.getElementById('ed-fit-stop-584abe3c0ef94c129f277aa03fe844a4-button');\n",
" const status = document.getElementById('ed-fit-stop-584abe3c0ef94c129f277aa03fe844a4-status');\n",
" const kernelId = '';\n",
" if (!button) {\n",
" return;\n",
" }\n",
"\n",
" function setStatus(text) {\n",
" if (status) {\n",
" status.textContent = text;\n",
" }\n",
" }\n",
"\n",
" function pageConfig() {\n",
" const element = document.getElementById('jupyter-config-data');\n",
" if (!element || !element.textContent) {\n",
" return {};\n",
" }\n",
" try {\n",
" return JSON.parse(element.textContent);\n",
" } catch (error) {\n",
" return {};\n",
" }\n",
" }\n",
"\n",
" function baseUrl(config) {\n",
" const configured = config.baseUrl || config.base_url ||\n",
" (window.Jupyter && Jupyter.notebook && Jupyter.notebook.base_url);\n",
" if (configured) {\n",
" return configured.endsWith('/') ? configured : configured + '/';\n",
" }\n",
" const markers = ['/lab/', '/notebooks/', '/tree/'];\n",
" for (const marker of markers) {\n",
" const index = window.location.pathname.indexOf(marker);\n",
" if (index >= 0) {\n",
" return window.location.pathname.slice(0, index + 1);\n",
" }\n",
" }\n",
" return '/';\n",
" }\n",
"\n",
" function token(config) {\n",
" return config.token || new URLSearchParams(window.location.search).get('token') || '';\n",
" }\n",
"\n",
" function cookie(name) {\n",
" const prefix = name + '=';\n",
" for (const part of document.cookie.split(';')) {\n",
" const trimmed = part.trim();\n",
" if (trimmed.startsWith(prefix)) {\n",
" return decodeURIComponent(trimmed.slice(prefix.length));\n",
" }\n",
" }\n",
" return '';\n",
" }\n",
"\n",
" function notebookPath() {\n",
" const decoded = decodeURIComponent(window.location.pathname);\n",
" const markers = ['/lab/tree/', '/notebooks/', '/tree/'];\n",
" for (const marker of markers) {\n",
" const index = decoded.indexOf(marker);\n",
" if (index >= 0) {\n",
" return decoded.slice(index + marker.length);\n",
" }\n",
" }\n",
" return '';\n",
" }\n",
"\n",
" async function kernelFromSessions(config) {\n",
" const url = new URL(baseUrl(config) + 'api/sessions', window.location.origin);\n",
" const authToken = token(config);\n",
" if (authToken) {\n",
" url.searchParams.set('token', authToken);\n",
" }\n",
" const response = await fetch(url, {credentials: 'same-origin'});\n",
" if (!response.ok) {\n",
" return '';\n",
" }\n",
" const sessions = await response.json();\n",
" const path = notebookPath();\n",
" const session = sessions.find((item) => item.path === path) || sessions[0];\n",
" return session && session.kernel ? session.kernel.id : '';\n",
" }\n",
"\n",
" async function interruptKernel(config, resolvedKernelId) {\n",
" const url = new URL(\n",
" baseUrl(config) + 'api/kernels/' + resolvedKernelId + '/interrupt',\n",
" window.location.origin\n",
" );\n",
" const authToken = token(config);\n",
" if (authToken) {\n",
" url.searchParams.set('token', authToken);\n",
" }\n",
" const xsrfToken = cookie('_xsrf');\n",
" const headers = {};\n",
" if (xsrfToken) {\n",
" headers['X-XSRFToken'] = xsrfToken;\n",
" }\n",
" const response = await fetch(url, {\n",
" method: 'POST',\n",
" credentials: 'same-origin',\n",
" headers: headers\n",
" });\n",
" return response.ok;\n",
" }\n",
"\n",
" button.addEventListener('click', async function() {\n",
" button.disabled = true;\n",
" setStatus('Stopping...');\n",
" const config = pageConfig();\n",
" try {\n",
" const resolvedKernelId = kernelId || await kernelFromSessions(config);\n",
" if (!resolvedKernelId) {\n",
" throw new Error('Could not resolve the current kernel id.');\n",
" }\n",
" const interrupted = await interruptKernel(config, resolvedKernelId);\n",
" if (!interrupted) {\n",
" throw new Error('Jupyter Server rejected the interrupt request.');\n",
" }\n",
" setStatus('Interrupt sent...');\n",
" } catch (error) {\n",
" button.disabled = false;\n",
" setStatus('Use Kernel > Interrupt to stop this fit.');\n",
" }\n",
" });\n",
"})();\n"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"\u001b[1;36mStandard fitting\u001b[0m\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"π Using experiment π¬ \u001b[32m'hrpt'\u001b[0m for \u001b[32m'single'\u001b[0m fitting\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"π Starting fit process with \u001b[32m'lmfit \u001b[0m\u001b[32m(\u001b[0m\u001b[32mleastsq\u001b[0m\u001b[32m)\u001b[0m\u001b[32m'\u001b[0m\u001b[33m...\u001b[0m\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"π Goodness-of-fit progress:\n"
]
},
{
"data": {
"text/html": [
" | iteration | time (s) | ΟΒ² | change / status |
|---|
| 1 | 1 | 0.04 | 1.29 | |
|---|
| 2 | 55 | 2.01 | 1.28 | |
|---|
"
],
"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;36m1.28\u001b[0m at iteration \u001b[1;36m54\u001b[0m\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"β
Fitting complete.\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"\u001b[1;36mSaving project π¦ \u001b[0m\u001b[32m'lbco_hrpt'\u001b[0m\u001b[1;36m to \u001b[0m\u001b[32m'../../../projects/refine-lbco-hrpt-report'\u001b[0m\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"βββ π project.edi\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"βββ π structures/\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"β βββ π lbco.edi\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"βββ π experiments/\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"β βββ π hrpt.edi\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"βββ π analysis/\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"β βββ π analysis.edi\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"βββ π reports/\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
" βββ π lbco_hrpt.html\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"βοΈ Settings used:\n"
]
},
{
"data": {
"text/html": [
" | Name | Value | Description |
|---|
| 1 | max_iterations | 1000 | Maximum solver iterations. |
|---|
"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"π Least-squares fit results:\n"
]
},
{
"data": {
"text/html": [
" | Metric | Value |
|---|
| 1 | π§ͺ Minimizer | lmfit |
|---|
| 2 | β
Overall status | success |
|---|
| 3 | β±οΈ Fitting time (seconds) | 2.01 |
|---|
| 4 | π Iterations | 52 |
|---|
| 5 | π Goodness-of-fit (reduced ΟΒ²) | 1.28 |
|---|
| 6 | π R-factor (Rf, %) | 5.61 |
|---|
| 7 | π R-factor squared (RfΒ², %) | 5.25 |
|---|
| 8 | π Weighted R-factor (wR, %) | 4.39 |
|---|
"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"π Refined parameters:\n"
]
},
{
"data": {
"text/html": [
" | datablock | category | entry | parameter | units | start | value | s.u. | change |
|---|
| 1 | lbco | cell | | length_a | Γ
| 3.8909 | 3.8909 | 0.0000 | 0.00 % β |
|---|
| 2 | lbco | atom_site | La | occupancy | | 0.5000 | 0.5840 | 0.0203 | 16.81 % β |
|---|
| 3 | lbco | atom_site | La | adp_iso | Γ
Β² | 0.5051 | 0.5983 | 0.0355 | 18.46 % β |
|---|
| 4 | lbco | atom_site | Co | adp_iso | Γ
Β² | 0.2370 | 0.1665 | 0.0580 | 29.74 % β |
|---|
| 5 | lbco | atom_site | O | adp_iso | Γ
Β² | 1.3935 | 1.3491 | 0.0192 | 3.19 % β |
|---|
| 6 | hrpt | linked_structure | lbco | scale | | 9.1351 | 8.9057 | 0.0761 | 2.51 % β |
|---|
| 7 | hrpt | peak | | broad_gauss_u | degΒ² | 0.0816 | 0.0812 | 0.0031 | 0.43 % β |
|---|
| 8 | hrpt | peak | | broad_gauss_v | degΒ² | -0.1159 | -0.1154 | 0.0066 | 0.48 % β |
|---|
| 9 | hrpt | peak | | broad_gauss_w | degΒ² | 0.1204 | 0.1203 | 0.0032 | 0.14 % β |
|---|
| 10 | hrpt | peak | | broad_lorentz_y | deg | 0.0844 | 0.0846 | 0.0021 | 0.18 % β |
|---|
| 11 | hrpt | instrument | | twotheta_offset | deg | 0.6226 | 0.6226 | 0.0010 | 0.00 % β |
|---|
| 12 | hrpt | background | 10 | intensity | | 168.5585 | 168.9780 | 1.3666 | 0.25 % β |
|---|
| 13 | hrpt | background | 30 | intensity | | 164.3357 | 164.0535 | 0.9992 | 0.17 % β |
|---|
| 14 | hrpt | background | 50 | intensity | | 166.8881 | 166.9125 | 0.7364 | 0.01 % β |
|---|
| 15 | hrpt | background | 110 | intensity | | 175.4006 | 175.2699 | 0.6479 | 0.07 % β |
|---|
| 16 | hrpt | background | 165 | intensity | | 174.2812 | 174.5580 | 0.8935 | 0.16 % β |
|---|
"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
" β’ start = parameter value before refinement
β’ value = refined value from least-squares minimization
β’ s.u. = standard uncertainty (one sigma), from the covariance matrix
β’ change = relative change from start, in %; β = increase, β = decrease
"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"\n",
"\n",
""
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"project.analysis.fit()\n",
"project.display.fit.results()\n",
"project.display.fit.correlations()"
]
},
{
"cell_type": "markdown",
"id": "160",
"metadata": {},
"source": [
"#### Display Pattern"
]
},
{
"cell_type": "code",
"execution_count": 83,
"id": "161",
"metadata": {
"execution": {
"iopub.execute_input": "2026-06-30T22:33:09.465942Z",
"iopub.status.busy": "2026-06-30T22:33:09.465711Z",
"iopub.status.idle": "2026-06-30T22:33:09.536566Z",
"shell.execute_reply": "2026-06-30T22:33:09.535628Z"
}
},
"outputs": [
{
"data": {
"text/html": [
""
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"project.display.pattern(expt_name='hrpt')"
]
},
{
"cell_type": "code",
"execution_count": 84,
"id": "162",
"metadata": {
"execution": {
"iopub.execute_input": "2026-06-30T22:33:09.540647Z",
"iopub.status.busy": "2026-06-30T22:33:09.540470Z",
"iopub.status.idle": "2026-06-30T22:33:09.618408Z",
"shell.execute_reply": "2026-06-30T22:33:09.617577Z"
}
},
"outputs": [
{
"data": {
"text/html": [
""
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"project.display.pattern(expt_name='hrpt', x_min=38, x_max=41)"
]
},
{
"cell_type": "markdown",
"id": "163",
"metadata": {},
"source": [
"#### Display Structure"
]
},
{
"cell_type": "code",
"execution_count": 85,
"id": "164",
"metadata": {
"execution": {
"iopub.execute_input": "2026-06-30T22:33:09.620268Z",
"iopub.status.busy": "2026-06-30T22:33:09.620077Z",
"iopub.status.idle": "2026-06-30T22:33:09.658308Z",
"shell.execute_reply": "2026-06-30T22:33:09.657462Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\u001b[1;36mStructure π§© \u001b[0m\u001b[32m'lbco'\u001b[0m\u001b[1;36m \u001b[0m\u001b[1;36m(\u001b[0m\u001b[1;36mAtom view type: \u001b[0m\u001b[32m'adp'\u001b[0m\u001b[1;36m)\u001b[0m\n"
]
},
{
"data": {
"text/html": [
"\n",
"
\n",
"
Loading plotβ¦
\n",
"
\n",
"
\n",
"
\n",
"
drag = rotate
wheel = zoom
right-drag = pan
\n",
"
\n",
"
\n",
"\n",
"\n",
"\n",
""
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"project.display.structure(struct_name='lbco')"
]
},
{
"cell_type": "markdown",
"id": "165",
"metadata": {},
"source": [
"## π Report\n",
"\n",
"This final section shows how to review the results of the analysis.\n",
"\n",
"By default, HTML report is generated after fitting. Here we also\n",
"show how to activate generation of CIF, TEX and PDF reports with\n",
"regular project saves.\n",
"Keep in mind, that PDF report generation requires additional\n",
"dependencies and is not that fast to be generated after each fit, so\n",
"use it with caution.\n",
"The generated report files will be saved in the `reports` folder of\n",
"the project directory."
]
},
{
"cell_type": "code",
"execution_count": 86,
"id": "166",
"metadata": {
"execution": {
"iopub.execute_input": "2026-06-30T22:33:09.660252Z",
"iopub.status.busy": "2026-06-30T22:33:09.660080Z",
"iopub.status.idle": "2026-06-30T22:33:36.825474Z",
"shell.execute_reply": "2026-06-30T22:33:36.824664Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\u001b[1;36mSaving project π¦ \u001b[0m\u001b[32m'lbco_hrpt'\u001b[0m\u001b[1;36m to \u001b[0m\u001b[32m'../../../projects/refine-lbco-hrpt-report'\u001b[0m\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"βββ π project.edi\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"βββ π structures/\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"β βββ π lbco.edi\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"βββ π experiments/\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"β βββ π hrpt.edi\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"βββ π analysis/\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"β βββ π analysis.edi\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"βββ π reports/\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
" βββ π lbco_hrpt.cif\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
" βββ π lbco_hrpt.html\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
" βββ π tex/lbco_hrpt.tex\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
" βββ π lbco_hrpt.pdf\n"
]
}
],
"source": [
"project.report.cif = True\n",
"project.report.tex = True\n",
"project.report.pdf = True\n",
"project.save()"
]
}
],
"metadata": {
"jupytext": {
"cell_metadata_filter": "-all",
"main_language": "python",
"notebook_metadata_filter": "-all"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.14.5"
}
},
"nbformat": 4,
"nbformat_minor": 5
}