def test_metadata(self): """Metadata is read correctly from BufrMessage.""" with BufrFile(TESTBUFR) as bufr_file: msg = BufrMessage(bufr_file) msg.unpack() msg_keys = list(msg.keys()) self.assertEqual(len(msg_keys), 146) for key in KNOWN_BUFR_KEYS: assert key in msg_keys # Size of message in bytes self.assertEqual(msg.size(), 220) self.assertEqual(len(list(msg.keys())), len(msg))
def test_metadata(self): """Metadata is read correctly from BufrMessage.""" with BufrFile(TESTBUFR) as bufr_file: msg = BufrMessage(bufr_file) msg.unpack() msg_keys = msg.keys() self.assertEqual(len(msg_keys), 140) for key in KNOWN_BUFR_KEYS: assert key in msg_keys # Size of message in bytes self.assertEqual(msg.size(), 220) self.assertEqual(len(msg.keys()), len(msg))
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)
def test_content(self): """Data values are read correctly from BufrMessage.""" with BufrFile(TESTBUFR) as bufr_file: msg = BufrMessage(bufr_file) msg.unpack() self.assertEqual(msg["airTemperatureAt2M"], 274.5)
def test_content(self): """Data values are read correctly from BufrMessage.""" with BufrFile(TESTBUFR) as bufr_file: msg = BufrMessage(bufr_file) msg.unpack() self.assertEqual(msg["airTemperatureAt2M"], 274.5)