Project

General

Profile

Errors converting subsurface netcdf4 data to GRIB2

Added by B. Parazin over 1 year ago

Hi all, I'm new to working with CDO & Grib2 files, so apologies if this is a simple question. I'm currently working on some code to convert NetCDF4 files to Grib2 files since I would like to use their data for boundary conditions in WRF-ARW, which only accepts grib files. Overall, this has been a pretty smooth process just by calling

cdo -f nc copy file.nc file.grb2
, but I've been running into a pair of issues I can't figure out with a netcdf of subsurface data (attached here), where one of the three elements (soil temperature) is getting converted to an unknown variable in the grib2 file, rather than getting ported over to the right variable name like everything else. Additionally, the converter is interpreting the coordinate of depth in cm as pressure in pa when converting. I imagine both of these issues are due to some errors with the metadata around these variables, so the converter is unable to figure out what these specifically are for conversion to the (stricter) grib format, but I simply don't know enough about CDO or grib2 files to know how to change the metadata to fix this, so I'd greatly appreciate it if anyone could tell me how to change up that metadata/point me to a source outlining how to specifically set up my netcdf files for this. I've also attached the current output of the copy command (subsurface.grb2) since I figure it could be helpful for someone to look at as well.


Replies (7)

RE: Errors converting subsurface netcdf4 data to GRIB2 - Added by B. Parazin over 1 year ago

Wait just spotted an error in the code block I put in, I'm calling

cdo -f grb2 copy file.nc file.grb2

RE: Errors converting subsurface netcdf4 data to GRIB2 - Added by B. Parazin over 1 year ago

Ok, so I was lacking CF standard data for some of the elements of this file, but now that I've added it in, I'm running into an issue with the standard name for my subsurface measurements; if I use depth, it thinks it is underwater measurements, and if I use height, it thinks it is above ground measurements, and lists them as heights above the surface, neither of which is right. I've tried simply setting height and positive = down, but that didn't do anything, so if anyone knows how to label my data so CDO recognizes it as height below the surface, I would be very grateful

RE: Errors converting subsurface netcdf4 data to GRIB2 - Added by Uwe Schulzweida over 1 year ago

CDO uses the attribute long_name="depth_below_land" to identify depth below land:

ncatted -a long_name,depth,o,c,"depth_below_land" file.nc
cdo -f nc copy file.nc file.grb2

RE: Errors converting subsurface netcdf4 data to GRIB2 - Added by B. Parazin over 1 year ago

Thank you! Is there a resource somewhere with all of the attributes CDO uses to identify variables and levels I can use for future reference?

RE: Errors converting subsurface netcdf4 data to GRIB2 - Added by Uwe Schulzweida over 1 year ago

No such a list does not exist. If possible, you should stick to the NetCDF CF Convention.

RE: Errors converting subsurface netcdf4 data to GRIB2 - Added by B. Parazin over 1 year ago

Yeah, I've found CF to be mostly good; the last thing I'm trying to figure out is how to designate a aTypeOfLevel as mean sea level, which doesn't have a CF convention. Right now my CDO conversion is marking my pressure reduced to mean sea level field as isobaricInPh, which I assume is the default, is there a name convention I should use for that? I've attached the current nc file I'm converting from for that one

t.nc (281 KB) t.nc

RE: Errors converting subsurface netcdf4 data to GRIB2 - Added by Uwe Schulzweida over 1 year ago

There is no name convention for the mean sea level. I'am sure you can change the typeOfLevel in the resulting GRIB file with the GRIB tools from ecCodes.

    (1-7/7)