Skip to content

Commit

Permalink
Bugfix/unknow coordinates (ecmwf#72)
Browse files Browse the repository at this point in the history
* allow for unknown coordinates
  • Loading branch information
b8raoult authored Oct 4, 2024
1 parent 39594dc commit 5314a34
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ Keep it human-readable, your future self will thank you!

## [0.5.5](https://github.com/ecmwf/anemoi-datasets/compare/0.5.4...0.5.5) - 2024-10-04

### Changed

- Allow for unknown coordinates when parsing CF input

## [Add support for (semi-)constant fields](https://github.com/ecmwf/anemoi-datasets/compare/0.5.1...0.5.2) - 2024-10-03

### Changed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def load_one(emoji, context, dates, dataset, options={}, flavour=None, **kwargs)
We have seen this bug triggered when we run many clients in parallel, for example, when we create a new dataset using `xarray-zarr`.
"""

context.trace(emoji, dataset, options)
context.trace(emoji, dataset, options, kwargs)

if isinstance(dataset, str) and ".zarr" in dataset:
data = xr.open_zarr(name_to_zarr_store(dataset), **options)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -244,3 +244,9 @@ class ScalarCoordinate(Coordinate):
@property
def mars_names(self):
return (self.variable.name,)


class UnsupportedCoordinate(Coordinate):
@property
def mars_names(self):
return (self.variable.name,)
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
from .coordinates import ScalarCoordinate
from .coordinates import StepCoordinate
from .coordinates import TimeCoordinate
from .coordinates import UnsupportedCoordinate
from .coordinates import XCoordinate
from .coordinates import YCoordinate
from .coordinates import is_scalar
Expand Down Expand Up @@ -157,11 +158,13 @@ def _guess(self, c, coord):
if c.shape in ((1,), tuple()):
return ScalarCoordinate(c)

raise NotImplementedError(
LOG.warning(
f"Coordinate {coord} not supported\n{axis=}, {name=},"
f" {long_name=}, {standard_name=}, units\n\n{c}\n\n{type(c.values)} {c.shape}"
)

return UnsupportedCoordinate(c)

def grid(self, coordinates, variable):
lat = [c for c in coordinates if c.is_lat]
lon = [c for c in coordinates if c.is_lon]
Expand Down

0 comments on commit 5314a34

Please sign in to comment.