Coverage for /opt/obspy/update-docs/src/obspy/obspy/signal/tests/test_invsim : 100%

Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
#!/usr/bin/env python # -*- coding: utf-8 -*- The InvSim test suite. """
# Seismometers defined as in Pitsa with one zero less. The corrected # signals are in velocity, thus must be integrated to offset and take one # zero less than pitsa (remove 1/w in frequency domain) -6.2832 + 4.7124j], 'zeros': [0.0 + 0.0j] * 1, 'sensitivity': 1.0, 'gain': 1. / 2.25}
-4.0093 + 4.0093j, -4.6077 - 6.9967j, -4.6077 + 6.9967j], 'zeros': [0.0 + 0.0j] * 2, 'sensitivity': 1.0, 'gain': 1. / 1.0413}
-0.4189 + 0.0j, -0.0628 + 0.0j, -0.0628 + 0.0j], 'zeros': [0.0 + 0.0j] * 2, 'sensitivity': 1.0, 'gain': 1. / 0.0271}
-0.1257 + 0.2177j, -83.4473 + 0.0j, -0.3285 + 0.0j], 'zeros': [0.0 + 0.0j] * 2, 'sensitivity': 1.0, 'gain': 1. / 1.61}
'kirnos': PAZ_KIRNOS, 'wood_anderson': PAZ_WOOD_ANDERSON, 'wwssn_lp': PAZ_WWSSN_LP, 'wwssn_sp': PAZ_WWSSN_SP}
""" Test cases for InvSim. """ # directory where the test files are located
""" Test seisSim seismometer simulation against seismometer simulation of Pitsa - LE3D seismometer. """ # load test file
# paz of test file - 4.21 - 4.66j, - 2.105 + 0.0j], 'zeros': [0.0 + 0.0j] * 3, 'sensitivity': 1.0, 'gain': 0.4}
# simulate instrument paz_simulate=paz, water_level=600.0, zero_mean=False, nfft_pow2=True) # load pitsa file # calculate normalized rms np.sum(data_pitsa ** 2))
""" Test seisSim seismometer simulation against seismometer simulation of Pitsa - STS-2 seismometer. """ # load test file
# paz of test file - 0.03736 + 0.03617j], 'zeros': [0.0 + 0.0j] * 2, 'sensitivity': 1.0, 'gain': 1.5}
# simulate instrument paz_simulate=paz, water_level=600.0, zero_mean=False, nfft_pow2=True) # load pitsa file # calculate normalized rms np.sum(data_pitsa ** 2))
""" Tests against PITSA. Note that PITSA displays microvolt, that is the amplitude values must be computed back into counts (for this stations .596microvolt/count was used). Pitsa internally calculates with the sensitivity 2800 of the WA. Using this we get for the following for event 2009-07-19 23:03::
RTSH PITSA 2.263 ObsPy 2.294 RTBE PITSA 1.325 ObsPy 1.363 RMOA PITSA 1.629 ObsPy 1.675 """ 'zeros': [0 + 0j, 0 + 0j, 0 + 0j], \ 'gain': 1.0, \ 'sensitivity': 671140000.0}
#XXX: Test for really big signal is missing, where the water level is # actually acting #def test_seisSimVsPitsa2(self): # from obspy.mseed import test as tests_ # path = os.path.dirname(__file__) # file = os.path.join(path, 'data', 'BW.BGLD..EHE.D.2008.001') # g = Trace() # g.read(file,format='MSEED') # # paz of test file # samp_rate = 200.0
# SAC recommends to taper the transfer function if a pure # deconvolution is done instead of simulating a different # instrument. This test checks the difference between the # result from removing the instrument response using SAC or # ObsPy. Visual inspection shows that the traces are pretty # much identical but differences remain (rms ~ 0.042). Haven't # found the cause for those, yet. One possible reason is the # floating point arithmetic of SAC vs. the double precision # arithmetic of Python. However differences still seem to be # too big for that. #Uncomment the following to run the sac-commands #that created the testing file #if 1: # import subprocess as sp # p = sp.Popen('sac',shell=True,stdin=sp.PIPE) # cd1 = p.stdin # print >>cd1, "r %s"%sacf # print >>cd1, "rmean" # print >>cd1, "rtrend" # print >>cd1, "taper type cosine width 0.03" # print >>cd1, "transfer from polezero subtype %s to none \ # freqlimits %f %f %f %f" % (pzf, fl1, fl2, fl3, fl4) # print >>cd1, "w over ./data/KARC_corrected.sac" # print >>cd1, "quit" # cd1.close() # p.wait()
'station': 'KARC', 'location': 'S1', 'starttime': UTCDateTime(2001, 2, 13, 0, 0, 0, 993700), 'calib': 1.00868e+09, 'channel': 'BHZ'}
paz_remove=tr.stats.paz, remove_sensitivity=False, pre_filt=(fl1, fl2, fl3, fl4))
# import matplotlib.pyplot as plt # plt.plot(tr.data) # plt.plot(data) # plt.show() np.sum(tr.data ** 2))
""" Compare results from removing instrument response using evalresp in SAC and ObsPy. Visual inspection shows that the traces are pretty much identical but differences remain (rms ~ 0.042). Haven't found the cause for those, yet. """
# #Set the following if-clause to True to run # #the sac-commands that created the testing file # if False: # import subprocess as sp # p = sp.Popen('sac', stdin=sp.PIPE) # cd1 = p.stdin # print >>cd1, "r %s" % rawf # print >>cd1, "rmean" # print >>cd1, "taper type cosine width 0.05" # print >>cd1, "transfer from evalresp fname %s to vel freqlimits\ # %f %f %f %f" % (respf, fl1, fl2, fl3, fl4) # print >>cd1, "w over %s" % evalrespf # print >>cd1, "quit" # cd1.close() # p.wait()
pre_filt=(fl1, fl2, fl3, fl4), seedresp=seedresp, taper_fraction=0.1, pitsasim=False, sacsim=True) np.sum(trtest.data ** 2)) #import matplotlib.pyplot as plt #plt.plot(tr.data-trtest.data,'b') #plt.plot(trtest.data,'g') #plt.figure() #plt.psd(tr.data,Fs=100.,NFFT=32768) #plt.psd(trtest.data,Fs=100.,NFFT=32768) #plt.figure() #plt.psd(tr.data - trtest.data, Fs=100., NFFT=32768) #plt.show()
# SAC trace was generated with: # taper type cosine width 0.05 'ones_trace_%d_tapered.sac' % i)
# The following lines compare the cosTaper result with # the result of the algorithm used by SAC in its taper routine # (taper.c) #freqs = np.fft.fftfreq(2**15,0.01) #fl1 = 0.00588 #fl2 = 0.00625 #fl3 = 30.0 #fl4 = 35.0 #npts = freqs.size #tap = cosTaper(freqs.size, freqs=freqs, flimit=(fl1, fl2, fl3, fl4)) #tap2 = c_sac_taper(freqs.size, freqs=freqs, # flimit=(fl1, fl2, fl3, fl4)) #import matplotlib.pyplot as plt #plt.plot(tap,'b') #plt.plot(tap2,'g--') #plt.show()
""" The evalresp needs a file with correct line separator, so '\n' for POSIX, '\r' for Mac OS, or '\r\n' for Windows. Here we check that evalresp reads all three formats.
This test only checks the parsing capabilities of evalresp, the number of fft points used (nfft) can therefore be chosen small. """ # linux # mac # windows
""" Was a bug due to inconstistent numerical range """ UTCDateTime(2012, 9, 4, 5, 12, 15, 863300)]
if __name__ == '__main__': unittest.main(defaultTest='suite') |