1. The file file1.grib1 contains parameters T and Z on six pressure levels.
- Use grib_copy to create two files, one containing all the pressure levels for parameter T, the other for Z. Check the content of the new files with grib_ls
Expand | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
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:
|
- Repeat but output the messages so the levels in the new files are in increasing numerical order
Expand | ||||
---|---|---|---|---|
| ||||
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:
|
2. Use grib_set to change the date and time to 12UTC on 4 February 2019 for all messages in file1.grib1
Expand | ||||
---|---|---|---|---|
| ||||
To change the date and time for the GRIB messages in file.grib1 use:
Using grib_ls confirms that this has been done correctly:
|
- Repeat but change the date and time for T at 500hPa only
Expand | ||||
---|---|---|---|---|
| ||||
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:
|
- Repeat so that T at 500hPa only is written to the output file
Expand | ||||
---|---|---|---|---|
| ||||
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:
|
3. Use grib_to_netcdf to convert the GRIB messages in file2.grib1 to NetCDF.
- Try with both the default data type (NC_SHORT) and NC_FLOAT.
- Check the data values in each case with ncdump.
Expand | ||||||
---|---|---|---|---|---|---|
| ||||||
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. |
- Repeat but set the Reference date to 6 February 2019 and compare with previous results
Expand | ||||
---|---|---|---|---|
| ||||
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). |
4. Use grib_to_netcdf to convert the GRIB messages in file3.grib1 to NetCDF.
- What happens … and why ?
Expand | ||
---|---|---|
| ||
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. |