Skip to content

Commit

Permalink
Merge branch 'main' into feature/merge-main-0.3.4-into-develop
Browse files Browse the repository at this point in the history
  • Loading branch information
sandorkertesz committed Sep 12, 2024
2 parents 3aa638b + d1e9c28 commit ba07d30
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 3 deletions.
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

0 comments on commit ba07d30

Please sign in to comment.