Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/merge main into develop #43

Merged
merged 6 commits into from
Nov 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,9 @@
"earthkit-data",
"https://earthkit-data.readthedocs.io/en/latest/",
),
"earthkit-maps": (
"earthkit-maps",
"https://earthkit-maps.readthedocs.io/en/latest/",
"earthkit-plots": (
"earthkit-plots",
"https://earthkit-plots.readthedocs.io/en/latest/",
),
"fieldlist": (
"fieldlist",
Expand Down
81 changes: 44 additions & 37 deletions docs/examples/healpix_fieldlist.ipynb

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/examples/numpy_arrays.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@
"id": "b91238ec-13b4-40c7-88c3-b703f311743d",
"metadata": {},
"source": [
"Define some helper methods for plotting. This will be done by earthkit-maps in the future."
"Define some helper methods for plotting."
]
},
{
Expand Down
81 changes: 44 additions & 37 deletions docs/examples/octahedral_fieldlist.ipynb

Large diffs are not rendered by default.

34 changes: 34 additions & 0 deletions docs/gridspec.rst
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,37 @@ Example:
.. code-block::

{"grid": [1, 1]}



HEALPix nested grid
------------------------------------------

The ``grid`` format is::

HXXX

The ``ordering`` must be set to ``"nested"``. For details about this grid, see `here <https://en.wikipedia.org/wiki/HEALPix>`_.

Example:

.. code-block::

{"grid": "H512", "ordering": "nested"}


HEALPix ring grid
------------------------------------------

The ``grid`` format is::

HXXX

The ``ordering`` can be omitted or set to ``"ring"``. For details about this grid, see `here <https://en.wikipedia.org/wiki/HEALPix>`_.

Example:

.. code-block::

{"grid": "H512", "ordering": "ring"}
{"grid": "H512"}
9 changes: 8 additions & 1 deletion docs/release_notes/version_0.3_updates.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
Version 0.3 Updates
/////////////////////////

Version 0.3.4
===============

Fixes
++++++++++++++++
- fixed issue when the "grid" value in a gridspec could not be specified as a tuple


Version 0.3.3
===============
Expand Down Expand Up @@ -33,7 +40,7 @@ New features
++++++++++++++++
- restructured and regenerated matrix inventory
- allow using the ``method`` keyword in :func:`interpolate` to specify the interpolation method
- allow using earthkit-data GRIB :xref:`fieldlist` in :func:`interpolate` as input data. This only works when the output grid is regular a latitude-longitude grid. This feature requires :xref:`earthkit-data` >= 0.6.0
- allow using earthkit-data GRIB :xref:`fieldlist` in :func:`interpolate` as input data. This only works when the output grid is a regular latitude-longitude grid. This feature requires :xref:`earthkit-data` >= 0.6.0
- added notebook examples:

- :ref:`/examples/healpix_fieldlist.ipynb`
Expand Down
8 changes: 8 additions & 0 deletions src/earthkit/regrid/gridspec.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,18 @@ def __init__(self, gs):
self._global_ns = None
super().__init__(gs)

@staticmethod
def _normalise(d):
for k, v in d.items():
if isinstance(v, tuple):
d[k] = list(v)

@staticmethod
def from_dict(d):
gs = dict(GridSpec.DEFAULTS)
gs.update(d)
GridSpec._normalise(gs)

t_name, t = GridSpec._infer_spec_type(gs)
if t is None:
raise ValueError(f"Unsupported gridspec={d}")
Expand Down
7 changes: 6 additions & 1 deletion src/earthkit/regrid/sphinxext/generate_inventory_rst.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,12 @@
def to_str(gs):
if isinstance(gs, str):
return gs
return {"grid": gs["grid"]}

grid = gs["grid"]
if isinstance(grid, str) and grid.startswith("H"):
return {"grid": gs["grid"], "ordering": gs["ordering"]}
else:
return {"grid": gs["grid"]}


def make_gs_block(source, target):
Expand Down
1 change: 1 addition & 0 deletions tests/test_gridspec.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@
),
({"grid": "H128"}, {"grid": [1, 1]}),
({"grid": "H128", "ordering": "ring"}, {"grid": [1, 1]}),
({"grid": (5, 5)}, {"grid": (10, 10)}),
],
)
def test_gridspec_ok(gs_in, gs_out):
Expand Down
Loading