diff --git a/climetlab/readers/grib/output.py b/climetlab/readers/grib/output.py index 2714f722..a2499f51 100644 --- a/climetlab/readers/grib/output.py +++ b/climetlab/readers/grib/output.py @@ -199,9 +199,9 @@ def update_metadata(self, handle, metadata, compulsary): if "number" in metadata: compulsary += ("numberOfForecastsInEnsemble",) productDefinitionTemplateNumber = {"tp": 11} - metadata[ - "productDefinitionTemplateNumber" - ] = productDefinitionTemplateNumber.get(handle.get("shortName"), 1) + metadata["productDefinitionTemplateNumber"] = ( + productDefinitionTemplateNumber.get(handle.get("shortName"), 1) + ) if metadata.get("type") in ("pf", "cf"): metadata.setdefault("typeOfGeneratingProcess", 4) diff --git a/climetlab/readers/netcdf/fieldset.py b/climetlab/readers/netcdf/fieldset.py index 4cd08682..1527caf6 100644 --- a/climetlab/readers/netcdf/fieldset.py +++ b/climetlab/readers/netcdf/fieldset.py @@ -181,6 +181,12 @@ class NetCDFFieldSetFromFileOrURL(NetCDFFieldSet): def __init__(self, path_or_url): self.path_or_url = path_or_url + @cached_property + def xr_dataset(self): + import xarray as xr + + return xr.open_dataset(self.path_or_url) + class NetCDFFieldSetFromFile(NetCDFFieldSetFromFileOrURL): def __init__(self, path): @@ -202,12 +208,6 @@ def __init__(self, url): def __repr__(self): return "NetCDFFieldSetFromURL(%s)" % (self.path_or_url,) - @cached_property - def xr_dataset(self): - import xarray as xr - - return xr.open_dataset(self.path_or_url) - class NetCDFMaskFieldSet(NetCDFFieldSet, MaskIndex): def __init__(self, *args, **kwargs): @@ -239,13 +239,6 @@ def fields(self): result.extend(s.fields) return result - # @cached_property - # def dataset(self): - # return self.to_xarray(combine="by_coords") - - # def __iter__(self): - # return MultiIndex.__iter__(self) - def __len__(self): return MultiIndex.__len__(self) diff --git a/climetlab/version b/climetlab/version index c7f4ab0c..88541566 100644 --- a/climetlab/version +++ b/climetlab/version @@ -1 +1 @@ -0.20.15 +0.21.0 diff --git a/tests/readers/test_netcdf_reader.py b/tests/readers/test_netcdf_reader.py index 664af369..a8ddbfa8 100644 --- a/tests/readers/test_netcdf_reader.py +++ b/tests/readers/test_netcdf_reader.py @@ -27,7 +27,7 @@ def test_netcdf(): def test_dummy_netcdf_reader_1(): s = load_source("file", climetlab_file("docs/examples/test.nc")) r = s._reader - assert str(r).startswith("NetCDFReader"), r + assert str(r).startswith("NetCDFFieldSetFromFile"), r assert len(r) == 2 assert isinstance(r[1], NetCDFField), r