grib_set

grib_set(fs, keys_and_values, repack=False)

Sets information in the GRIB header of fs and returns a new Fieldset.

Parameters
  • fs (Fieldset) – input fieldset

  • keys_and_values (list) – the ecCodes keys and values

  • repack (bool) – repack data. Sometimes after setting some ecCodes keys (e.g. packingType) involving properties of the packing algorithm a repacking of data is needed. New in Metview version 5.17.0

Return type

Fieldset

keys_and_values has to be a list of the ecCodes keys and their values following each other. The actual data types are deduced from the values passed (and not from the key name!).

Examples
import metview as mv

f = mv.read("my.grib")
f = mv.grib_set(f,
   ["date", 20150601,       # int
    "time", 0600,           # int
    "stepType", "avg",      # str
    "startStep", 0 ,        # int
    "endStep", 31,          # int
    "longitudeOfLastGridPointInDegrees", 100.5])  #  float
import metview as mv

# GRIB data with ccsds packing
f = mv.read("ccsds.grib")
# when we change the packing type repacking must be used
f = mv.grib_set(f, ["packingType", "grid_simple"], repack=True)
grib_set_long(fs, keys_and_values, repack=False)
grib_set_double(fs, keys_and_values, repack=False)
grib_set_string(fs, keys_and_values, repack=False)
grib_set_long_array(fs, keys_and_values, repack=False)

Sets information in the GRIB header of fs and returns a new Fieldset.

Parameters
  • fs (Fieldset) – input fieldset

  • keys_and_values (list) – the ecCodes keys and values

  • repack (bool) – repack data. Sometimes after setting some ecCodes keys (e.g. packingType) involving properties of the packing algorithm a repacking of data is needed. New in Metview version 5.17.0

Return type

Fieldset

keys_and_values has to be a list of the ecCodes keys and their values following each other. The actual values have to match the type of the function. grib_set_long_array expects a vector containing the values. If applied to a multi-field fieldset, then all fields are modified.

Example
f = mv.grib_set_long(f,
   ["centre", 99,
    "level", 200])