Beispiel #1
0
 def test_evalresp(self):
     """
     Tests evaluating instrument response information.
     """
     client = Client()
     dt = UTCDateTime("2005-01-01")
     # plot as PNG file
     tempfile = NamedTemporaryFile().name
     client.evalresp(
         network="IU", station="ANMO", location="00", channel="BHZ", time=dt, output="plot", filename=tempfile
     )
     self.assertEqual(open(tempfile, "rb").read(4)[1:4], "PNG")
     os.remove(tempfile)
     # plot-amp as PNG file
     tempfile = NamedTemporaryFile().name
     client.evalresp(
         network="IU", station="ANMO", location="00", channel="BHZ", time=dt, output="plot-amp", filename=tempfile
     )
     self.assertEqual(open(tempfile, "rb").read(4)[1:4], "PNG")
     os.remove(tempfile)
     # plot-phase as PNG file
     tempfile = NamedTemporaryFile().name
     client.evalresp(
         network="IU", station="ANMO", location="00", channel="BHZ", time=dt, output="plot-phase", filename=tempfile
     )
     self.assertEqual(open(tempfile, "rb").read(4)[1:4], "PNG")
     os.remove(tempfile)
     # fap as ASCII file
     tempfile = NamedTemporaryFile().name
     client.evalresp(
         network="IU", station="ANMO", location="00", channel="BHZ", time=dt, output="fap", filename=tempfile
     )
     self.assertEqual(open(tempfile, "rt").readline(), "1.000000E-05  1.202802E+04  1.792007E+02\n")
     os.remove(tempfile)
     # cs as ASCII file
     tempfile = NamedTemporaryFile().name
     client.evalresp(
         network="IU", station="ANMO", location="00", channel="BHZ", time=dt, output="cs", filename=tempfile
     )
     self.assertEqual(open(tempfile, "rt").readline(), "1.000000E-05 -1.202685E+04 1.677835E+02\n")
     os.remove(tempfile)
     # fap & def as ASCII file
     tempfile = NamedTemporaryFile().name
     client.evalresp(
         network="IU",
         station="ANMO",
         location="00",
         channel="BHZ",
         time=dt,
         output="fap",
         units="def",
         filename=tempfile,
     )
     self.assertEqual(open(tempfile, "rt").readline(), "1.000000E-05  1.202802E+04  1.792007E+02\n")
     os.remove(tempfile)
     # fap & dis as ASCII file
     tempfile = NamedTemporaryFile().name
     client.evalresp(
         network="IU",
         station="ANMO",
         location="00",
         channel="BHZ",
         time=dt,
         output="fap",
         units="dis",
         filename=tempfile,
     )
     self.assertEqual(open(tempfile, "rt").readline(), "1.000000E-05  7.557425E-01  2.692007E+02\n")
     os.remove(tempfile)
     # fap & vel as ASCII file
     tempfile = NamedTemporaryFile().name
     client.evalresp(
         network="IU",
         station="ANMO",
         location="00",
         channel="BHZ",
         time=dt,
         output="fap",
         units="vel",
         filename=tempfile,
     )
     self.assertEqual(open(tempfile, "rt").readline(), "1.000000E-05  1.202802E+04  1.792007E+02\n")
     os.remove(tempfile)
     # fap & acc as ASCII file
     tempfile = NamedTemporaryFile().name
     client.evalresp(
         network="IU",
         station="ANMO",
         location="00",
         channel="BHZ",
         time=dt,
         output="fap",
         units="acc",
         filename=tempfile,
     )
     self.assertEqual(open(tempfile, "rt").readline(), "1.000000E-05  1.914318E+08  8.920073E+01\n")
     os.remove(tempfile)
     # fap as NumPy ndarray
     data = client.evalresp(network="IU", station="ANMO", location="00", channel="BHZ", time=dt, output="fap")
     np.testing.assert_array_equal(data[0], [1.00000000e-05, 1.20280200e04, 1.79200700e02])
     # cs as NumPy ndarray
     data = client.evalresp(network="IU", station="ANMO", location="00", channel="BHZ", time=dt, output="cs")
     np.testing.assert_array_equal(data[0], [1.00000000e-05, -1.20268500e04, 1.67783500e02])
Beispiel #2
0
 def test_evalresp(self):
     """
     Tests evaluating instrument response information.
     """
     client = Client()
     dt = UTCDateTime("2005-01-01")
     # plot as PNG file
     tempfile = NamedTemporaryFile().name
     client.evalresp(network="IU", station="ANMO", location="00",
                     channel="BHZ", time=dt, output='plot',
                     filename=tempfile)
     self.assertEqual(open(tempfile, 'rb').read(4)[1:4], 'PNG')
     os.remove(tempfile)
     # plot-amp as PNG file
     tempfile = NamedTemporaryFile().name
     client.evalresp(network="IU", station="ANMO", location="00",
                     channel="BHZ", time=dt, output='plot-amp',
                     filename=tempfile)
     self.assertEqual(open(tempfile, 'rb').read(4)[1:4], 'PNG')
     os.remove(tempfile)
     # plot-phase as PNG file
     tempfile = NamedTemporaryFile().name
     client.evalresp(network="IU", station="ANMO", location="00",
                     channel="BHZ", time=dt, output='plot-phase',
                     filename=tempfile)
     self.assertEqual(open(tempfile, 'rb').read(4)[1:4], 'PNG')
     os.remove(tempfile)
     # fap as ASCII file
     tempfile = NamedTemporaryFile().name
     client.evalresp(network="IU", station="ANMO", location="00",
                     channel="BHZ", time=dt, output='fap',
                     filename=tempfile)
     self.assertEqual(open(tempfile, 'rt').readline(),
                      '1.000000E-05  1.202802E+04  1.792007E+02\n')
     os.remove(tempfile)
     # cs as ASCII file
     tempfile = NamedTemporaryFile().name
     client.evalresp(network="IU", station="ANMO", location="00",
                     channel="BHZ", time=dt, output='cs',
                     filename=tempfile)
     self.assertEqual(open(tempfile, 'rt').readline(),
                      '1.000000E-05 -1.202685E+04 1.677835E+02\n')
     os.remove(tempfile)
     # fap & def as ASCII file
     tempfile = NamedTemporaryFile().name
     client.evalresp(network="IU", station="ANMO", location="00",
                     channel="BHZ", time=dt, output='fap', units='def',
                     filename=tempfile)
     self.assertEqual(open(tempfile, 'rt').readline(),
                      '1.000000E-05  1.202802E+04  1.792007E+02\n')
     os.remove(tempfile)
     # fap & dis as ASCII file
     tempfile = NamedTemporaryFile().name
     client.evalresp(network="IU", station="ANMO", location="00",
                     channel="BHZ", time=dt, output='fap', units='dis',
                     filename=tempfile)
     self.assertEqual(open(tempfile, 'rt').readline(),
                      '1.000000E-05  7.557425E-01  2.692007E+02\n')
     os.remove(tempfile)
     # fap & vel as ASCII file
     tempfile = NamedTemporaryFile().name
     client.evalresp(network="IU", station="ANMO", location="00",
                     channel="BHZ", time=dt, output='fap', units='vel',
                     filename=tempfile)
     self.assertEqual(open(tempfile, 'rt').readline(),
                      '1.000000E-05  1.202802E+04  1.792007E+02\n')
     os.remove(tempfile)
     # fap & acc as ASCII file
     tempfile = NamedTemporaryFile().name
     client.evalresp(network="IU", station="ANMO", location="00",
                     channel="BHZ", time=dt, output='fap', units='acc',
                     filename=tempfile)
     self.assertEqual(open(tempfile, 'rt').readline(),
                      '1.000000E-05  1.914318E+08  8.920073E+01\n')
     os.remove(tempfile)
     # fap as NumPy ndarray
     data = client.evalresp(network="IU", station="ANMO", location="00",
                            channel="BHZ", time=dt, output='fap')
     np.testing.assert_array_equal(data[0],
         [1.00000000e-05, 1.20280200e+04, 1.79200700e+02])
     # cs as NumPy ndarray
     data = client.evalresp(network="IU", station="ANMO", location="00",
                            channel="BHZ", time=dt, output='cs')
     np.testing.assert_array_equal(data[0],
         [1.00000000e-05, -1.20268500e+04, 1.67783500e+02])
Beispiel #3
0
 def test_evalresp(self):
     """
     Tests evaluating instrument response information.
     """
     client = Client()
     dt = UTCDateTime("2005-01-01")
     # plot as PNG file
     tempfile = NamedTemporaryFile().name
     client.evalresp(network="IU",
                     station="ANMO",
                     location="00",
                     channel="BHZ",
                     time=dt,
                     output='plot',
                     filename=tempfile)
     self.assertEqual(open(tempfile, 'rb').read(4)[1:4], 'PNG')
     os.remove(tempfile)
     # plot-amp as PNG file
     tempfile = NamedTemporaryFile().name
     client.evalresp(network="IU",
                     station="ANMO",
                     location="00",
                     channel="BHZ",
                     time=dt,
                     output='plot-amp',
                     filename=tempfile)
     self.assertEqual(open(tempfile, 'rb').read(4)[1:4], 'PNG')
     os.remove(tempfile)
     # plot-phase as PNG file
     tempfile = NamedTemporaryFile().name
     client.evalresp(network="IU",
                     station="ANMO",
                     location="00",
                     channel="BHZ",
                     time=dt,
                     output='plot-phase',
                     filename=tempfile)
     self.assertEqual(open(tempfile, 'rb').read(4)[1:4], 'PNG')
     os.remove(tempfile)
     # fap as ASCII file
     tempfile = NamedTemporaryFile().name
     client.evalresp(network="IU",
                     station="ANMO",
                     location="00",
                     channel="BHZ",
                     time=dt,
                     output='fap',
                     filename=tempfile)
     self.assertEqual(
         open(tempfile, 'rt').readline(),
         '1.000000E-05  1.202802E+04  1.792007E+02\n')
     os.remove(tempfile)
     # cs as ASCII file
     tempfile = NamedTemporaryFile().name
     client.evalresp(network="IU",
                     station="ANMO",
                     location="00",
                     channel="BHZ",
                     time=dt,
                     output='cs',
                     filename=tempfile)
     self.assertEqual(
         open(tempfile, 'rt').readline(),
         '1.000000E-05 -1.202685E+04 1.677835E+02\n')
     os.remove(tempfile)
     # fap & def as ASCII file
     tempfile = NamedTemporaryFile().name
     client.evalresp(network="IU",
                     station="ANMO",
                     location="00",
                     channel="BHZ",
                     time=dt,
                     output='fap',
                     units='def',
                     filename=tempfile)
     self.assertEqual(
         open(tempfile, 'rt').readline(),
         '1.000000E-05  1.202802E+04  1.792007E+02\n')
     os.remove(tempfile)
     # fap & dis as ASCII file
     tempfile = NamedTemporaryFile().name
     client.evalresp(network="IU",
                     station="ANMO",
                     location="00",
                     channel="BHZ",
                     time=dt,
                     output='fap',
                     units='dis',
                     filename=tempfile)
     self.assertEqual(
         open(tempfile, 'rt').readline(),
         '1.000000E-05  7.557425E-01  2.692007E+02\n')
     os.remove(tempfile)
     # fap & vel as ASCII file
     tempfile = NamedTemporaryFile().name
     client.evalresp(network="IU",
                     station="ANMO",
                     location="00",
                     channel="BHZ",
                     time=dt,
                     output='fap',
                     units='vel',
                     filename=tempfile)
     self.assertEqual(
         open(tempfile, 'rt').readline(),
         '1.000000E-05  1.202802E+04  1.792007E+02\n')
     os.remove(tempfile)
     # fap & acc as ASCII file
     tempfile = NamedTemporaryFile().name
     client.evalresp(network="IU",
                     station="ANMO",
                     location="00",
                     channel="BHZ",
                     time=dt,
                     output='fap',
                     units='acc',
                     filename=tempfile)
     self.assertEqual(
         open(tempfile, 'rt').readline(),
         '1.000000E-05  1.914318E+08  8.920073E+01\n')
     os.remove(tempfile)
     # fap as NumPy ndarray
     data = client.evalresp(network="IU",
                            station="ANMO",
                            location="00",
                            channel="BHZ",
                            time=dt,
                            output='fap')
     np.testing.assert_array_equal(
         data[0], [1.00000000e-05, 1.20280200e+04, 1.79200700e+02])
     # cs as NumPy ndarray
     data = client.evalresp(network="IU",
                            station="ANMO",
                            location="00",
                            channel="BHZ",
                            time=dt,
                            output='cs')
     np.testing.assert_array_equal(
         data[0], [1.00000000e-05, -1.20268500e+04, 1.67783500e+02])
from obspy.iris import Client
import numpy as np
import matplotlib.pyplot as plt
from obspy.core import UTCDateTime
from obspy.signal import cornFreq2Paz, seisSim

client = Client()
# dt = UTCDateTime(2005, 4, 26, 21, 0, 0, 31225480)
dt = UTCDateTime("2006-5-26")
data = client.evalresp("TA", "M03C", "--", "BHE", dt) 
# data[0]
Beispiel #5
0
 def test_evalresp(self):
     """
     Tests evaluating instrument response information.
     """
     client = Client()
     dt = UTCDateTime("2005-01-01")
     # plot as PNG file
     with NamedTemporaryFile() as tf:
         tempfile = tf.name
         client.evalresp(network="IU", station="ANMO", location="00",
                         channel="BHZ", time=dt, output='plot',
                         filename=tempfile)
         with open(tempfile, 'rb') as fp:
             self.assertEqual(fp.read(4)[1:4], b'PNG')
     # plot-amp as PNG file
     with NamedTemporaryFile() as tf:
         tempfile = tf.name
         client.evalresp(network="IU", station="ANMO", location="00",
                         channel="BHZ", time=dt, output='plot-amp',
                         filename=tempfile)
         with open(tempfile, 'rb') as fp:
             self.assertEqual(fp.read(4)[1:4], b'PNG')
     # plot-phase as PNG file
     with NamedTemporaryFile() as tf:
         tempfile = tf.name
         client.evalresp(network="IU", station="ANMO", location="00",
                         channel="BHZ", time=dt, output='plot-phase',
                         filename=tempfile)
         with open(tempfile, 'rb') as fp:
             self.assertEqual(fp.read(4)[1:4], b'PNG')
     # fap as ASCII file
     with NamedTemporaryFile() as tf:
         tempfile = tf.name
         client.evalresp(network="IU", station="ANMO", location="00",
                         channel="BHZ", time=dt, output='fap',
                         filename=tempfile)
         with open(tempfile, 'rt') as fp:
             self.assertEqual(fp.readline(),
                              '1.000000E-05  1.055999E+04  1.792007E+02\n')
     # cs as ASCII file
     with NamedTemporaryFile() as tf:
         tempfile = tf.name
         client.evalresp(network="IU", station="ANMO", location="00",
                         channel="BHZ", time=dt, output='cs',
                         filename=tempfile)
         with open(tempfile, 'rt') as fp:
             self.assertEqual(fp.readline(),
                              '1.000000E-05 -1.055896E+04 1.473054E+02\n')
     # fap & def as ASCII file
     with NamedTemporaryFile() as tf:
         tempfile = tf.name
         client.evalresp(network="IU", station="ANMO", location="00",
                         channel="BHZ", time=dt, output='fap', units='def',
                         filename=tempfile)
         with open(tempfile, 'rt') as fp:
             self.assertEqual(fp.readline(),
                              '1.000000E-05  1.055999E+04  1.792007E+02\n')
     # fap & dis as ASCII file
     with NamedTemporaryFile() as tf:
         tempfile = tf.name
         client.evalresp(network="IU", station="ANMO", location="00",
                         channel="BHZ", time=dt, output='fap', units='dis',
                         filename=tempfile)
         with open(tempfile, 'rt') as fp:
             self.assertEqual(fp.readline(),
                              '1.000000E-05  6.635035E-01  2.692007E+02\n')
     # fap & vel as ASCII file
     with NamedTemporaryFile() as tf:
         tempfile = tf.name
         client.evalresp(network="IU", station="ANMO", location="00",
                         channel="BHZ", time=dt, output='fap', units='vel',
                         filename=tempfile)
         with open(tempfile, 'rt') as fp:
             self.assertEqual(fp.readline(),
                              '1.000000E-05  1.055999E+04  1.792007E+02\n')
     # fap & acc as ASCII file
     with NamedTemporaryFile() as tf:
         tempfile = tf.name
         client.evalresp(network="IU", station="ANMO", location="00",
                         channel="BHZ", time=dt, output='fap', units='acc',
                         filename=tempfile)
         with open(tempfile, 'rt') as fp:
             self.assertEqual(fp.readline(),
                              '1.000000E-05  1.680674E+08  8.920073E+01\n')
     # fap as NumPy ndarray
     data = client.evalresp(network="IU", station="ANMO", location="00",
                            channel="BHZ", time=dt, output='fap')
     np.testing.assert_array_equal(
         data[0], [1.00000000e-05, 1.05599900e+04, 1.79200700e+02])
     # cs as NumPy ndarray
     data = client.evalresp(network="IU", station="ANMO", location="00",
                            channel="BHZ", time=dt, output='cs')
     np.testing.assert_array_equal(
         data[0], [1.00000000e-05, -1.05589600e+04, 1.47305400e+02])