[python #BKT-483151]: wgrib2 - HRRR Data to NetCDF
- Subject: [python #BKT-483151]: wgrib2 - HRRR Data to NetCDF
- Date: Fri, 28 Jun 2019 14:58:57 -0600
I'm not super familiar with wgrib2, but it appears to be a problem with how
wgrib2 is converting variables to netCDF. If I compare the manifest from wgrib2
to the list of variables when XArray opens it, it looks like the following are
missing from the 3-hour forecast:
42:28594909:d=2019062100:REFD:263 K level:2-3 hour max fcst:
79:56593810:d=2019062100:WEASD:surface:0-3 hour acc fcst:
84:56771551:d=2019062100:APCP:surface:2-3 hour acc fcst:
85:57284946:d=2019062100:WEASD:surface:2-3 hour acc fcst:
I'm sure I missed one, but the theme here seems to be that the process wgrib2
uses to come up with netCDF variable names does not correctly keep these fields
from conflicting, and thus some of the fields end up clobbering others in the
file. If these fields are of concern to you, you may want to reach out to the
wgrib2 developers: https://www.cpc.ncep.noaa.gov/products/wesley/wgrib2/
You can also use netCDF-java to do the conversion from grib2:
java -classpath netcdfAll.jar ucar.nc2.write.Nccopy -i
hrrr.t00z.wrfsfcf03.grib2 -o hrrr03.nc4
I will add that these converted files don't seem to like the conversion in
xarray to data frames, so I'm not sure if they'll work for your purposes.
> I'm using wgrib2 to convert some HRRR grib2 data to netcdf for some
> analysis I'm doing in Python. I'm running into an issue where I'm not
> getting all of the data between two files.
> The first file is here . . .
> -> According to wgrib, I've got 148 variables in this file.
> The second file is here . . .
> -> According to wgrib, I've got 152 variables in this file.
> I convert them both to netcdf using the following wgrib2 command.
> wgrib2 hrrr.t00z.wrfsfcf00.grib2 -netcdf hrrr.t00z.wrfsfcf00.nc
> wgrib2 hrrr.t00z.wrfsfcf03.grib2 -netcdf hrrr.t00z.wrfsfcf03.nc
> I then take those netcdf files and load them into Python using the
> following . . .
> ------ Python Start -------
> import xarray as xr
> hrrr_file="hrrr.t00z.wrfsfcf00.nc "
> hrrr = xr.open_dataset(hrrr_file).to_dataframe()
> ------ End Python -------
> Doing this for either file always results in 148 columns, two of which
> are latitude and longitude. Leaving me with 146 variables in the final
> dataset. Two variables are missing in the 00 hour forecast and 5 are
> missing in the 3 hour forecast.
> Any help you could provide would be greatly appreciated. I'm at a loss
> as to why variables are coming up missing.
Ticket ID: BKT-483151
Department: Support Python
NOTE: All email exchanges with Unidata User Support are recorded in the Unidata
inquiry tracking system and then made publicly available through the web. If
you do not want to have your interactions made available in this way, you must
let us know in each email you send to us.