2013-03-25 12:04:10 +00:00
|
|
|
/*! \page grib_set grib_set
|
|
|
|
\section DESCRIPTION
|
|
|
|
Sets key/value pairs in the input grib file and writes
|
|
|
|
each message to the output_grib_file.
|
|
|
|
It fails when an error occurs (e.g. key not found).
|
|
|
|
|
|
|
|
\section USAGE
|
|
|
|
grib_set
|
|
|
|
[options] grib_file grib_file ... output_grib_file
|
|
|
|
|
|
|
|
\section OPTIONS
|
2016-06-16 17:52:29 +00:00
|
|
|
-s key[:{s/d/i}]=value,key[:{s/d/i}]=value,... \n
|
2013-03-25 12:04:10 +00:00
|
|
|
Key/values to set.
|
2016-06-16 17:52:29 +00:00
|
|
|
For each key a string (key:s), a double (key:d) or an integer (key:i)
|
2013-03-25 12:04:10 +00:00
|
|
|
type can be defined. By default the native type is set.
|
|
|
|
\n \n -r \n Repack data. Sometimes after setting some keys involving properties
|
|
|
|
of the packing algorithm a repacking of data is needed.
|
|
|
|
This repacking is performed setting this -r option.
|
|
|
|
\n \n -d value \n
|
|
|
|
Set all the data values to "value".
|
2016-06-16 17:52:29 +00:00
|
|
|
\n \n -p key[:{s/d/i}],key[:{s/d/i}],... \n
|
2013-03-25 12:04:10 +00:00
|
|
|
Declaration of keys to print.
|
2016-06-16 17:52:29 +00:00
|
|
|
For each key a string (key:s), a double (key:d) or an integer (key:i)
|
2013-03-25 12:04:10 +00:00
|
|
|
type can be requested. Default type is string.
|
2016-06-16 17:52:29 +00:00
|
|
|
\n \n -P key[:{s/d/i}],key[:{s/d/i}],... \n
|
2013-03-25 12:04:10 +00:00
|
|
|
As -p adding the declared keys to the default list.
|
2016-06-16 17:52:29 +00:00
|
|
|
\n \n -w key[:{s/d/i}]{=/!=}value,key[:{s/d/i}]=value,... \n
|
2013-03-25 12:04:10 +00:00
|
|
|
Where clause.
|
2018-12-28 12:00:18 +00:00
|
|
|
Set is only executed for GRIB messages matching all the key/value constraints.
|
|
|
|
If a GRIB message does not match the constraints it is copied unchanged
|
|
|
|
to the output_grib_file. This behaviour can be changed by setting the -S option.
|
2016-06-16 17:52:29 +00:00
|
|
|
A valid constraint is of type key=value or key!=value.
|
|
|
|
For each key a string (key:s), a double (key:d) or an integer (key:i)
|
2013-03-25 12:04:10 +00:00
|
|
|
type can be defined. Default type is string.
|
|
|
|
\n \n -7 \n Does not fail when the message has wrong length
|
2018-12-28 12:00:18 +00:00
|
|
|
\n \n -S \n Strict. Only GRIB messages matching all the constraints are copied to
|
2013-03-25 12:04:10 +00:00
|
|
|
the output file
|
|
|
|
\n \n -V \n Version.
|
2018-12-28 12:00:18 +00:00
|
|
|
\n \n -M \n Multi-field support off. Turn off support for multiple fields in single GRIB message.
|
2013-03-25 12:04:10 +00:00
|
|
|
\n \n -g \n Copy GTS header.
|
|
|
|
\n \n -G \n GRIBEX compatibility mode.
|
2016-06-16 17:52:29 +00:00
|
|
|
\n \n -T T | B | M | A \n Message type. T->GTS, B->BUFR, M->METAR (Experimental),A->Any (Experimental).
|
|
|
|
The input file is interpreted according to the message type.
|
2013-03-25 12:04:10 +00:00
|
|
|
\n \n -f \n Force. Force the execution not to fail on error.
|
|
|
|
\n \n -v \n Verbose.
|
|
|
|
\n \n
|
|
|
|
\section grib_set_examples grib_set examples
|
|
|
|
-# To set productDefinitionTemplateNumber=2 only for the fields with productDefinitionTemplateNumber=11 \n
|
|
|
|
\verbatim
|
|
|
|
>grib_set -s productDefinitionTemplateNumber=2 -w productDefinitionTemplateNumber=11 ../data/tigge_pf_ecmwf.grib2 out.grib2
|
|
|
|
\endverbatim\n
|
|
|
|
-# To set productDefinitionTemplateNumber=2 only for the fields for which productDefinitionTemplateNumber is not equal to 11 \n
|
|
|
|
\verbatim
|
|
|
|
>grib_set -s productDefinitionTemplateNumber=2 -w productDefinitionTemplateNumber!=11 tigge_pf_ecmwf.grib2 out.grib2
|
|
|
|
\endverbatim\n
|
|
|
|
-# When a key is not used all the bits of its value should be set to 1 to indicate that it is missing. Since the length
|
|
|
|
(number of octet) is different from a key to another, the value that we have to code for missing keys is not unique.
|
|
|
|
To give an easy way to set a key to missing a string "missing" or "MISSING" is accepted by grib_set as follows:\n
|
|
|
|
\verbatim
|
|
|
|
>grib_set -s scaleFactorOfFirstFixedSurface=missing,scaledValueOfFirstFixedSurface=MISSING ../data/regular_latlon_surface.grib2 out.grib2
|
|
|
|
\endverbatim\n
|
2021-10-03 17:06:50 +00:00
|
|
|
Since some values cannot be set to missing you can get an error for those keys.\n
|
2013-03-25 12:04:10 +00:00
|
|
|
-# To set scaleFactorOfSecondFixedSurface to missing only for the fields for which scaleFactorOfSecondFixedSurface is not missing: \n
|
|
|
|
\verbatim
|
|
|
|
>grib_set -s scaleFactorOfSecondFixedSurface=missing -w scaleFactorOfSecondFixedSurface!=missing tigge_pf_ecmwf.grib2 out.grib2
|
|
|
|
\endverbatim\n
|
2018-12-28 12:00:18 +00:00
|
|
|
-# It's possible to produce a GRIB edition 2 file from a GRIB edition 1 just changing the edition number with grib_set.
|
2013-03-25 12:04:10 +00:00
|
|
|
At this stage of development all the geography parameters, level and time information is correctly translated, for the product
|
2018-01-15 13:45:31 +00:00
|
|
|
definition extra 'set' calls must be done. To do this properly, use the tool grib_filter.\n
|
2013-03-25 12:04:10 +00:00
|
|
|
\verbatim
|
|
|
|
grib_set -s edition=2 ../data/reduced_gaussian_pressure_level.grib1
|
|
|
|
\endverbatim\n
|
|
|
|
-# With grib edition 2 is possible to compress data using the jpeg algorithm.
|
|
|
|
To change packing algorithm from grid_simple (simple packing) to grid_jpeg (jpeg2000 packing):\n
|
|
|
|
\verbatim
|
|
|
|
>grib_set -s packingType=grid_jpeg ../data/regular_gaussian_model_level.grib2 out.grib2
|
|
|
|
\endverbatim\n
|
|
|
|
-# It's possible to ask grib_api to calculate the number of bits per value needed to pack a given
|
|
|
|
field with a fixed number of decimal digits of precision. For example if we want to pack a temperature
|
|
|
|
expressed in Kelvin with 1 digits of precision after the decimal point we can set changeDecimalPrecision=1 \n
|
|
|
|
\verbatim
|
|
|
|
>grib_set -s changeDecimalPrecision=1 ../data/regular_latlon_surface.grib2 ../data/out.grib2
|
|
|
|
rm -f ../data/out.grib2 | true
|
|
|
|
./grib_set -s changeDecimalPrecision=1 ../data/regular_latlon_surface.grib2 ../data/out.grib2
|
|
|
|
\endverbatim\n
|
|
|
|
*/
|