Skip to content

Commit 742589a

Browse files
Improve joint-fit support and add parameter-evolution plotting (#130)
* Create and use load_numeric_block method in io/ascii.py * Disable some rules for docs/ * Initial implementation of the new tutorial * Add add_from_zip_path to Experiments collection * Update data index hash * Use data from web repo * Use another dataset * Save project after every fit * Clean up * Initial implementation of plotting parameter evolution * Replace conditions category with diffrn using CIF naming * Simplify extract_metadata API and make data loading explicit * Fix fit_results to store snapshot parameters per experiment * Clean up tutorial ed-17.py duplicate plot_param calls * Fix test to use save_as() matching current ProjectInfo.path default * Add integer index support to CollectionBase.__getitem__ * Rename plot_param to plot_param_series with versus descriptor * Clean up tutorial * Update docs with new notebook * Simplify constraints API to single expression string * Fix docstring lint errors in CollectionBase.__getitem__ * New dataset and update tutorials * Update T-scan notebook * Fix Windows CI UnicodeDecodeError in script test runner
1 parent 4e71972 commit 742589a

46 files changed

Lines changed: 1799 additions & 208 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/copilot-instructions.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,13 @@
100100
case.
101101
- Don't add dependencies without asking.
102102

103+
## Tutorials
104+
105+
- Jupyter notebooks (`docs/docs/tutorials/*.ipynb`) are **generated
106+
artifacts** — never edit them by hand. Edit only the corresponding
107+
`*.py` script, then run `pixi run notebook-convert` followed by
108+
`pixi run notebook-prepare` to regenerate the notebook.
109+
103110
## Changes
104111

105112
- Before implementing any structural or design change (new categories,

docs/architecture/architecture.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -727,6 +727,12 @@ project_dir/
727727

728728
All examples below are drawn from the actual tutorials (`tutorials/`).
729729

730+
> **Notebook workflow:** Jupyter notebooks (`*.ipynb`) in
731+
> `docs/docs/tutorials/` are generated artifacts. Edit only the
732+
> corresponding `*.py` script, then run `pixi run notebook-convert`
733+
> followed by `pixi run notebook-prepare` to regenerate the notebook.
734+
> Never edit `*.ipynb` files by hand.
735+
730736
### 8.1 Project Setup
731737

732738
```python

docs/docs/tutorials/ed-13.ipynb

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,7 @@
396396
"TOF, respectively.\n",
397397
"\n",
398398
"You can set them manually, but it is more convenient to use the\n",
399-
"`get_value_from_xye_header` function from the EasyDiffraction library."
399+
"`extract_metadata` function from the EasyDiffraction library."
400400
]
401401
},
402402
{
@@ -420,11 +420,11 @@
420420
"metadata": {},
421421
"outputs": [],
422422
"source": [
423-
"project_1.experiments['sim_si'].instrument.setup_twotheta_bank = ed.get_value_from_xye_header(\n",
424-
" si_xye_path, 'two_theta'\n",
423+
"project_1.experiments['sim_si'].instrument.setup_twotheta_bank = ed.extract_metadata(\n",
424+
" si_xye_path, r'two_theta\\s*=\\s*([-+]?\\d*\\.?\\d+(?:[eE][-+]?\\d+)?)'\n",
425425
")\n",
426-
"project_1.experiments['sim_si'].instrument.calib_d_to_tof_linear = ed.get_value_from_xye_header(\n",
427-
" si_xye_path, 'DIFC'\n",
426+
"project_1.experiments['sim_si'].instrument.calib_d_to_tof_linear = ed.extract_metadata(\n",
427+
" si_xye_path, r'DIFC\\s*=\\s*([-+]?\\d*\\.?\\d+(?:[eE][-+]?\\d+)?)'\n",
428428
")"
429429
]
430430
},
@@ -1485,11 +1485,11 @@
14851485
},
14861486
"outputs": [],
14871487
"source": [
1488-
"project_2.experiments['sim_lbco'].instrument.setup_twotheta_bank = ed.get_value_from_xye_header(\n",
1489-
" lbco_xye_path, 'two_theta'\n",
1488+
"project_2.experiments['sim_lbco'].instrument.setup_twotheta_bank = ed.extract_metadata(\n",
1489+
" lbco_xye_path, r'two_theta\\s*=\\s*([-+]?\\d*\\.?\\d+(?:[eE][-+]?\\d+)?)'\n",
14901490
")\n",
1491-
"project_2.experiments['sim_lbco'].instrument.calib_d_to_tof_linear = ed.get_value_from_xye_header(\n",
1492-
" lbco_xye_path, 'DIFC'\n",
1491+
"project_2.experiments['sim_lbco'].instrument.calib_d_to_tof_linear = ed.extract_metadata(\n",
1492+
" lbco_xye_path, r'DIFC\\s*=\\s*([-+]?\\d*\\.?\\d+(?:[eE][-+]?\\d+)?)'\n",
14931493
")"
14941494
]
14951495
},

docs/docs/tutorials/ed-13.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -212,19 +212,19 @@
212212
# TOF, respectively.
213213
#
214214
# You can set them manually, but it is more convenient to use the
215-
# `get_value_from_xye_header` function from the EasyDiffraction library.
215+
# `extract_metadata` function from the EasyDiffraction library.
216216

217217
# %% [markdown] tags=["doc-link"]
218218
# 📖 See
219219
# [documentation](https://docs.easydiffraction.org/lib/user-guide/analysis-workflow/experiment/#instrument-category)
220220
# for more details about the instrument parameters.
221221

222222
# %%
223-
project_1.experiments['sim_si'].instrument.setup_twotheta_bank = ed.get_value_from_xye_header(
224-
si_xye_path, 'two_theta'
223+
project_1.experiments['sim_si'].instrument.setup_twotheta_bank = ed.extract_metadata(
224+
si_xye_path, r'two_theta\s*=\s*([-+]?\d*\.?\d+(?:[eE][-+]?\d+)?)'
225225
)
226-
project_1.experiments['sim_si'].instrument.calib_d_to_tof_linear = ed.get_value_from_xye_header(
227-
si_xye_path, 'DIFC'
226+
project_1.experiments['sim_si'].instrument.calib_d_to_tof_linear = ed.extract_metadata(
227+
si_xye_path, r'DIFC\s*=\s*([-+]?\d*\.?\d+(?:[eE][-+]?\d+)?)'
228228
)
229229

230230
# %% [markdown]
@@ -804,11 +804,11 @@
804804
# **Solution:**
805805

806806
# %% tags=["solution", "hide-input"]
807-
project_2.experiments['sim_lbco'].instrument.setup_twotheta_bank = ed.get_value_from_xye_header(
808-
lbco_xye_path, 'two_theta'
807+
project_2.experiments['sim_lbco'].instrument.setup_twotheta_bank = ed.extract_metadata(
808+
lbco_xye_path, r'two_theta\s*=\s*([-+]?\d*\.?\d+(?:[eE][-+]?\d+)?)'
809809
)
810-
project_2.experiments['sim_lbco'].instrument.calib_d_to_tof_linear = ed.get_value_from_xye_header(
811-
lbco_xye_path, 'DIFC'
810+
project_2.experiments['sim_lbco'].instrument.calib_d_to_tof_linear = ed.extract_metadata(
811+
lbco_xye_path, r'DIFC\s*=\s*([-+]?\d*\.?\d+(?:[eE][-+]?\d+)?)'
812812
)
813813

814814
# %% [markdown]

0 commit comments

Comments
 (0)