Structure Refinement: Co2SiO4, D20 (T-scan, resumed)¶
This example loads a previously saved Co2SiO4 project after a
sequential refinement was stopped before all scan files were
processed. If analysis/results.csv already contains completed rows,
running project.analysis.fit() again resumes from the remaining
datasets and appends the missing results.
🛠️ Import Library¶
import easydiffraction as ed
📂 Load Project¶
Download Project¶
The returned path points directly to the saved project directory with
a partially completed sequential fit, including
analysis/results.csv.
project_dir = ed.download_data(id=37, destination='projects')
Getting data...
Data #37: Co2SiO4, D20 (ILL), T-scan (resumed)
✅ Data #37 downloaded and extracted to '../../../projects/ed-37/cosio_d20'
Load Project¶
project = ed.Project.load(project_dir)
⚠️ Skipping inactive analysis CIF sections while fitting_mode is single: ['sequential_fit'].
🚀 Perform Analysis¶
Display Structure¶
Render the Co2SiO4 structure restored from the saved project.
project.display.structure(struct_name='cosio')
Structure 🧩 'cosio' (Atom view type: 'covalent')
wheel = zoom
right-drag = pan
Resume Sequential Analysis¶
This project already stores the template experiment, sequential-fit
settings, and the partial analysis/results.csv from the previous
run. Running the fit again skips datasets already present in the CSV
and continues from the remaining files.
project.analysis.fit()
Standard fitting
📋 Using 1 experiments 🔬 from 'd20' to 'd20' for 'single' fitting
🚀 Starting fit process with 'lmfit'...
📈 Goodness-of-fit (reduced χ²) per experiment:
| experiment | χ² | iterations | status | |
|---|---|---|---|---|
| 1 | d20 | 53.08 | 243 | ✅ |
Saving project 📦 'cosio_d20' to '../../../projects/ed-37/cosio_d20'
├── 📄 project.cif
├── 📁 structures/
│ └── 📄 cosio.cif
├── 📁 experiments/
│ └── 📄 d20.cif
├── 📁 analysis/
│ ├── 📄 analysis.cif
│ └── 📄 results.csv
└── 📁 reports/
└── 📄 cosio_d20.html
Replay Fitted Datasets¶
Apply fitted parameters from the first CSV row and plot the result.
project.apply_params_from_csv(row_index=0)
project.display.pattern(expt_name='d20')
Apply fitted parameters from the last CSV row and plot the result.
project.apply_params_from_csv(row_index=-1)
project.display.pattern(expt_name='d20')
Display Parameter Evolution¶
Use the same persisted diffrn path stored in analysis/results.csv
for the x-axis.
temperature = 'diffrn.ambient_temperature'
Plot fit quality metrics vs. temperature.
project.display.fit.series(
project.analysis.fit_result.success,
versus=temperature,
)
project.display.fit.series(
project.analysis.fit_result.reduced_chi_square,
versus=temperature,
)
project.display.fit.series(
project.analysis.fit_result.iterations,
versus=temperature,
)
Omitting param plots every fitted parameter one after another.
project.display.fit.series(versus=temperature)
💾 Save Project¶
project.save_as(dir_path='projects/ed_23_cosio_d20_scan')
Saving project 📦 'cosio_d20' to '../../../projects/ed_23_cosio_d20_scan'
├── 📄 project.cif
├── 📁 structures/
│ └── 📄 cosio.cif
├── 📁 experiments/
│ └── 📄 d20.cif
├── 📁 analysis/
│ └── 📄 analysis.cif
└── 📁 reports/
└── 📄 cosio_d20.html