Exemple #1
0
 def test_get_coordinates(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,
               'azimuth': 0.0, 'local_depth': 0, 'dip': -90.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()))
     # Additional test with non-trivial azimuth
     sp = Parser(os.path.join(self.path, 'dataless.seed.II_COCO'))
     result = {'elevation': 1.0, 'latitude': -12.1901,
               'longitude': 96.8349, 'local_depth': 1.3,
               'azimuth': 92.0, 'local_depth': 1.3, 'dip': 0.0}
     paz = sp.get_coordinates("II.COCO.10.BH2", UTCDateTime("2010-11-11"))
     self.assertEqual(sorted(paz.items()), sorted(result.items()))
Exemple #2
0
 def test_get_coordinates(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,
               'azimuth': 0.0, 'local_depth': 0, 'dip': -90.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()))
     # Additional test with non-trivial azimuth
     sp = Parser(os.path.join(self.path, 'dataless.seed.II_COCO'))
     result = {'elevation': 1.0, 'latitude': -12.1901,
               'longitude': 96.8349, 'local_depth': 1.3,
               'azimuth': 92.0, 'local_depth': 1.3, 'dip': 0.0}
     paz = sp.get_coordinates("II.COCO.10.BH2", UTCDateTime("2010-11-11"))
     self.assertEqual(sorted(paz.items()), sorted(result.items()))
Exemple #3
0
 def test_get_paz_from_xseed(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.get_paz('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 #4
0
 def test_get_paz_from_xseed(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.get_paz('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 #5
0
 def test_get_coordinates(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_get_paz_from_xseed(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.00000e00,
         "zeros": [0j, 0j, 0j],
         "poles": [(-4.44400e00 + 4.44400e00j), (-4.44400e00 - 4.44400e00j), (-1.08300e00 + 0.00000e00j)],
         "sensitivity": 6.71140e08,
         "seismometer_gain": 4.00000e02,
         "digitizer_gain": 1677850.0,
     }
     self.assertEqual(sorted(paz.items()), sorted(result.items()))
Exemple #7
0
    def test_create_read_assert_and_write_xseed(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 #8
0
    def test_create_read_assert_and_write_xseed(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 #9
0
 def test_get_coordinates(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 #10
0
from obspy.core import UTCDateTime
from obspy.core import inventory
from obspy.io.xseed.parser import Parser

sp = Parser('YN.dataless')
xsd = sp.get_xseed()
print(xsd)

#print(sp.get_inventory())["channels"]
#print(sp.get_inventory()["stations"])

#print(sp.getXSEED())