Skip to content

Support str step range in xarray engine#721

Merged
sandorkertesz merged 11 commits into
developfrom
feature/xarray-support-str-step-range
Jun 10, 2025
Merged

Support str step range in xarray engine#721
sandorkertesz merged 11 commits into
developfrom
feature/xarray-support-str-step-range

Conversation

@sandorkertesz

@sandorkertesz sandorkertesz commented Jun 10, 2025

Copy link
Copy Markdown
Collaborator

Closes #713

This PR adds the following changes:

Breaking changes

  • Separated the dimension names from the metadata keys used to generate the dimensions. Dimensions associated with the dimension roles are now taking the name of the dimension role, irrespective of the metadata key the dimension role is mapped to. E.g.: the "level_type" dimension role now generates a dimension called "level_type". Previously, the dimension name was the name of the associated metadata key: e.g. it was "levtype" in the default profile. The old behaviour can still be invoked by using the newly added dim_name_from_role_name=False option.

  • The step dimension role is now mapped to the "step_timedelta" metadata key, which is the datetime.timedelta representation of the "endStep" GRIB/metadata key. Previously, this role was mapped to the "step" key. Please note that due to this change when dim_name_from_role_name=False is used the step dimension will be called "step_timedelta" instead of "step".

Deprecation

  • The name of the ensemble member dimension role changed to "number" from "ens" in the dim_roles option of to_xarray(). The old name is still available for backward compatibility but will be removed in a future release.

Other changes

  • Allowed using mappings in the extra_dims and fixed_dims options to define both the name of the dimensions and the metadata keys to generate their values. Previously, these options only took a single/multiple metadata keys. E.g. both the options below will generate the "expver", "mars_stream" and "mars_class" dimensions using the "expver", "stream" and "class" metadata keys.
       extra_dims = ["expver", {"mars_stream": "stream"}, ("mars_class", "class")]
       extra_dims = {
           "expver": "expver",
           "mars_stream": "stream",
           "mars_class": "class",
       }

New Xarray engine notebooks

  • xr_engine_step_range.ipynb
  • xr_engine_ensemble.ipynb
  • xr_engine_squeeze.ipynb

@codecov-commenter

codecov-commenter commented Jun 10, 2025

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 97.15302% with 8 lines in your changes missing coverage. Please review.
✅ Project coverage is 90.77%. Comparing base (e5be345) to head (6b5065a).
⚠️ Report is 323 commits behind head on develop.

Files with missing lines Patch % Lines
tests/xr_engine/test_xr_time.py 78.12% 2 Missing and 5 partials ⚠️
tests/xr_engine/xr_engine_fixtures.py 66.66% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop     #721      +/-   ##
===========================================
+ Coverage    90.66%   90.77%   +0.10%     
===========================================
  Files          168      169       +1     
  Lines        12683    12916     +233     
  Branches       614      615       +1     
===========================================
+ Hits         11499    11724     +225     
- Misses        1001     1003       +2     
- Partials       183      189       +6     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

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

@sandorkertesz sandorkertesz merged commit 387ed5a into develop Jun 10, 2025
126 checks passed
@sandorkertesz sandorkertesz deleted the feature/xarray-support-str-step-range branch June 10, 2025 14:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

to_xarray fails with GRIB2 data containing step as a range

2 participants