Skip to content

Commit

Permalink
Merge branch 'fsspec:main' into kpaul/issue-448
Browse files Browse the repository at this point in the history
  • Loading branch information
kmpaul authored Apr 12, 2024
2 parents 82a405e + 95f333c commit fb21134
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 14 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -124,3 +124,6 @@ dmypy.json

# Pyre type checker
.pyre/

# VSCode settings
.vscode/
2 changes: 1 addition & 1 deletion ci/environment-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ dependencies:
- xarray
- xarray-datatree
- h5netcdf
- h5py<3.9
- h5py
- pandas
- cfgrib
- cftime
Expand Down
2 changes: 1 addition & 1 deletion ci/environment-py310.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ dependencies:
- xarray
- xarray-datatree
- h5netcdf
- h5py<3.9
- h5py
- pandas
- cfgrib
- cftime
Expand Down
2 changes: 1 addition & 1 deletion ci/environment-py311.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ dependencies:
- xarray
- xarray-datatree
- h5netcdf
- h5py<3.9
- h5py
- pandas
- cfgrib
- cftime
Expand Down
8 changes: 5 additions & 3 deletions kerchunk/grib2.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,9 +250,11 @@ def scan_grib(
z[varName].attrs["_ARRAY_DIMENSIONS"] = dims

for coord in cfgrib.dataset.COORD_ATTRS:
coord2 = {"latitude": "latitudes", "longitude": "longitudes"}.get(
coord, coord
)
coord2 = {
"latitude": "latitudes",
"longitude": "longitudes",
"step": "step:int",
}.get(coord, coord)
try:
x = m.get(coord2)
except eccodes.WrongStepUnitError as e:
Expand Down
2 changes: 1 addition & 1 deletion kerchunk/tests/test_combine.py
Original file line number Diff line number Diff line change
Expand Up @@ -730,7 +730,7 @@ def test_cftimes_to_normal(refs):
engine="zarr",
chunks={},
)
assert z.time.dtype == "M8[s]"
assert z.time.dtype.kind == "M"
assert (
z.time.values
== np.array(["1970-02-01T00:00:00", "1970-03-01T00:00:00"], dtype="M8[s]")
Expand Down
17 changes: 10 additions & 7 deletions kerchunk/tests/test_grib.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import os.path

import eccodes
import fsspec
import numpy as np
import pytest
Expand All @@ -15,6 +16,7 @@
correct_hrrr_subhf_step,
)

eccodes_ver = tuple(int(i) for i in eccodes.__version__.split("."))
cfgrib = pytest.importorskip("cfgrib")
here = os.path.dirname(__file__)

Expand Down Expand Up @@ -49,7 +51,10 @@ def _fetch_first(url):
@pytest.mark.parametrize(
"url",
[
"s3://noaa-hrrr-bdp-pds/hrrr.20140730/conus/hrrr.t23z.wrfsubhf08.grib2",
pytest.param(
"s3://noaa-hrrr-bdp-pds/hrrr.20140730/conus/hrrr.t23z.wrfsubhf08.grib2",
marks=pytest.mark.skipif(eccodes_ver >= (2, 34), reason="eccodes too new"),
),
"s3://noaa-gefs-pds/gefs.20221011/00/atmos/pgrb2ap5/gep01.t00z.pgrb2a.0p50.f570",
"s3://noaa-gefs-retrospective/GEFSv12/reforecast/2000/2000010100/c00/Days:10-16/acpcp_sfc_2000010100_c00.grib2",
],
Expand Down Expand Up @@ -111,13 +116,11 @@ def test_grib_tree():
zg = zarr.open_group(fs.get_mapper(""))
assert isinstance(zg["refc/instant/atmosphere/refc"], zarr.Array)
assert isinstance(zg["vbdsf/avg/surface/vbdsf"], zarr.Array)
assert (
zg["vbdsf/avg/surface"].attrs["coordinates"]
== "surface latitude longitude time valid_time step"
assert set(zg["vbdsf/avg/surface"].attrs["coordinates"].split()) == set(
"surface latitude longitude step time valid_time".split()
)
assert (
zg["refc/instant/atmosphere"].attrs["coordinates"]
== "atmosphere latitude longitude step time valid_time"
assert set(zg["refc/instant/atmosphere"].attrs["coordinates"].split()) == set(
"atmosphere latitude longitude step time valid_time".split()
)
# Assert that the fill value is set correctly
assert zg.refc.instant.atmosphere.step.fill_value is np.NaN
Expand Down

0 comments on commit fb21134

Please sign in to comment.