You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 34 Next »

DESCRIPTION

Apply the rules defined in rules_file to each BUFR message in the BUFR files provided as arguments.

USAGE

bufr_filter [options] rules_file file file ...

OPTIONS


-f

Force. Force the execution not to fail on error.


-o output_grib_file

Output grib is written to output_grib_file. If an output grib file is required and -o is not used, the output grib is written to filtered.out


-V

Version.


-g

Copy GTS header.


-7

Does not fail when the message has wrong length


-v

Verbose.

bufr_filter examples

  1. The bufr_filter processes sequentially all bufr messages contained in the input files and applies the rules to each one of them. Input messages can be written to the output by using the "write" statement. The write statement can be parameterised so that output is sent to multiple files depending on key values used in the output file name.


  2. BUFR header information can be accessed witout unpacking the data. This rules_file:

    print "[bufrHeaderCentre] [bufrHeaderSubCentre] [masterTablesVersionNumber] [localTablesVersionNumber] [numberOfSubsets]";
    
    will result in the the follwing output:
    > bufr_filter rules_file ../data/bufr/syno_multi.bufr
    98 0 13 1 1
    98 0 13 1 1
    98 0 13 1 1
    


  3. To print values from the data section the messages have to be unpacked. This rules_file:

    set unpack=1;
    print "block=[blockNumber] station=[stationNumber] lat=[latitude] lon=[longitude] t2=[airTemperatureAt2M]";
    
    will print out some data values from the specified SYNOP BUFR messages.
    > bufr_filter rules_file ../data/bufr/syno_multi.bufr
    block=1 station=1 lat=70.93 lon=-8.67 t2=274.5
    block=1 station=3 lat=77 lon=15.5 t2=268.4
    block=1 station=7 lat=78.92 lon=11.93 t2=268.5
    


  4. bufr_filter allows defining new keys with the transient keyword. We will further develop the previous example by creating a new key to combine the block number and the station number into the full WMO station id:

    set unpack=1;
    transient statid=1000*blockNumber+stationNumber;
    print "statid=[statid] lat=[latitude] lon=[longitude] t2=[airTemperatureAt2M]";
    
    The result is:
    > bufr_filter rules_file ../data/bufr/syno_multi.bufr
    statid=1001 lat=70.93 lon=-8.67 t2=274.5
    statid=1003 lat=77 lon=15.5 t2=268.4
    statid=1007 lat=78.92 lon=11.93 t2=268.5
    


  5. To access the attributes belonging to the keys use the -> operator. The example below prints the attributes of key "pressure" from a SYNOP BUFR message.

    print "pressure=[pressure] [pressure->units]";
    print "pressure->code=[pressure->code!06d]";
    print "pressure->scale=[pressure->scale]";
    print "pressure->reference=[pressure->reference]";
    print "pressure->width=[pressure->width]";
    print "pressure->percentConfidence=[pressure->percentConfidence] [pressure->percentConfidence->units]";
    print "pressure->percentConfidence->code=[pressure->percentConfidence->code!06d]";
    print "pressure->percentConfidence->scale=[pressure->percentConfidence->scale]";
    print "pressure->percentConfidence->reference=[pressure->percentConfidence->reference]";
    print "pressure->percentConfidence->width=[pressure->percentConfidence->width]";
    
    The result is:
    > bufr_filter rules_file ../data/bufr/syno_1.bufr
    pressure=100910 Pa
    pressure->code=010004
    pressure->scale=-1
    pressure->reference=0
    pressure->width=14
    pressure->percentConfidence=74 %
    pressure->percentConfidence->code=033007
    pressure->percentConfidence->scale=0
    pressure->percentConfidence->reference=0
    pressure->percentConfidence->width=7
    


  6. To access elements by rank (i.e. by their occurence in the message) use the # operator. The example below prints the 4th value of key "pressure" from a TEMP BUFR message.

    set unpack=1;
    print "pressure=[pressure#4] [pressure#4->units]";
    print "pressure=[pressure]";
    
    The result is:
    > bufr_filter rules_file ../data/bufr/temp_101.bufr
    pressure=98500 Pa
    pressure=102000 101800 100000 98500 96400 92500 92100 89700 
    88100 86100 85000 84400 79400 79000 78300 77300 
    71900 70000 69400 65100 61200 53400 50000 43900 
    40000 39900 37800 31600 30000 27500 25000 21200 
    21000 20600 20400 20000 19300 18400 17000 16600 
    15100 15000 14600 14000 13400 13200 12900 11100 
    10800 10000 8960 7630 7000 6420 6190 5770 
    5320 5000 3970 3570 3190 3090 3000 2820 
    2630 2400 2340 2050 2000 1680 1530 1500 
    1380 1300 1210 31600
    


  7. It is possible to access elements by conditions imposed on coordinate descriptors. The example below prints the temperature values on temperature significant levels from a TEMP BUFR message. For temperature significant levels the value of key "verticalSoundingSignificance" is 4 and this is what we use in the condition. As a reference, we also print all the verticalSoundingSignificance and airTemperature values found in the message.

    set unpack=1;
    print "----- /verticalSoundingSignificance=4/airTemperature -----";
    print "[/verticalSoundingSignificance=4/airTemperature]";
    print "----- verticalSoundingSignificance -----";
    print "[verticalSoundingSignificance]";
    print "----- airTemperature -----";
    print "[airTemperature]";
    
    The result is:
    > bufr_filter rules_file ../data/bufr/temp_101.bufr
    ----- /verticalSoundingSignificance=4/airTemperature -----
    272.1 269.5 268.1 267.9 266.7 266.1 264.9 264.9 
    260.5 260.9 263.5 263.7 261.7 261.9 259.1 258.9 
    251.5 243.9 238.3 236.7 221.7 212.7 215.5 215.9 
    214.1 217.3 218.3 217.3 219.3 218.9 219.5 217.9 
    218.3 217.5 220.3 219.1 220.1 217.3 216.5 217.7 
    215.9 217.1 213.5 216.1 214.7 216.1 215.3 216.5 
    213.9 215.3 215.7 212.7 214.1 216.1 213.7 215.3 
    214.9
    ----- verticalSoundingSignificance -----
    68 4 32 4 4 32 4 4 
    4 4 32 4 4 4 4 4 
    4 32 4 4 4 4 32 4 
    32 4 4 8 32 4 32 20 
    4 4 4 32 4 4 4 4 
    4 32 4 4 4 4 4 4 
    4 32 4 4 32 4 4 4 
    4 32 4 4 4 4 32 4 
    4 4 4 4 32 4 4 4 
    4 4 4 8
    ----- airTemperature -----
    272.1 272.1 270.5 269.5 268.1 267.9 267.9 266.7 
    266.1 264.9 264.9 264.9 260.5 260.9 263.5 263.7 
    261.7 261.7 261.9 259.1 258.9 251.5 248.9 243.9 
    238.5 238.3 236.7 -1e+100 226.1 221.7 218.7 212.7 
    212.7 215.5 215.9 215.1 214.1 217.3 218.3 217.3 
    219.3 219.1 218.9 219.5 217.9 218.3 217.5 220.3 
    219.1 217.9 220.1 217.3 217.5 216.5 217.7 215.9 
    217.1 215.5 213.5 216.1 214.7 216.1 216.3 215.3 
    216.5 213.9 215.3 215.7 215.1 212.7 214.1 216.1 
    213.7 215.3 214.9
    


  • No labels