This archive contains answers to questions sent to Unidata support through mid-2025. Note that the archive is no longer being updated. We provide the archive for reference; many of the answers presented here remain technically correct, even if somewhat outdated. For the most up-to-date information on the use of NSF Unidata software and data services, please consult the Software Documentation first.
Hi, 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: https://www.unidata.ucar.edu/software/thredds/current/netcdf-java/ https://www.unidata.ucar.edu/software/thredds/current/netcdf-java/reference/manPages.html 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. Ryan > Hi, > > 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 . . . > > https://pando-rgw01.chpc.utah.edu/hrrr/sfc/20190621/hrrr.t00z.wrfsfcf00.grib2 > > -> According to wgrib, I've got 148 variables in this file. > > The second file is here . . . > > https://pando-rgw01.chpc.utah.edu/hrrr/sfc/20190621/hrrr.t00z.wrfsfcf03.grib2 > > -> 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 Details =================== Ticket ID: BKT-483151 Department: Support Python Priority: Low Status: Closed =================== 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.