Skip to content

Orso improvements - #402

Open
rozyczko wants to merge 24 commits into
developfrom
orso_improvements
Open

Orso improvements#402
rozyczko wants to merge 24 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 85.51069% with 61 lines in your changes missing coverage. Please review.
✅ Project coverage is 93.58%. Comparing base (c869e63) to head (03e6fbb).

Files with missing lines Patch % Lines
src/easyreflectometry/orso_utils.py 82.62% 53 Missing ⚠️
src/easyreflectometry/data/measurement.py 83.33% 4 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%   93.58%   -0.40%     
===========================================
  Files           54       54              
  Lines         5177     5500     +323     
===========================================
+ Hits          4865     5147     +282     
- Misses         312      353      +41     
Flag Coverage Δ
integration 38.67% <29.21%> (-0.45%) ⬇️
unittests 93.58% <85.51%> (-0.40%) ⬇️

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 91.39% <83.33%> (-1.01%) ⬇️
src/easyreflectometry/orso_utils.py 82.66% <82.62%> (-7.17%) ⬇️

... 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.

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