def remove_response_paz(st, paz_path, pre_filt): """ remove response using paz file """ for trace in st: # get key network = trace.stats.network station = trace.stats.station channel = trace.stats.channel key = f"{network}.{station}.{channel}" paz_path_used = join(paz_path, key) # try to read paz try: attach_paz(trace, paz_path_used) except: # pylint: disable=bare-except return None # ndarray data = simulate_seismometer(trace.data, trace.stats.sampling_rate, paz_remove=trace.stats.paz, water_level=6e9, zero_mean=False, taper=False, pre_filt=pre_filt, sacsim=True) trace.data = data return st
def remove_response(st, pre_filt=None, inv=None): for index, item in enumerate(st): pz_vir_file = io.StringIO() inv_tr = inv.select(channel=item.stats.channel) inv_tr.write(pz_vir_file, format="SACPZ") pz_vir_file.seek(0) attach_paz(item, pz_vir_file) data = simulate_seismometer(item.data, item.stats.sampling_rate, paz_remove=item.stats.paz, water_level=6e9, zero_mean=False, taper=False, pre_filt=pre_filt, sacsim=True) st[index].data = data return st
st = read('RAW/*', debug_headers=True) k = len(st) i = 0 while i < k: tr = st[i] print(tr.id, tr.stats.starttime.year, tr.stats.starttime.julday) ### differential Volcity to Accerletion diftr = obspy.core.trace.Trace.differentiate(tr) ### Pole and Zero chn = tr.stats.channel sta = tr.stats.station Ps = "PZs/" + "*" + sta + "*" + "HHZ" + "*" HH_paz = glob.glob(Ps) pz.attach_paz(diftr, HH_paz[0]) paz = dict(diftr.stats.paz) ### power spectrum density ppsd = PPSD(diftr.stats, paz, ppsd_length=3600.0, overlap=0.95) ppsd.add(diftr) [t, amp] = ppsd.get_mode() ### Output ts = str(tr.stats.starttime.year) + "." + str(tr.stats.starttime.julday) txt = sta + "." + chn + "." + ts + ".txt" with open(txt, mode="w") as f: for j in range(len(t)): f.write("%e %6.2f\n" % (t[j], amp[j])) i += 1
et = event.origins[0].time #Get eventtime #print('Event time: %s' %et) path = '../WAV/%s/%d/%02d/%d-%02d-%02d-*'\ %(wav_path, et.year, et.month, et.year, et.month, et.day) #Read in corresponding waveform #Find file with corresponding file name for fname in glob.glob(path): stream = obspy.read(fname) if stream[0].stats.starttime > et-40 and stream[0].stats.starttime < et: st1 = stream #print('Filename: %s' %fname) #Remove instrument response for tr in st1: attach_paz(tr, '/Volumes/LS_M2/PpolPackage-master/response/SAC_PZs_XX_SPOBS2_SHZ_00_2001.001.00.00.00.0000_2021.001.24.60.60.99999') st1.simulate(paz_remove = tr.stats.paz) #Preprocessing st1.detrend('demean') st1.detrend('simple') st1.taper(max_percentage = 0.01, type = 'hann') st1.filter('bandpass', freqmin = fmi, freqmax = fma) #Select traces from specific station st = obspy.core.stream.Stream() for tr in st1.select(station = 'LSb%s' %ns): st.append(tr) #print(st)
if dist > d_con: et = event.origins[0].time #get eventtime path = path_to_wav + '/%d/%02d/%d-%02d-%02d-*'\ %(et.year, et.month, et.year, et.month, et.day) #read in corresponding waveform # Find file with corresponding file name that fits to the eventtime for fname in glob.glob(path): stream = obspy.read(fname) if stream[0].stats.starttime > et - 40 and stream[ 0].stats.starttime < et: st1 = stream #print('filename: %s' %fname) # Remove instrument response for tr in st1: attach_paz(tr, path_to_response_file) st1.simulate(paz_remove=tr.stats.paz) # Preprocessing st1.detrend('demean') st1.detrend('simple') st1.taper(max_percentage=0.01, type='hann') st1.filter('bandpass', freqmin=fmi, freqmax=fma) # Select traces from specific station st = obspy.core.stream.stream() for tr in st1.select(station='lsb%s' % ns): st.append(tr) #print(st)