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 0.3.4 into develop #36

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion docs/examples/healpix_fieldlist.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
" \"url\", \n",
" \"https://get.ecmwf.int/repository/test-data/earthkit-regrid/examples/H8_nested_multi.grib2\")\n",
"\n",
"# the target grid is a global 5x5 degree regular latitude grid\n",
"# the target grid is a global 5x5 degree regular latitude-longitude grid\n",
"out_grid = {\"grid\": [5,5]}\n",
"\n",
"# perform interpolation for each field and add results \n",
Expand Down
2 changes: 1 addition & 1 deletion docs/examples/octahedral_fieldlist.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
" \"url\", \n",
" \"https://get.ecmwf.int/repository/test-data/earthkit-regrid/examples/O32_multi.grib2\")\n",
"\n",
"# the target grid is a global 5x5 degree regular latitude grid\n",
"# the target grid is a global 5x5 degree regular latitude-longitude grid\n",
"out_grid = {\"grid\": [5,5]}\n",
"\n",
"# perform interpolation for each field and add results \n",
Expand Down
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
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