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])