The file file1.grib1 contains parameters T and Z on six pressure levels.
...
| Expand |
|---|
|
To reorder the messages in order of ascending pressure level, use, e.g.: | Code Block |
|---|
% grib_copy -B “level:l asc” file.grib1 “[shortName]_ordered.grib1” |
Note the use of “level:l” 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: | Code Block |
|---|
% grib_ls -p centre,shortName,typeOfLevel,level,dataDate t_ordered.grib1
t_ordered.grib1
centre shortName typeOfLevel level dataDate
ecmf t isobaricInhPa 300 20190201
ecmf t isobaricInhPa 400 20190201
ecmf t isobaricInhPa 500 20190201
ecmf t isobaricInhPa 700 20190201
ecmf t isobaricInhPa 850 20190201
ecmf t isobaricInhPa 1000 20190201
6 of 6 grib messages in t_ordered.grib1
6 of 6 total grib messages in 1 files |
|
Use grib_set to change the date and time to 12UTC on 4 February 2019 for all messages in file1.grib1
...
| Expand |
|---|
|
If grib_set is used with the -S option, only the changed GRIB message is copied to the output file: | Code Block |
|---|
% grib_set -S -w shortName=t,level=500 -s dataDate=20190204,dataTime=12 file.grib1 t500_only.grib1 |
Again, grib_ls can be used to confirm the output is correct: | Code Block |
|---|
% grib_ls -p centre,shortName,typeOfLevel,level,dataDate,dataTime t500_only.grib1 t500_only.grib1
centre shortName typeOfLevel level dataDate dataTime
ecmf t isobaricInhPa 500 20190204 12
1 of 1 grib messages in t500_only.grib1
1 of 1 total grib messages in 1 files |
|
Use grib_to_netcdf to convert the GRIB messages in file2.grib1 to NetCDF.
...
| Expand |
|---|
|
To set the reference date to 1 January 2019, use the -R option | Code Block |
|---|
% grib_to_netcdf -R 20190206 -o out2b.nc file2.grib1
grib_to_netcdf: Version 2.10.0
grib_to_netcdf: Processing input file 'file2.grib1'.
grib_to_netcdf: Found 4 GRIB fields in 1 file.
grib_to_netcdf: Ignoring key(s): method, type, stream, refdate, hdate
grib_to_netcdf: Creating netCDF file 'out2b.nc'
grib_to_netcdf: NetCDF library version: 4.4.1 of May 8 2017 15:47:29 $
grib_to_netcdf: Creating large (64 bit) file format.
grib_to_netcdf: Defining variable 't2m'.
grib_to_netcdf: Done. |
Compare the time variable settings from out2.nc and out2b.nc: | Code Block |
|---|
% ncdump -v time out2.nc
...
variables:
...
int time(time) ;
time:units = "hours since 1900-01-01 00:00:00.0" ;
time:long_name = "time" ;
time:calendar = "gregorian" ;
data:
time = 1043886, 1043892, 1043898, 1043904 ;
...
% ncdump -v time out2b.nc
...
variables:
...
int time(time) ;
time:units = "hours since 2019-02-06 00:00:00.0" ;
time:long_name = "time" ;
time:calendar = "gregorian" ;
data:
time = -114, -108, -102, -96 ;
... |
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). |
Use grib_to_netcdf to convert the GRIB messages in file3.grib1 to NetCDF.
...