Exemple #1
0
 def test_getPAZFromXSEED(self):
     """
     Get PAZ from XSEED file, testcase for #146
     """
     filename = os.path.join(self.path, 'dataless.seed.BW_FURT')
     sp1 = Parser(filename)
     sp2 = Parser(sp1.get_XSEED())
     paz = sp2.getPAZ('EHE')
     result = {'gain': 1.00000e+00,
               'zeros': [0j, 0j, 0j],
               'poles': [(-4.44400e+00 + 4.44400e+00j),
                         (-4.44400e+00 - 4.44400e+00j),
                         (-1.08300e+00 + 0.00000e+00j)],
               'sensitivity': 6.71140E+08,
               'seismometer_gain': 4.00000E+02,
               'digitizer_gain': 1677850.0}
     self.assertEqual(sorted(paz.items()), sorted(result.items()))
Exemple #2
0
 def test_getCoordinates(self):
     """
     Test extracting coordinates for SEED and XSEED (including #146)
     """
     # SEED
     sp = Parser(os.path.join(self.path, 'dataless.seed.BW_RJOB'))
     result = {'elevation': 860.0, 'latitude': 47.737166999999999,
               'longitude': 12.795714, 'local_depth': 0}
     paz = sp.get_coordinates("BW.RJOB..EHZ", UTCDateTime("2007-01-01"))
     self.assertEqual(sorted(paz.items()), sorted(result.items()))
     paz = sp.get_coordinates("BW.RJOB..EHZ", UTCDateTime("2010-01-01"))
     self.assertEqual(sorted(paz.items()), sorted(result.items()))
     # XSEED
     sp2 = Parser(sp.get_XSEED())
     paz = sp2.get_coordinates("BW.RJOB..EHZ", UTCDateTime("2007-01-01"))
     self.assertEqual(sorted(paz.items()), sorted(result.items()))
     paz = sp2.get_coordinates("BW.RJOB..EHZ", UTCDateTime("2010-01-01"))
     self.assertEqual(sorted(paz.items()), sorted(result.items()))
Exemple #3
0
    def test_createReadAssertAndWriteXSEED(self):
        """
        This test takes some SEED files, reads them to a Parser object
        and converts them back to SEED once. This is done to avoid any
        formating issues as seen in test_readAndWriteSEED.

        Therefore the reading and writing of SEED files is considered to be
        correct.

        Finally the resulting SEED gets converted to XSEED and back to SEED
        and the two SEED strings are then evaluated to be identical.

        This tests also checks for XML validity using a XML schema.
        """
        # Loop over all files and versions.
        for version in ['1.0', '1.1']:
            # Path to XML schema file.
            xsd_path = os.path.join(self.path, 'xml-seed-%s.xsd' % version)
            # Prepare validator.
            f = open(xsd_path, 'rb')
            xmlschema_doc = etree.parse(f)
            f.close()
            xmlschema = etree.XMLSchema(xmlschema_doc)
            for file in self.BW_SEED_files:
                # Parse the file.
                parser1 = Parser(file)
                # Convert to SEED once to avoid any issues seen in
                # test_readAndWriteSEED.
                original_seed = parser1.get_SEED()
                del parser1
                # Now read the file, parse it, write XSEED, read XSEED and
                # write SEED again. The output should be totally identical.
                parser2 = Parser(original_seed)
                xseed_string = parser2.get_XSEED(version=version)
                del parser2
                # Validate XSEED.
                doc = etree.parse(io.BytesIO(xseed_string))
                self.assertTrue(xmlschema.validate(doc))
                del doc
                parser3 = Parser(xseed_string)
                new_seed = parser3.get_SEED()
                self.assertEqual(original_seed, new_seed)
                del parser3, original_seed, new_seed
Exemple #4
0
    def test_createReadAssertAndWriteXSEED(self):
        """
        This test takes some SEED files, reads them to a Parser object
        and converts them back to SEED once. This is done to avoid any
        formating issues as seen in test_readAndWriteSEED.

        Therefore the reading and writing of SEED files is considered to be
        correct.

        Finally the resulting SEED gets converted to XSEED and back to SEED
        and the two SEED strings are then evaluated to be identical.

        This tests also checks for XML validity using a XML schema.
        """
        # Loop over all files and versions.
        for version in ['1.0', '1.1']:
            # Path to XML schema file.
            xsd_path = os.path.join(self.path, 'xml-seed-%s.xsd' % version)
            # Prepare validator.
            f = open(xsd_path, 'rb')
            xmlschema_doc = etree.parse(f)
            f.close()
            xmlschema = etree.XMLSchema(xmlschema_doc)
            for file in self.BW_SEED_files:
                # Parse the file.
                parser1 = Parser(file)
                # Convert to SEED once to avoid any issues seen in
                # test_readAndWriteSEED.
                original_seed = parser1.get_SEED()
                del parser1
                # Now read the file, parse it, write XSEED, read XSEED and
                # write SEED again. The output should be totally identical.
                parser2 = Parser(original_seed)
                xseed_string = parser2.get_XSEED(version=version)
                del parser2
                # Validate XSEED.
                doc = etree.parse(io.BytesIO(xseed_string))
                self.assertTrue(xmlschema.validate(doc))
                del doc
                parser3 = Parser(xseed_string)
                new_seed = parser3.get_SEED()
                self.assertEqual(original_seed, new_seed)
                del parser3, original_seed, new_seed
Exemple #5
0
 def test_getCoordinates(self):
     """
     Test extracting coordinates for SEED and XSEED (including #146)
     """
     # SEED
     sp = Parser(os.path.join(self.path, 'dataless.seed.BW_RJOB'))
     result = {
         'elevation': 860.0,
         'latitude': 47.737166999999999,
         'longitude': 12.795714,
         'local_depth': 0
     }
     paz = sp.get_coordinates("BW.RJOB..EHZ", UTCDateTime("2007-01-01"))
     self.assertEqual(sorted(paz.items()), sorted(result.items()))
     paz = sp.get_coordinates("BW.RJOB..EHZ", UTCDateTime("2010-01-01"))
     self.assertEqual(sorted(paz.items()), sorted(result.items()))
     # XSEED
     sp2 = Parser(sp.get_XSEED())
     paz = sp2.get_coordinates("BW.RJOB..EHZ", UTCDateTime("2007-01-01"))
     self.assertEqual(sorted(paz.items()), sorted(result.items()))
     paz = sp2.get_coordinates("BW.RJOB..EHZ", UTCDateTime("2010-01-01"))
     self.assertEqual(sorted(paz.items()), sorted(result.items()))
Exemple #6
0
 def test_getPAZFromXSEED(self):
     """
     Get PAZ from XSEED file, testcase for #146
     """
     filename = os.path.join(self.path, 'dataless.seed.BW_FURT')
     sp1 = Parser(filename)
     sp2 = Parser(sp1.get_XSEED())
     paz = sp2.getPAZ('EHE')
     result = {
         'gain':
         1.00000e+00,
         'zeros': [0j, 0j, 0j],
         'poles': [(-4.44400e+00 + 4.44400e+00j),
                   (-4.44400e+00 - 4.44400e+00j),
                   (-1.08300e+00 + 0.00000e+00j)],
         'sensitivity':
         6.71140E+08,
         'seismometer_gain':
         4.00000E+02,
         'digitizer_gain':
         1677850.0
     }
     self.assertEqual(sorted(paz.items()), sorted(result.items()))