Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

This command generates a python code script that contains the code to update the bufr_encode_new function.

...

ibufr = codes_bufr_new_from_samples('BUFR4') 

is not needed This function message_encoding generates handles to bufr messages using a template BUFR4_local that is part of ecCodes installation ( can be seen by using codes_info)as the message handle is provided by the message_encoding function.


Code Block
languagepy
titlemessage_encode
def message_encoding(FullInputFileName,fout):
    '''
    Message encoding function 
    FullInputFilename      :     full path of the Ascii file for example /tmp/data/rema_20180918.txt
    fout                   :     file Object to write the output bufr file( obtained by a call to open )
    
    Requires ecCodes and the BUFR4_local template on  
                 ECCODES_PATH/share/eccodes/samples

    '''
    TEMPLATE='BUFR4_local'
    
    # reads the Ascii file into a pandas Dataframe
    dfFull=read_ascii(FullInputFileName)
  
    # loops over the rows of the dataFrame dfFull  
    for _,row in dfFull.iterrows():
        bid=codes_bufr_new_from_samples(TEMPLATE)
        try:
            bufr_encode_new(bid,row)
            codes_write(bid,fout)
        except CodesInternalError as ec:
            print ec
        codes_release(bid)

...