To copy only those messages for parameter T from the GRIB file file1.grib1 use grib_copy with the -w option to specify a shortName=t:
Similarly to copy only those messages for parameter Z, use:
Or, more simply, and because the file contains only parameters T and Z, one can use:
Using grib_ls of the two files confirms that the contents are correct. For example:
|
To reorder the messages in order of ascending pressure level, use, e.g.:
Note the use of “level:i” here to specify that the level should be treated as an integer ! Using grib_ls to inspect the two files confirms that the contents are correct. For example:
|
To change the date and time for the GRIB messages in file.grib1 use:
Using grib_ls confirms that this has been done correctly:
|
To make the same change of date and time for the temperature at 500hPa only use the -w option with grib_set to make sure that the correct message is changed:
Again, grib_ls can be used to confirm the output is correct:
|
If grib_set is used with the -S option, only the changed GRIB message is copied to the output file:
Again, grib_ls can be used to confirm the output is correct:
|
To convert the GRIB messages in file.grib1 to netCDF with data type NC_SHORT use:
Using ncdump to print the values for the variable t2m shows:
The data values appear as integers because of the NC_SHORT data format. These values need to be unpacked using the scale_factor and add_offset netCDF attributes.
In this case, the data values do not need further processing. |
To set the reference date to 1 January 2019, use the -R option
Compare the time variable settings from out2.nc and out2b.nc:
The time units are different and the time values are negative in out2b.nc because the date of the GRIB data is 1 February 2019 (so before the new reference date). |
Converting file3.grib1 to netCDF gives the following:
The conversion fails because the GRIB data is represented on a reduced Gaussian grid (gridType=reduced_gg). Conversion to NetCDF is possible only for GRIB data with gridType=regular_ll or gridType=regular_gg. |