Herbie icon indicating copy to clipboard operation
Herbie copied to clipboard

Herbie accessors should be able to work for a GRIB2 file read by cfgrib that wasn't routed through Herbie

Open blaylockbk opened this issue 2 years ago • 2 comments

If you read a GRIB2 file into xarray with cfgrib, it is still missing the projection info that Herbie gets from pyproj and pygrib. That means you can't use the

ds = xr.open_dataset("file.grib2", engine='cfgrib')
ds.herbie.crs  # <<-- !! THIS ERRORS, because no projection info

It would be nice if the accessor would do the work to get that info like the H.xarray method already does.

blaylockbk avatar Mar 10 '23 05:03 blaylockbk

This could be worked on as part of #172

blaylockbk avatar Mar 10 '23 05:03 blaylockbk

I will need to look for the file path from the cfgrib history

import re
import xarray as xr

ds = xr.open_dataset(FILE, engine='cfgrib')
match = re.search(r'"source": "(.*?)"', ds. History)
Path(match. Group(1)).exists()

blaylockbk avatar Mar 11 '23 22:03 blaylockbk