Page tree
Skip to end of metadata
Go to start of metadata

Question 1

Use grib_get to obtain a list all of the pressure levels available for the parameter T in the file tz_an_pl.grib1


Use grib_get with the -w option to specify a shortName=t.

% grib_get -w shortName=t -p level tz_an_pl.grib1 1000 850 700 500 400 300

Note that you can use any of the other aliases for level: "-p lev" or "-p levelist" will produce the same list. Similarly, other keys can be used to specify the parameter, e.g., “paramId=130”.

Question 2

Use grib_get to print the shortName, dataDate, dataTime and level for the  500 and 1000 hPa levels only in tz_an_pl.grib1.



% grib_get -w level=500/1000 -p shortName,dataDate,dataTime,level tz_an_pl.grib1 z 20180223 0 1000 t 20180223 0 1000 z 20180223 0 500 t 20180223 0 500

Question 3

Use grib_get to print the stepRange for the field in surface.grib1 in (a) hours (b) minutes and (c) seconds. What happens ?

	% grib_get -p stepRange surface.grib1
	ECCODES ERROR   :  unable to represent the step in h
   	                 	Hint: try changing the step units
	ECCODES ERROR   :  Decoding invalid

The error occurs because the stepRange of one of the fields cannot be represented in hours. Similarly, using the “-s” option to set stepUnits=m to obtain the stepRange in (b) minutes gives:


	% grib_get -s stepUnits=m -p stepRange surface.grib1
	ECCODES ERROR   :  unable to represent the step in m
    	                Hint: try changing the step units
	ECCODES ERROR   :  Decoding invalid

Finally, with stepUnits=s we obtain:

% grib_get –s stepUnits=s -p stepRange surface.grib1 10800 11400 11450

Question 4 

User grib_get_data to print the latitude, longitude and values for the first field in surface.grib1.

  • Output the data values in decimal format with 5 decimal places
  • Output the data values in exponential format with 10 decimal places
  • Are there any missing values ?

Use grib_get_data with "-w count=1" to restrict to the first field only and specify the format with the "-F" option

% grib_get_data -w count=1 -F "%.5f" surface.grib1 Latitude, Longitude, Value 2.500 -20.000 301.94104 2.500 -17.500 302.15637 2.500 -15.000 301.96082 2.500 -12.500 301.84155 2.500 -10.000 302.04504 2.500 -7.500 301.92847 ...

Exponential format with 10 decimal places is the default !

% grib_get_data -w count=1 surface.grib1 Latitude, Longitude, Value 2.500 -20.000 3.0194104004e+02 2.500 -17.500 3.0215637207e+02 2.500 -15.000 3.0196081543e+02 2.500 -12.500 3.0184155273e+02 2.500 -10.000 3.0204504395e+02 2.500 -7.500 3.0192846680e+02 ...

Additional information can be printed along with the latitude, longitude and value by using the -p option.  For example:

% grib_get_data -w count=1 -p centre,dataDate,stepRange surface.grib1 Latitude, Longitude, Value, centre, dataDate, stepRange 2.500 -20.000 3.0194104004e+02 ecmf 20180223 3 2.500 -17.500 3.0215637207e+02 ecmf 20180223 3 2.500 -15.000 3.0196081543e+02 ecmf 20180223 3 2.500 -12.500 3.0184155273e+02 ecmf 20180223 3 2.500 -10.000 3.0204504395e+02 ecmf 20180223 3 2.500 -7.500 3.0192846680e+02 ecmf 20180223 3 ...

Note that the additional keys are always printed after the latitude, longitude and values.

To check for missing values use grib_get_data with the –m option:


	% grib_get_data -w count=1 –m MISSING surface.grib1
	  Latitude, Longitude, Value
    	2.500    5.000 3.0202160645e+02
2.500 7.500 3.0177075195e+02 2.500 10.000 MISSING 0.000 -20.000 3.0146936035e+02 0.000 -17.500 3.0119396973e+02 ...


Question 5

Use grib_get_data to print the data values in temperature at 500 hPa only from the file in tz_an_pl.grib1

  • Make sure you print only the data for T at 500 hPa
  • What is printed ?

Use grib_get_data with the where option to specify only shortName=t and level=500:


	% grib_get_data -w shortName=t,level=500, tz_an_pl.grib1

In this case, only the data values are printed; there are no values of latitude and longitude. This is because the field is stored in spectral representation. The values shown are not the values of temperature at 500 hPa. Instead, the data values printed are those of the spectral components of the field. In this case, it is not possible for grib_get_data to determine latitude-longitude values.

  • No labels