Skip to content

Orso improvements - #402

Merged
rozyczko merged 29 commits into
developfrom
orso_improvements
Sep 2, 2026
Merged

rozyczko merged 29 commits into
developfrom
orso_improvements

Conversation

@rozyczko

@rozyczko rozyczko commented Sep 1, 2026

Copy link
Copy Markdown
Member

This pull request introduces comprehensive support for ORSO file handling, including both text (.ort) and binary (.orb, NeXus/HDF5) formats. It also enhances polarization channel detection, experiment import/export, and unit handling, while making several API improvements and deprecations for clarity and maintainability.

ORSO file handling and data import/export:

  • Added support for reading and writing binary ORSO (.orb, NeXus/HDF5) files alongside text .ort files, with format detection based on content rather than file extension. Binary support requires the new orb extra (h5py).
  • Improved ORSO export: Project.save_experiment_as_orso serializes experiments and models using the new utility functions, and Model.as_orso now outputs the ORSO model-language dictionary (slab representation), not the internal dict.
  • Repeating multilayers are now preserved during import/export, using the ORSO stack syntax and resolving stacks to retain repetition counts.
  • Units declared in ORSO files are now honored and converted on load (Qz in 1/nm, lengths in nm, SLDs in 1/nm^2).

Polarization and dataset handling:

  • Enhanced polarization channel detection: new functions map ORSO polarization headers to internal channels, and multi-dataset files are classified per dataset.
  • Added dataset_from_datagroup to build a DataSet1D from a loaded DataGroup, preserving the parsed ORSO header for provenance and avoiding redundant parsing.
  • Project experiment loading now supports pre-loaded DataGroup objects and robustly handles multi-dataset files, raising on corrupt ORSO files instead of silently falling back.

Resolution and error handling:

  • Resolution and error columns are read more carefully: FWHM columns are converted to sigma, missing error columns warn instead of propagating nan, and stored Pointwise resolutions remain as variances for round-tripping.

API improvements and deprecations:

  • Deprecated Project.load_orso_file in favor of explicit data and model loading methods for clarity.
  • Various internal refactorings to centralize ORSO logic and reduce code duplication.

@rozyczko rozyczko added [scope] enhancement Adds/improves features (major.MINOR.patch) [priority] high Should be prioritized soon enhancement labels Sep 1, 2026
@codecov

codecov Bot commented Sep 1, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 95.24941% with 20 lines in your changes missing coverage. Please review.
✅ Project coverage is 94.40%. Comparing base (c869e63) to head (264195b).

Files with missing lines Patch % Lines
src/easyreflectometry/orso_utils.py 95.73% 13 Missing ⚠️
src/easyreflectometry/data/measurement.py 87.50% 3 Missing ⚠️
src/easyreflectometry/data/polarized.py 89.47% 2 Missing ⚠️
src/easyreflectometry/project.py 97.01% 2 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           develop     #402      +/-   ##
===========================================
+ Coverage    93.97%   94.40%   +0.42%     
===========================================
  Files           54       54              
  Lines         5177     5500     +323     
===========================================
+ Hits          4865     5192     +327     
+ Misses         312      308       -4     
Flag Coverage Δ
integration 38.67% <29.21%> (-0.45%) ⬇️
unittests 94.40% <95.24%> (+0.42%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
src/easyreflectometry/data/__init__.py 100.00% <100.00%> (ø)
src/easyreflectometry/model/model.py 98.12% <100.00%> (+0.65%) ⬆️
...rc/easyreflectometry/model/resolution_functions.py 98.03% <ø> (ø)
src/easyreflectometry/data/polarized.py 95.27% <89.47%> (-1.16%) ⬇️
src/easyreflectometry/project.py 94.14% <97.01%> (+1.42%) ⬆️
src/easyreflectometry/data/measurement.py 92.47% <87.50%> (+0.06%) ⬆️
src/easyreflectometry/orso_utils.py 94.40% <95.73%> (+4.56%) ⬆️

... and 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@rozyczko
rozyczko merged commit 8b13521 into develop Sep 2, 2026
55 checks passed
@rozyczko
rozyczko deleted the orso_improvements branch September 2, 2026 09:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement [priority] high Should be prioritized soon [scope] enhancement Adds/improves features (major.MINOR.patch)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant