mirror of https://github.com/ecmwf/eccodes.git
104 lines
6.1 KiB
HTML
104 lines
6.1 KiB
HTML
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
|
<html><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
|
|
<title>grib_api: grib_set</title>
|
|
<link href="doxygen.css" rel="stylesheet" type="text/css">
|
|
<link href="tabs.css" rel="stylesheet" type="text/css">
|
|
</head><body>
|
|
<!-- Generated by Doxygen 1.5.3 -->
|
|
<div class="tabs">
|
|
<ul>
|
|
<li><a href="index.html"><span>Main Page</span></a></li>
|
|
<li><a href="modules.html"><span>Modules</span></a></li>
|
|
<li><a href="files.html"><span>Files</span></a></li>
|
|
<li><a href="pages.html"><span>Related Pages</span></a></li>
|
|
<li><a href="examples.html"><span>Examples</span></a></li>
|
|
</ul>
|
|
</div>
|
|
<h1><a class="anchor" name="grib_set">grib_set</a></h1><h2><a class="anchor" name="DESCRIPTION">
|
|
DESCRIPTION</a></h2>
|
|
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).<h2><a class="anchor" name="USAGE">
|
|
USAGE</a></h2>
|
|
grib_set [options] grib_file grib_file ... output_grib_file<h2><a class="anchor" name="OPTIONS">
|
|
OPTIONS</a></h2>
|
|
-s key[:{s/d/l}]=value,key[:{s/d/l}]=value,... <br>
|
|
Key/values to set. For each key a string (key:s) or a double (key:d) or a long (key:l) type can be defined. By default the native type is set. <br>
|
|
<br>
|
|
-r <br>
|
|
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. <br>
|
|
<br>
|
|
-d value <br>
|
|
Set all the data values to "value". <br>
|
|
<br>
|
|
-p key[:{s/d/l}],key[:{s/d/l}],... <br>
|
|
Declaration of keys to print. For each key a string (key:s) or a double (key:d) or a long (key:l) type can be requested. Default type is string. <br>
|
|
<br>
|
|
-P key[:{s/d/l}],key[:{s/d/l}],... <br>
|
|
As -p adding the declared keys to the default list. <br>
|
|
<br>
|
|
-w key[:{s/d/l}]=value,key[:{s/d/l}]=value,... <br>
|
|
Where clause. 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 setting the option -S. For each key a string (key:s) or a double (key:d) or a long (key:l) type can be defined. Default type is string. <br>
|
|
<br>
|
|
-7 <br>
|
|
Does not fail when the message has wrong length <br>
|
|
<br>
|
|
-S <br>
|
|
Strict. Only grib messages matching all the constraints are copied to the output file <br>
|
|
<br>
|
|
-V <br>
|
|
Version. <br>
|
|
<br>
|
|
-M <br>
|
|
Multi-grib support off. Turn off support for multiple fields in single grib message <br>
|
|
<br>
|
|
-g <br>
|
|
Copy GTS header. <br>
|
|
<br>
|
|
-G <br>
|
|
GRIBEX compatibility mode. <br>
|
|
<br>
|
|
-f <br>
|
|
Force. Force the execution not to fail on error. <br>
|
|
<br>
|
|
-v <br>
|
|
Verbose. <br>
|
|
<br>
|
|
<h2><a class="anchor" name="grib_set_examples">
|
|
grib_set examples</a></h2>
|
|
<ol type=1>
|
|
<li>To set productDefinitionTemplateNumber=2 only for the fields with productDefinitionTemplateNumber=11 <br>
|
|
<div class="fragment"><pre class="fragment">
|
|
>grib_set -s productDefinitionTemplateNumber=2 -w productDefinitionTemplateNumber=11 ../data/tigge_pf_ecmwf.grib2 out.grib2
|
|
</pre></div><br>
|
|
</li><li>To set productDefinitionTemplateNumber=2 only for the fields for which productDefinitionTemplateNumber is not equal to 11 <br>
|
|
<div class="fragment"><pre class="fragment">
|
|
>grib_set -s productDefinitionTemplateNumber=2 -w productDefinitionTemplateNumber!=11 tigge_pf_ecmwf.grib2 out.grib2
|
|
</pre></div><br>
|
|
</li><li>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:<br>
|
|
<div class="fragment"><pre class="fragment">
|
|
>grib_set -s scaleFactorOfFirstFixedSurface=missing,scaledValueOfFirstFixedSurface=MISSING ../data/regular_latlon_surface.grib2 out.grib2
|
|
</pre></div><br>
|
|
Since some values can not be set to missing you can get an error for those keys.</li><li>To set scaleFactorOfSecondFixedSurface to missing only for the fields for which scaleFactorOfSecondFixedSurface is not missing: <br>
|
|
<div class="fragment"><pre class="fragment">
|
|
>grib_set -s scaleFactorOfSecondFixedSurface=missing -w scaleFactorOfSecondFixedSurface!=missing tigge_pf_ecmwf.grib2 out.grib2
|
|
</pre></div><br>
|
|
</li><li>It's possible to produce a grib edition 2 file from a grib edition 1 just changing the edition number with grib_set. At this stage of development all the geography parameters, level and time information is correctly translated, for the product definition extra set calls must be done. To do this properly <a class="el" href="grib_convert.html">grib_convert</a> is suggested. <br>
|
|
<div class="fragment"><pre class="fragment">
|
|
grib_set -s editionNumber=2 ../data/reduced_gaussian_pressure_level.grib1
|
|
</pre></div><br>
|
|
</li><li>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):<br>
|
|
<div class="fragment"><pre class="fragment">
|
|
>grib_set -s packingType=grid_jpeg ../data/regular_gaussian_model_level.grib2 out.grib2
|
|
</pre></div><br>
|
|
</li><li>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 <br>
|
|
<div class="fragment"><pre class="fragment">
|
|
>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
|
|
</pre></div><br>
|
|
</li></ol>
|
|
<hr size="1"><address style="text-align: right;"><small>Generated on Tue Sep 22 15:18:22 2009 for grib_api by
|
|
<a href="http://www.doxygen.org/index.html">
|
|
<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.3 </small></address>
|
|
</body>
|
|
</html>
|