Skip to content

Commit

Permalink
Update for grib2io xarray backend
Browse files Browse the repository at this point in the history
- Adding validDate coordinate variable
- Adding fullName and shortName to data variables.
- Changed message selection on 1 line to use isel()
  • Loading branch information
EricEngle-NOAA committed Sep 29, 2023
1 parent 771e342 commit 3f7225d
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion grib2io/xarray_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ def open_dataset(
ds = ds.assign_coords(cube.coords())
# assign extra geo coords
ds = ds.assign_coords(extra_geo)
# assign valid date coords
ds = ds.assign_coords(dict(validDate=ds.coords['refDate']+ds.coords['leadTime']))
# assign attributes
ds.attrs['engine'] = 'grib2io'

Expand Down Expand Up @@ -459,6 +461,8 @@ def build_da_without_coords(index, cube, filename) -> xr.DataArray:
da.attrs['GRIB2IO_section1'] = msg1.section1
da.attrs['GRIB2IO_section3'] = msg1.section3
da.attrs['GRIB2IO_section4'] = msg1.section4
da.attrs['fullName'] = msg1.fullName
da.attrs['shortName'] = msg1.shortName
da.attrs['units'] = msg1.units

da.name = index.shortName.iloc[0]
Expand Down Expand Up @@ -568,7 +572,7 @@ def __eq__(self, other):
cube.x = range(int(index.nx.iloc[0]))

extra_geo = None
msg = index.msg[0]
msg = index.msg.iloc[0]

# we want the lat lons; make them via accessing a record; we are asuming
# all records are the same grid because they have the same shape;
Expand Down

0 comments on commit 3f7225d

Please sign in to comment.