Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Confirmed: This was the most recent edition of this training course

...

Expand
titleSolution...

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:

Code Block
   % grib_copy -w shortName=t file1.grib1 t.grib1

Similarly to copy only those messages for parameter Z, use:

Code Block
   % grib_copy -w shortName=z file1.grib1 z.grib1

Or, more simply, and because the file contains only parameters T and Z, one can use:

Code Block
  % grib_copy file.grib1 “[shortName]_an_pl.grib1”

Using grib_ls of the two files confirms that the contents are correct.   For example:

Code Block
% grib_ls -p centre,shortName,typeOfLevel,level,dataDate t.grib1
  t.grib1
  centre       shortName    typeOfLevel  level        dataDate     
  ecmf         t            isobaricInhPa  1000        20190201     
  ecmf         t            isobaricInhPa  850         20190201     
  ecmf         t            isobaricInhPa  700         20190201     
  ecmf         t            isobaricInhPa  500         20190201     
  ecmf         t            isobaricInhPa  400         20190201     
  ecmf         t            isobaricInhPa  300         20190201 
  6 of 6 grib messages in t.grib1
 
  6 of 6 total grib messages in 1 files

...

Expand
titleSolution...

To reorder the messages in order of ascending pressure level, use, e.g.:

Code Block
% grib_copy -B “level:li asc” file.grib1 “[shortName]_ordered.grib1”

Note the use of “level:l” 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:

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

...

2. Use grib_set to change the date and time to 12UTC on 4 February 2019 for all messages in file1.grib1

...