示例#1
0
 def test_serialize(self):
     """Message can be serialized to file."""
     with BufrFile(TESTBUFR) as bufr_file:
         msg = BufrMessage(bufr_file)
         with open(TEST_OUTPUT, "w") as test:
             msg.write(test)
     os.unlink(TEST_OUTPUT)
示例#2
0
 def test_serialize(self):
     """Message can be serialized to file."""
     with BufrFile(TESTBUFR) as bufr_file:
         msg = BufrMessage(bufr_file)
         with open(TEST_OUTPUT, "w") as test:
             msg.write(test)
     os.unlink(TEST_OUTPUT)
示例#3
0
 def test_copy_data(self):
     """Can copy data section from one message to another"""
     bufr = BufrMessage(sample='BUFR3')
     with BufrFile('../../data/bufr/metar_with_2_bias.bufr') as bufr_file:
         bufrin = BufrMessage(bufr_file)
         ivalues=(
             0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
             0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
             0, 0, 0, 1, 1, 1, 1, 1, 1, 1,
             1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
             1, 1, 1, 1, 1, 0, 1, 1, 1, 1,
             1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
             1, 1, 1, 1, 1, 1, 1, 1, 0)
         bufr['inputDataPresentIndicator'] = ivalues
         bufr['edition'] = 3
         bufr['masterTableNumber'] = 0
         bufr['bufrHeaderSubCentre'] = 0
         bufr['bufrHeaderCentre'] = 98
         bufr['updateSequenceNumber'] = 1
         bufr['dataCategory'] = 0
         bufr['dataSubCategory'] = 140
         bufr['masterTablesVersionNumber'] = 13
         bufr['localTablesVersionNumber'] = 1
         bufr['typicalYearOfCentury'] = 15
         bufr['typicalMonth'] = 5
         bufr['typicalDay'] = 4
         bufr['typicalHour'] = 9
         bufr['typicalMinute'] = 30
         bufr['numberOfSubsets'] = 1
         bufr['observedData'] = 1
         bufr['compressedData'] = 0
         ivalues=(
             307011,7006,10004,222000,101023,31031,1031,1032,101023,33007,
             225000,236000,101023,31031,1031,1032,8024,101001,225255,225000,
             236000,101023,31031,1031,1032,8024,101001,225255,
             1063,2001,4001,4002,4003,4004,4005,5002,
             6002,7001,7006,11001,11016,11017,11002)
         bufr['unexpandedDescriptors'] = ivalues
         bufrin.unpack()
         bufrin.copy_data(bufr)
         with open(TEST_OUTPUT, 'w') as test:
             bufr.write(test)
         os.unlink(TEST_OUTPUT)