Skip to content

Fix retain time coordinate#1072

Open
Alfie5640 wants to merge 2 commits into
ecmwf:developfrom
Alfie5640:fix-retain-time-coordinate
Open

Fix retain time coordinate#1072
Alfie5640 wants to merge 2 commits into
ecmwf:developfrom
Alfie5640:fix-retain-time-coordinate

Conversation

@Alfie5640

Copy link
Copy Markdown

Description

Updated default profiled to enable add_valid_time_coord
When add_valid_time_coord=True, converting GRIB data containing a single valid time could fail during xarray conversion.

The failure occurred because scalar "valid_time" values were incorrectly assigned a coordinate dimension: ValueError: dimensions ('valid_time',) must have the same length as the number of data dimensions, ndim=0

This change updates coordinate dimension inference so scalar coordinate values are represented with no dimensions ( dims=() ), while non-scalar coordinates retain their inferred dimensions

Tests

Added a regression test covering the single valid time case to make sure that

  • valid_time is retained as an auxiliary coordinate
  • valid_time is not incorrectly promoted to a dimension
  • scalar coordinate dimensions are represented correctly

Ran all tests with pytest

Contributor Declaration

By opening this pull request, I affirm the following:

  • All authors agree to the Contributor License Agreement.
  • The code follows the project's coding standards.
  • I have performed self-review and added comments where needed.
  • I have added or updated tests to verify that my changes are effective and functional.
  • I have run all existing tests and confirmed they pass.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant