Skip to end of metadata
Go to start of metadata

In a BUFR message the same key can appear several times in different positions of the message. From ecCodes version 0.13.0 it is possible to set a key by rank and in the following bufr_filter example the 4th instance of the key airTemperature is set to the value "300.1". The value of the key is then printed.

instructions.filter
set unpack=1;
set #4#airTemperature = 300.1;
print "#4#airTemperature=[#4#airTemperature]";
 
set pack=1;
write;

It is very important to remember that the key is not encoded back in the data section until the key "pack" is set to 1. At line 5 the encoding is performed and at line 6 the message is written in the output file. The instruction.filters file can be used as follows

bufr_filter -o out.bufr instructions.filter in.bufr

The output file out.bufr will contain the newly encoded value of the 4th instance of the airTemperature key. If in the original message in.bufr the 4th instance of airTemperature is not present because for example there are only two airTemperature keys a "key not found" error is returned.

Please note: One cannot set such keys by using the "/subsetNumber=N/" notation. You must use the rank notation above.


  • No labels