本文整理汇总了Python中mi.dataset.parser.velpt_ab.VelptAbParser.get_records方法的典型用法代码示例。如果您正苦于以下问题:Python VelptAbParser.get_records方法的具体用法?Python VelptAbParser.get_records怎么用?Python VelptAbParser.get_records使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mi.dataset.parser.velpt_ab.VelptAbParser
的用法示例。
在下文中一共展示了VelptAbParser.get_records方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_jumbled
# 需要导入模块: from mi.dataset.parser.velpt_ab import VelptAbParser [as 别名]
# 或者: from mi.dataset.parser.velpt_ab.VelptAbParser import get_records [as 别名]
def test_jumbled(self):
"""
Read files and verify that all expected particles can be read.
This particular data file has the velocity data records
preceded by the diagnostics records, a situation not likely
to occur on a deployed instrument but anything is possible!
The logic in the parser will not produce an instrument metadata
particle (configuration data) until it encounters a velocity or
a diagnostics record. Assumes that all the configuration records are
at the beginning of the file. This is reasonable as the instrument is
configured before being deployed. So the config records would be stored
first. Verify that the contents of the particles are correct.
There should be no exceptions generated.
"""
log.debug('===== START TEST SIMPLE NOT IN ORDER =====')
# Test the telemetered version
with open(os.path.join(RESOURCE_PATH, 'jumbled_VELPT_SN_11402_2014-07-02.aqd'), 'rb') as file_handle:
num_particles_to_request = num_expected_particles = 72
parser = VelptAbParser(self._parser_config,
file_handle,
self.exception_callback)
particles = parser.get_records(num_particles_to_request)
self.assertEquals(len(particles), num_expected_particles)
self.assert_particles(particles, 'jumbled_VELPT_SN_11402_2014-07-02.yml', RESOURCE_PATH)
log.debug('===== END TEST SIMPLE NOT IN ORDER =====')
示例2: test_bad_diag_checksum_21_recs
# 需要导入模块: from mi.dataset.parser.velpt_ab import VelptAbParser [as 别名]
# 或者: from mi.dataset.parser.velpt_ab.VelptAbParser import get_records [as 别名]
def test_bad_diag_checksum_21_recs(self):
"""
The file used in this test has a power record with a missing timestamp.
This results in 9 particles being retrieved instead of 10, and also result in the exception
callback being called.
"""
log.debug('===== START TEST FOUND BAD DIAG HDR CHECKSUM AND TOO MANY RECS =====')
with open(os.path.join(RESOURCE_PATH, 'bad_diag_hdr_checksum_21_diag_VELPT_SN_11402_2014-07-02.aqd'), 'rb')\
as file_handle:
num_particles_to_request = num_expected_particles = 118
parser = VelptAbParser(self._parser_config,
file_handle,
self.exception_callback)
particles = parser.get_records(num_particles_to_request)
self.assertEquals(len(particles), num_expected_particles)
self.assert_particles(particles, 'bad_diag_hdr_checksum_21_diag_VELPT_SN_11402_2014-07-02.yml',
RESOURCE_PATH)
log.debug('===== END TEST FOUND BAD DIAG HDR CHECKSUM AND TOO MANY RECS =====')
示例3: test_bad_diagnostic_checksum
# 需要导入模块: from mi.dataset.parser.velpt_ab import VelptAbParser [as 别名]
# 或者: from mi.dataset.parser.velpt_ab.VelptAbParser import get_records [as 别名]
def test_bad_diagnostic_checksum(self):
"""
The file used in this test has a record with a bad checksum.
This results in 71 particles being retrieved instead of 72.
"""
log.debug('===== START TEST FOUND BAD DIAGNOSTICS CHECKSUM =====')
with open(os.path.join(RESOURCE_PATH, 'bad_diag_checksum_VELPT_SN_11402_2014-07-02.aqd'), 'rb') as file_handle:
num_particles_to_request = num_expected_particles = 71
parser = VelptAbParser(self._parser_config,
file_handle,
self.exception_callback)
particles = parser.get_records(num_particles_to_request)
self.assertEquals(len(particles), num_expected_particles)
self.assert_particles(particles, 'too_few_VELPT_SN_11402_2014-07-02.yml', RESOURCE_PATH)
log.debug('===== END TEST FOUND BAD DIAGNOSTICS CHECKSUM =====')
示例4: test_invalid_record_id
# 需要导入模块: from mi.dataset.parser.velpt_ab import VelptAbParser [as 别名]
# 或者: from mi.dataset.parser.velpt_ab.VelptAbParser import get_records [as 别名]
def test_invalid_record_id(self):
"""
The file used in this test has one record with an invalid ID byte.
This results in 71 particles being retrieved instead of 72.
"""
log.debug('===== START TEST INVALID RECORD ID =====')
with open(os.path.join(RESOURCE_PATH, 'bad_id_VELPT_SN_11402_2014-07-02.aqd'), 'rb') as file_handle:
num_particles_to_request = num_expected_particles = 71
parser = VelptAbParser(self._parser_config,
file_handle,
self.exception_callback)
particles = parser.get_records(num_particles_to_request)
self.assertEquals(len(particles), num_expected_particles)
self.assert_particles(particles, 'bad_id_VELPT_SN_11402_2014-07-02.yml', RESOURCE_PATH)
log.debug('===== END TEST INVALID RECORD ID =====')
示例5: test_invalid_sync_byte
# 需要导入模块: from mi.dataset.parser.velpt_ab import VelptAbParser [as 别名]
# 或者: from mi.dataset.parser.velpt_ab.VelptAbParser import get_records [as 别名]
def test_invalid_sync_byte(self):
"""
The file used in this test has extra bytes between records which need to be skipped
in order to process the correct number of particles. All records are still processed.
"""
log.debug('===== START TEST INVALID SYNC BYTE =====')
with open(os.path.join(RESOURCE_PATH, 'extra_bytes_VELPT_SN_11402_2014-07-02.aqd'), 'rb') as file_handle:
num_particles_to_request = num_expected_particles = 72
parser = VelptAbParser(self._parser_config,
file_handle,
self.exception_callback)
particles = parser.get_records(num_particles_to_request)
self.assertEquals(len(particles), num_expected_particles)
self.assert_particles(particles, 'VELPT_SN_11402_2014-07-02.yml', RESOURCE_PATH)
log.debug('===== END TEST INVALID SYNC BYTE =====')
示例6: test_no_diag_recs
# 需要导入模块: from mi.dataset.parser.velpt_ab import VelptAbParser [as 别名]
# 或者: from mi.dataset.parser.velpt_ab.VelptAbParser import get_records [as 别名]
def test_no_diag_recs(self):
"""
The file used in this test has a single diagnostic header record but no diagnostic
records. No diagnostic particles will be produced.
"""
log.debug('===== START TEST NO DIAGNOSTIC RECORDS FOUND =====')
with open(os.path.join(RESOURCE_PATH, 'no_diag_recs_VELPT_SN_11402_2014-07-02.aqd'), 'rb')\
as file_handle:
num_particles_to_request = num_expected_particles = 51
parser = VelptAbParser(self._parser_config,
file_handle,
self.exception_callback)
particles = parser.get_records(num_particles_to_request)
self.assertEquals(len(particles), num_expected_particles)
self.assert_particles(particles, 'no_diag_recs_VELPT_SN_11402_2014-07-02.yml', RESOURCE_PATH)
log.debug('===== END TEST NO DIAGNOSTIC RECORDS FOUND =====')
示例7: test_missing_all_config
# 需要导入模块: from mi.dataset.parser.velpt_ab import VelptAbParser [as 别名]
# 或者: from mi.dataset.parser.velpt_ab.VelptAbParser import get_records [as 别名]
def test_missing_all_config(self):
"""
The file used in this test has no user configuration record.
Instrument metadata will still be produced but the fields from
the user config will NOT be included.
"""
log.debug('===== START TEST MISSING ALL CONFIG RECORDS =====')
with open(os.path.join(RESOURCE_PATH, 'no_config_recs_VELPT_SN_11402_2014-07-02.aqd'), 'rb') as file_handle:
num_particles_to_request = num_expected_particles = 72
parser = VelptAbParser(self._parser_config,
file_handle,
self.exception_callback)
particles = parser.get_records(num_particles_to_request)
self.assertEquals(len(particles), num_expected_particles)
self.assert_particles(particles, 'no_config_recs_VELPT_SN_11402_2014-07-02.yml', RESOURCE_PATH)
log.debug('===== END TEST MISSING ALL CONFIG RECORDS =====')
示例8: test_truncated_file
# 需要导入模块: from mi.dataset.parser.velpt_ab import VelptAbParser [as 别名]
# 或者: from mi.dataset.parser.velpt_ab.VelptAbParser import get_records [as 别名]
def test_truncated_file(self):
"""
The file used in this test has a malformed (too short) record at
the end of the file.This results in 71 particles being retrieved
instead of 72.
"""
log.debug('===== START TEST FOUND TRUNCATED FILE =====')
with open(os.path.join(RESOURCE_PATH, 'truncated_VELPT_SN_11402_2014-07-02.aqd'), 'rb') as file_handle:
num_particles_to_request = num_expected_particles = 71
parser = VelptAbParser(self._parser_config,
file_handle,
self.exception_callback)
particles = parser.get_records(num_particles_to_request)
self.assertEquals(len(particles), num_expected_particles)
self.assert_particles(particles, 'truncated_VELPT_SN_11402_2014-07-02.yml', RESOURCE_PATH)
log.debug('===== END TEST FOUND TRUNCATED FILE =====')
示例9: test_too_many_diagnostics_records
# 需要导入模块: from mi.dataset.parser.velpt_ab import VelptAbParser [as 别名]
# 或者: from mi.dataset.parser.velpt_ab.VelptAbParser import get_records [as 别名]
def test_too_many_diagnostics_records(self):
"""
The file used in this test has 21 diagnostics records in the second set.
Twenty are expected. The records are all still processed.
The error is simply noted.
"""
log.debug('===== START TEST TOO MANY DIAGNOSTICS RECORDS =====')
with open(os.path.join(RESOURCE_PATH, 'too_many_VELPT_SN_11402_2014-07-02.aqd'), 'rb') as file_handle:
num_particles_to_request = num_expected_particles = 73
parser = VelptAbParser(self._parser_config,
file_handle,
self.exception_callback)
particles = parser.get_records(num_particles_to_request)
self.assertEquals(len(particles), num_expected_particles)
self.assert_particles(particles, 'too_many_VELPT_SN_11402_2014-07-02.yml', RESOURCE_PATH)
log.debug('===== END TEST TOO MANY DIAGNOSTICS RECORDS =====')
示例10: test_simple
# 需要导入模块: from mi.dataset.parser.velpt_ab import VelptAbParser [as 别名]
# 或者: from mi.dataset.parser.velpt_ab.VelptAbParser import get_records [as 别名]
def test_simple(self):
"""
Read files and verify that all expected particles can be read.
Verify that the contents of the particles are correct.
This is the happy path test.
"""
log.debug('===== START TEST SIMPLE =====')
# Test the telemetered version
with open(os.path.join(RESOURCE_PATH, 'VELPT_SN_11402_2014-07-02.aqd'), 'rb') as file_handle:
num_particles_to_request = num_expected_particles = 72
parser = VelptAbParser(self._parser_config,
file_handle,
self.exception_callback)
particles = parser.get_records(num_particles_to_request)
self.assertEquals(len(particles), num_expected_particles)
self.assert_particles(particles, 'VELPT_SN_11402_2014-07-02.yml', RESOURCE_PATH)
log.debug('===== END TEST SIMPLE =====')
示例11: test_random_diag_record
# 需要导入模块: from mi.dataset.parser.velpt_ab import VelptAbParser [as 别名]
# 或者: from mi.dataset.parser.velpt_ab.VelptAbParser import get_records [as 别名]
def test_random_diag_record(self):
"""
The file used in this test has a bad checksum in the head configuration record.
Instrument metadata will still be produced but the fields from
the head config will NOT be included.
"""
log.debug('===== START TEST RANDOM DIAGNOSTIC RECORD FOUND =====')
with open(os.path.join(RESOURCE_PATH, 'random_diag_record_VELPT_SN_11402_2014-07-02.aqd'), 'rb')\
as file_handle:
num_particles_to_request = num_expected_particles = 72
parser = VelptAbParser(self._parser_config,
file_handle,
self.exception_callback)
particles = parser.get_records(num_particles_to_request)
self.assertEquals(len(particles), num_expected_particles)
self.assert_particles(particles, 'random_diag_record_VELPT_SN_11402_2014-07-02.yml', RESOURCE_PATH)
log.debug('===== END TEST RANDOM DIAGNOSTIC RECORD FOUND =====')
示例12: test_hardware_config_bad_checksum
# 需要导入模块: from mi.dataset.parser.velpt_ab import VelptAbParser [as 别名]
# 或者: from mi.dataset.parser.velpt_ab.VelptAbParser import get_records [as 别名]
def test_hardware_config_bad_checksum(self):
"""
The file used in this test has a bad checksum in the hardware configuration record.
Instrument metadata will still be produced but the fields from
the hardware config will NOT be included.
"""
log.debug('===== START TEST HARDWARE CONFIG BAD CHECKSUM =====')
with open(os.path.join(RESOURCE_PATH, 'bad_checksum_in_hardware_config_VELPT_SN_11402_2014-07-02.aqd'), 'rb')\
as file_handle:
num_particles_to_request = num_expected_particles = 72
parser = VelptAbParser(self._parser_config,
file_handle,
self.exception_callback)
particles = parser.get_records(num_particles_to_request)
self.assertEquals(len(particles), num_expected_particles)
self.assert_particles(particles, 'no_hardware_config_VELPT_SN_11402_2014-07-02.yml', RESOURCE_PATH)
log.debug('===== END TEST HARDWARE CONFIG BAD CHECKSUM =====')