Skip to content

Commit 8088725

Browse files
committed
small changes
so that time is found as a coordinate or an axes, not sure why it is not being found as an axes though
1 parent d6820a3 commit 8088725

File tree

3 files changed

+16
-2
lines changed

3 files changed

+16
-2
lines changed

model_catalogs/model_catalogs.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,9 @@ def setup(locs="mc_", override=False, boundaries=True):
258258

259259
# initial_cats is a list of Catalogs in this case
260260
cats = [
261-
intake.cat[cat_name] for cat_name in list(intake.cat) if loc in cat_name
261+
intake.cat[cat_name]
262+
for cat_name in list(intake.cat)
263+
if str(loc) in cat_name
262264
]
263265

264266
# remove the prefix from the catalog name

model_catalogs/process.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,10 @@ def to_dask(self):
251251
)
252252

253253
# drop any time duplicates that may be present (RTOFS can have)
254-
self._ds = self._ds.drop_duplicates(dim=self._ds.cf.axes["T"])
254+
if "T" in self._ds.cf.axes:
255+
self._ds = self._ds.drop_duplicates(dim=self._ds.cf.axes["T"])
256+
elif "time" in self._ds.cf.coordinates:
257+
self._ds = self._ds.drop_duplicates(dim=self._ds.cf.coordinates["time"])
255258

256259
# check for 'urlpath' update being sent in, if so use it to
257260
# subselect ds in time

model_catalogs/tests/test_catalogs.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
Make sure catalogs work correctly. If this doesn't run once, try again since the servers can be finnicky.
33
"""
44

5+
import pathlib
56
import warnings
67

78
from unittest import mock
@@ -112,6 +113,14 @@ def test_boundaries():
112113
assert "bbox" in boundaries[model]
113114
assert "wkt" in boundaries[model]
114115

116+
# also test through setup with just this one
117+
import mc_goods
118+
119+
# input catalog file directly
120+
catloc = pathlib.Path(mc_goods.__path__[0]) / "gofs.yaml"
121+
main_cat = mc.setup(catloc)
122+
assert "geospatial_bounds" in main_cat["GOFS"].metadata
123+
115124

116125
# @pytest.mark.slow
117126
# this test continues to be too brittle with CO-OPS servers breaking constantly but in different ways each time

0 commit comments

Comments
 (0)