Ejemplo n.º 1
0
    def test_getTimingQuality(self):
        """
        This test reads a self-made Mini-SEED file with Timing Quality
        information in Blockette 1001. A real test file would be better.

        The test file contains 101 records with the timing quality ranging from
        0 to 100 in steps of 1.

        The result is compared to the result from the following R command:

        V <- 0:100; min(V); max(V); mean(V); median(V); quantile(V, 0.75,
        type = 3); quantile(V, 0.25, type = 3)
        """
        filename = os.path.join(self.path, 'data', 'timingquality.mseed')
        result = util.getTimingAndDataQuality(filename)
        self.assertEqual(result,
                         {'timing_quality_upper_quantile': 75.0,
                          'data_quality_flags': [0, 0, 0, 0, 0, 0, 0, 0],
                          'timing_quality_min': 0.0,
                          'timing_quality_lower_quantile': 25.0,
                          'timing_quality_average': 50.0,
                          'timing_quality_median': 50.0,
                          'timing_quality_max': 100.0})
        # No timing quality set should result in an empty dictionary.
        filename = os.path.join(self.path, 'data',
                                'BW.BGLD.__.EHE.D.2008.001.first_10_records')
        result = util.getTimingAndDataQuality(filename)
        self.assertEqual(result,
                         {'data_quality_flags': [0, 0, 0, 0, 0, 0, 0, 0]})
        result = util.getTimingAndDataQuality(filename)
        self.assertEqual(result,
                         {'data_quality_flags': [0, 0, 0, 0, 0, 0, 0, 0]})
Ejemplo n.º 2
0
    def test_getTimingQuality(self):
        """
        This test reads a self-made Mini-SEED file with Timing Quality
        information in Blockette 1001. A real test file would be better.

        The test file contains 101 records with the timing quality ranging from
        0 to 100 in steps of 1.

        The result is compared to the result from the following R command:

        V <- 0:100; min(V); max(V); mean(V); median(V); quantile(V, 0.75,
        type = 3); quantile(V, 0.25, type = 3)
        """
        filename = os.path.join(self.path, 'data', 'timingquality.mseed')
        result = util.getTimingAndDataQuality(filename)
        self.assertEqual(
            result, {
                'timing_quality_upper_quantile': 75.0,
                'data_quality_flags': [0, 0, 0, 0, 0, 0, 0, 0],
                'timing_quality_min': 0.0,
                'timing_quality_lower_quantile': 25.0,
                'timing_quality_average': 50.0,
                'timing_quality_median': 50.0,
                'timing_quality_max': 100.0
            })
        # No timing quality set should result in an empty dictionary.
        filename = os.path.join(self.path, 'data',
                                'BW.BGLD.__.EHE.D.2008.001.first_10_records')
        result = util.getTimingAndDataQuality(filename)
        self.assertEqual(result,
                         {'data_quality_flags': [0, 0, 0, 0, 0, 0, 0, 0]})
        result = util.getTimingAndDataQuality(filename)
        self.assertEqual(result,
                         {'data_quality_flags': [0, 0, 0, 0, 0, 0, 0, 0]})
Ejemplo n.º 3
0
 def test_getDataQuality(self):
     """
     This test reads a self-made Mini-SEED file with set Data Quality Bits.
     A real test file would be better as this test tests a file that was
     created by the inverse method that reads the bits.
     """
     filename = os.path.join(self.path, 'data', 'qualityflags.mseed')
     # Read quality flags.
     result = util.getTimingAndDataQuality(filename)
     # The test file contains 18 records. The first record has no set bit,
     # bit 0 of the second record is set, bit 1 of the third, ..., bit 7 of
     # the 9th record is set. The last nine records have 0 to 8 set bits,
     # starting with 0 bits, bit 0 is set, bits 0 and 1 are set...
     # Altogether the file contains 44 set bits.
     self.assertEqual(result,
                      {'data_quality_flags': [9, 8, 7, 6, 5, 4, 3, 2]})
     # No set quality flags should result in a list of zeros.
     filename = os.path.join(self.path, 'data', 'test.mseed')
     result = util.getTimingAndDataQuality(filename)
     self.assertEqual(result,
                      {'data_quality_flags': [0, 0, 0, 0, 0, 0, 0, 0]})
Ejemplo n.º 4
0
 def test_getDataQuality(self):
     """
     This test reads a self-made Mini-SEED file with set Data Quality Bits.
     A real test file would be better as this test tests a file that was
     created by the inverse method that reads the bits.
     """
     filename = os.path.join(self.path, 'data', 'qualityflags.mseed')
     # Read quality flags.
     result = util.getTimingAndDataQuality(filename)
     # The test file contains 18 records. The first record has no set bit,
     # bit 0 of the second record is set, bit 1 of the third, ..., bit 7 of
     # the 9th record is set. The last nine records have 0 to 8 set bits,
     # starting with 0 bits, bit 0 is set, bits 0 and 1 are set...
     # Altogether the file contains 44 set bits.
     self.assertEqual(result,
                      {'data_quality_flags': [9, 8, 7, 6, 5, 4, 3, 2]})
     # No set quality flags should result in a list of zeros.
     filename = os.path.join(self.path, 'data', 'test.mseed')
     result = util.getTimingAndDataQuality(filename)
     self.assertEqual(result,
                      {'data_quality_flags': [0, 0, 0, 0, 0, 0, 0, 0]})