Exemple #1
0
 def test_sim_WA(self):
     """ Test simulating a Wood Anderson instrument. """
     t1 = UTCDateTime("2010-09-3T16:30:00.000")
     t2 = UTCDateTime("2010-09-3T17:00:00.000")
     fdsn_client = Client('IRIS')
     st = fdsn_client.get_waveforms(
         network='NZ', station='BFZ', location='10', channel='HHZ',
         starttime=t1, endtime=t2, attach_response=True)
     inventory = fdsn_client.get_stations(
         network='NZ', station='BFZ', location='10', channel='HHZ',
         starttime=t1, endtime=t2, level="response")
     tr = st[0]
     # Test with inventory
     _sim_WA(trace=tr, inventory=inventory, water_level=10)
Exemple #2
0
    def test_sim_WA(self):
        """Test feeding both PAZ and seedresp."""
        t1 = UTCDateTime("2010-09-3T16:30:00.000")
        t2 = UTCDateTime("2010-09-3T17:00:00.000")
        fdsn_client = Client('IRIS')
        st = fdsn_client.get_waveforms(
            network='NZ', station='BFZ', location='10', channel='HHZ',
            starttime=t1, endtime=t2, attach_response=True)
        tr = st[0]
        PAZ = {'poles': [-4.440 + 4.440j, -4.440 - 4.440j, -1.083 + 0.0j],
               'zeros': [0.0 + 0.0j, 0.0 + 0.0j, 0.0 + 0.0],
               'sensitivity': 0.4,
               'gain': 60077000.0}
        tr_safe = tr.copy()
        # Test with PAZ
        _sim_WA(trace=tr, PAZ=PAZ, seedresp=None, water_level=10)
        tr = tr_safe.copy()
        # Test without PAZ or seedresp
        _sim_WA(trace=tr, PAZ=None, seedresp=None, water_level=10)
        tr = tr_safe.copy()
        with NamedTemporaryFile() as tf:
            respf = tf.name
            old_iris_client = OldIris_Client()
            # fetch RESP information from "old" IRIS web service, see
            # obspy.fdsn for accessing the new IRIS FDSN web services
            old_iris_client.resp('NZ', 'BFZ', '10', 'HHZ', t1, t2,
                                 filename=respf)
            date = t1

            seedresp = {
                'filename': respf, 'date': date, 'network': tr.stats.network,
                'station': tr.stats.station, 'channel': tr.stats.channel,
                'location': tr.stats.location, 'units': 'DIS'
                        }
            _sim_WA(trace=tr, PAZ=None, seedresp=seedresp, water_level=10)
Exemple #3
0
    def test_sim_WA(self):
        """Test feeding both PAZ and seedresp."""
        from eqcorrscan.utils.mag_calc import _sim_WA
        from obspy.core.util import NamedTemporaryFile
        from obspy import UTCDateTime
        from obspy.clients.fdsn import Client
        from obspy.clients.iris import Client as OldIris_Client

        t1 = UTCDateTime("2010-09-3T16:30:00.000")
        t2 = UTCDateTime("2010-09-3T17:00:00.000")
        fdsn_client = Client('IRIS')
        st = fdsn_client.get_waveforms(network='NZ', station='BFZ',
                                       location='10',
                                       channel='HHZ',
                                       starttime=t1, endtime=t2,
                                       attach_response=True)
        tr = st[0]
        PAZ = {'poles': [-4.440 + 4.440j, -4.440 - 4.440j, -1.083 + 0.0j],
               'zeros': [0.0 + 0.0j, 0.0 + 0.0j, 0.0 + 0.0],
               'sensitivity': 0.4,
               'gain': 60077000.0}
        tr_safe = tr.copy()
        # Test with PAZ
        _sim_WA(trace=tr, PAZ=PAZ, seedresp=None, water_level=10)
        tr = tr_safe.copy()
        # Test without PAZ or seedresp
        _sim_WA(trace=tr, PAZ=None, seedresp=None, water_level=10)
        tr = tr_safe.copy()
        with NamedTemporaryFile() as tf:
            respf = tf.name
            old_iris_client = OldIris_Client()
            # fetch RESP information from "old" IRIS web service, see obspy.fdsn
            # for accessing the new IRIS FDSN web services
            old_iris_client.resp('NZ', 'BFZ', '10', 'HHZ', t1, t2,
                                 filename=respf)
            date = t1

            seedresp = {'filename': respf,  # RESP filename
                        'date': date,
                        'network': tr.stats.network,
                        'station': tr.stats.station,
                        'channel': tr.stats.channel,
                        'location': tr.stats.location,
                        # Units to return response in ('DIS', 'VEL' or ACC)
                        'units': 'DIS'
                        }
            _sim_WA(trace=tr, PAZ=None, seedresp=seedresp, water_level=10)
    def test_sim_WA(self):
        """Test feeding both PAZ and seedresp."""
        t1 = UTCDateTime("2010-09-3T16:30:00.000")
        t2 = UTCDateTime("2010-09-3T17:00:00.000")
        fdsn_client = Client('IRIS')
        st = fdsn_client.get_waveforms(network='NZ',
                                       station='BFZ',
                                       location='10',
                                       channel='HHZ',
                                       starttime=t1,
                                       endtime=t2,
                                       attach_response=True)
        tr = st[0]
        PAZ = {
            'poles': [-4.440 + 4.440j, -4.440 - 4.440j, -1.083 + 0.0j],
            'zeros': [0.0 + 0.0j, 0.0 + 0.0j, 0.0 + 0.0],
            'sensitivity': 0.4,
            'gain': 60077000.0
        }
        tr_safe = tr.copy()
        # Test with PAZ
        _sim_WA(trace=tr, PAZ=PAZ, seedresp=None, water_level=10)
        tr = tr_safe.copy()
        # Test without PAZ or seedresp
        _sim_WA(trace=tr, PAZ=None, seedresp=None, water_level=10)
        tr = tr_safe.copy()
        with open("Temp_resp", "w") as tf:
            respf = tf.name
            old_iris_client = OldIris_Client()
            # fetch RESP information from "old" IRIS web service, see
            # obspy.fdsn for accessing the new IRIS FDSN web services
            old_iris_client.resp('NZ',
                                 'BFZ',
                                 '10',
                                 'HHZ',
                                 t1,
                                 t2,
                                 filename=respf)
            # Hack around unit issues
        with open("Temp_resp", "r") as tf:
            resp_contents = [line for line in tf]
        corrected_contents = []
        for line in resp_contents:
            if "COUNT" in line:
                line = line.replace("COUNT", "COUNTS")
            corrected_contents.append(line)
        with open("Temp_resp", "w") as tf:
            for line in corrected_contents:
                tf.write(line)
        date = t1

        seedresp = {
            'filename': respf,
            'date': date,
            'network': tr.stats.network,
            'station': tr.stats.station,
            'channel': tr.stats.channel,
            'location': tr.stats.location,
            'units': 'DIS'
        }
        _sim_WA(trace=tr, PAZ=None, seedresp=seedresp, water_level=10)
        os.remove(respf)