Scheduled Downtime
On Friday 21 April 2023 @ 5pm MT, this website will be down for maintenance and expected to return online the morning of 24 April 2023 at the latest

wgrib2 output to netcdf - output variable names have changed between versions

MikeZu

New member
Hello all...

I'm not 100% sure this is the proper place to post this, but it can't hurt. The grb2 files in question are created from WRF output by way of UPP. The problem isn't the grb2 files themselves, but wgrib2 functionality...

I'm having a slight problem transitioning some code from an older system to a newer one. The code calls on wgrib2 to use the -netcdf option to convert the grb2 files to netcdf, and then various other actions are taken on the netcdf files.

The problem is that the newer version of wrgrib2 is using different netcdf names for some of the variables. For example, previously the grb2 variable TMP:30-0 mb above ground was output to the netcdf variable TMP_30_0mbaboveground. The new version of wgrib2 outputs it to TMP_30M0mbaboveground.

I'd rather not change the code to look for the new name, since the data gets loaded into a database under the netcdf name, so we'd have to change that as well. I could use something like the NCO netcdf operators to change the netcdf variable names after file creation, but that seems clumsy.

I think I may be able to change the mapping of input to output names in wgrib2 using the -nc_table option, but I haven't been able to find clear examples about how to do this. The documentation online has been less than clear.

Does anybody have suggestions? Maybe an nc_table file entry that work for the above case?

Thanks!
 
OK, in case anybody else is (or gets) interested, I now know the proper solution. I contacted one of the developers, and he got back to me very quickly and helpfully.

So this was an intentional change to remove the second underscore, to ease parsing the difference between the physical property and the height. I suspected as much.

I asked about the nc_table option, and it does allow you to specify the netcdf output names. For my case, I just create a file (I called it name_fix.nc_table) with the following lines:
HGT:30-0 mb above ground:HGT_30_0mbaboveground
RH:30-0 mb above ground:RH_30_0mbaboveground
TMP:30-0 mb above ground:TMP_30_0mbaboveground
UGRD:30-0 mb above ground:UGRD_30_0mbaboveground
VGRD:30-0 mb above ground:VGRD_30_0mbaboveground

Then when I issue my wgrib2 command, I simply include the "-nc_table name_fix.nc_table" option, and I get a netcdf file with my desired variable names.
 
Top