...
...
Expand |
---|
title | Click here to see solution... |
---|
|
To copy only those messages for parameter T from the GRIB file tz_an_pl.grib1 use grib_copy with the -w option to specify a shortName=t: No Format |
---|
$> grib_copy -w shortName=t tz_an_pl.grib1 t_an_pl.grib1 |
Similarly to copy only those messages for parameter Z, use: No Format |
---|
$> grib_copy -w shortName=z tz_an_pl.grib1 z_an_pl.grib1 |
Or, more simply, and because the file contains only parameters T and Z, one can use: No Format |
---|
$> grib_copy tz_an_pl.grib1 "[shortName]_an_pl.grib1" |
Using grib_ls of the two files confirms that the contents are correct. For example: No Format |
---|
$> grib_ls -p centre,paramId,typeOfLevel,level,date,dataType,time,shortName t_an_pl.grib1
t_an_pl.grib1
centre paramId typeOfLevel level date dataType time shortName
ecmf 130 isobaricInhPa 1000 20170219 an 1200 t
ecmf 130 isobaricInhPa 850 20170219 an 1200 t
ecmf 130 isobaricInhPa 700 20170219 an 1200 t
ecmf 130 isobaricInhPa 500 20170219 an 1200 t
ecmf 130 isobaricInhPa 400 20170219 an 1200 t
ecmf 130 isobaricInhPa 300 20170219 an 1200 t
6 of 6 messages in t_an_pl.grib1
6 of 6 total messages in 1 files |
You can take this further and split the file tz_an_pl.grib1 into separate files for each parameter/pressure level combination with: No Format |
---|
$> grib_copy tz_an_pl.grib1 "[shortName]_[level].grib[edition]"
$> ls ?_*.grib1
t_1000.grib1 t_400.grib1 t_700.grib1 z_1000.grib1 z_400.grib1 z_700.grib1
t_300.grib1 t_500.grib1 t_850.grib1 z_300.grib1 z_500.grib1 z_850.grib1 |
Each file contains one message only, e.g.: No Format |
---|
$> grib_ls -p centre,paramId,typeOfLevel,level,date,dataType,time,shortName t_1000.grib1
t_1000.grib1
centre paramId typeOfLevel level date dataType time shortName
ecmf 130 isobaricInhPa 1000 20170219 an 1200 t
1 of 1 messages in t_1000.grib1
1 of 1 total messages in 1 files |
|
...
The field in the file tp.grib is supposed to contain total precipitation, created using MARS compute to sum the convective and large-scale (stratiform) precipitation.
What is the parameter set to in the file tp.grib ? How could you use grib_set to change it is set correctly to total precipitation (shortName=tp, paramId=228) ?
Expand |
---|
title | Click here to see solution... |
---|
|
Use grib_ls to inspect the contents of the file tp.grib1, printing also the paramId with the –P option: No Format |
---|
$> grib_ls -P paramId tp.grib1
tp.grib1
paramId edition centre typeOfLevel level dataDate stepRange dataType shortName packingType gridType
142 1 ecmf surface 0 20170221 24 fc lsp grid_simple regular_ll
1 of 1 messages in tp.grib1
1 of 1 total messages in 1 files |
Alternatively, you could inspect the parameter namesapce with grib_ls: No Format |
---|
$> grib_ls -n parameter tp.grib1
tp.grib1
centre paramId units name shortName
ecmf 142 m Large-scale precipitation lsp
1 of 1 messages in tp.grib1
1 of 1 total messages in 1 files |
The shortName is set to lsp and paramId to 142, i.e., large-scale precipitation. Info |
---|
The field was created using MARS compute to sum the convective and large-scale (stratiform) precipitation. When using MARS compute, the output field maintains the information from the GRIB header of the first input field so, in this case, we see that the field has paramId 142 even though the message is now supposed to contain the total precipitation. |
To change the parameter to total precipitation, use grib_set as follows: No Format |
---|
$> grib_set -s shortName=tp tp.grib1 tp_new.grib1 |
Check with grib_ls: No Format |
---|
$> grib_ls -P paramId tp_new.grib1
tp_new.grib1
paramId edition centre typeOfLevel level dataDate stepRange dataType shortName packingType gridType
228 1 ecmf surface 0 20170221 24 fc tp grid_simple regular_ll
1 of 1 messages in tp_new.grib1
1 of 1 total messages in 1 files |
Tip |
---|
Note that changing the shortName has also changed the value of paramId. The same could be achieved by setting paramId=228: No Format |
---|
$> grib_set -s paramId=228 tp.grib tp_new.grib |
|
|
...
How could you use the grib_to_netcdf tool to convert the GRIB messages in file1.grib to netCDF and store the result in a file named out1.nc using the default NC_SHORT netCDF data type ?
...