Skip to content

Commit

Permalink
allow for unknown coordinated
Browse files Browse the repository at this point in the history
  • Loading branch information
b8raoult committed Oct 4, 2024
1 parent fa3d0b2 commit 5e8af47
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 15 deletions.
14 changes: 8 additions & 6 deletions docs/building/sources/repeated_dates.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,20 @@
repeated_dates
################

The `repeated_dates` source is used to repeat a single source multiple times, so that its data is present at multiple dates.
A simple example of this is when you have source that contains a constant field, such as orography or bathymetry,
that you want to have repeated at all the dates of the dataset.
The `repeated_dates` source is used to repeat a single source multiple
times, so that its data is present at multiple dates. A simple example
of this is when you have source that contains a constant field, such as
orography or bathymetry, that you want to have repeated at all the dates
of the dataset.

The generale format of the `repeated_dates` source is:

.. literalinclude:: yaml/repeated_dates1.yaml
:language: yaml

where ``source`` is any of the :ref:`operations <operations>` or :ref:`sources <sources>` described in the previous sections.
The ``mode`` parameter can be one of the following:

where ``source`` is any of the :ref:`operations <operations>` or
:ref:`sources <sources>` described in the previous sections. The
``mode`` parameter can be one of the following:

**********
constant
Expand Down
13 changes: 6 additions & 7 deletions docs/building/sources/xarray-based.rst
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
This source uses `Xarray`_ internally to access the data, and assumes
that it follows the `CF conventions`_.
This source uses Xarray_ internally to access the data, and assumes that
it follows the `CF conventions`_.

You specify any valid `xarray.open_dataset`_ arguments in the source.
You specify any valid xarray.open_dataset_ arguments in the source.

.. literalinclude:: yaml/xarray-based.yaml
:language: yaml
:language: yaml

.. _cf conventions: http://cfconventions.org/

.. _Xarray: https://docs.xarray.dev/en/stable/index.html

.. _CF conventions: http://cfconventions.org/
.. _xarray: https://docs.xarray.dev/en/stable/index.html

.. _xarray.open_dataset: https://docs.xarray.dev/en/stable/generated/xarray.open_dataset.html
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 5e8af47

Please sign in to comment.