startaim = max([tr.stats.starttime for tr in (AC + RLAS)]) endtaim = min([tr.stats.endtime for tr in (AC + RLAS)]) AC.trim(startaim, endtaim, nearest_sample=True) RLAS.trim(startaim, endtaim, nearest_sample=True) # **Resample, Filter and Rotate** # In[4]: RLAS.decimate(factor=4) AC.decimate(factor=4) f_cutoff = 1.0 RLAS.filter('lowpass', freq=f_cutoff, corners=2, zerophase=True) AC.filter('lowpass', freq=f_cutoff, corners=2, zerophase=True) # event location from event info source_latitude = event.origins[0].latitude source_longitude = event.origins[0].longitude # station location (Wettzell) station_latitude = 49.144001 station_longitude = 12.8782 # theoretical backazimuth and distance baz = gps2dist_azimuth(source_latitude, source_longitude, station_latitude, station_longitude)
# get list of all days and of unique days days_all = np.array([ datetime.strptime(a[-8:], '%Y.%j').strftime('%Y.%m.%d') for a in dayfiles ]) days = np.unique(days_all) for dy in days: file_list = dayfiles[np.where( days_all == dy)] # files for this day, all stations st = Stream() for fl in file_list: if fl not in bad_files and os.stat(fl).st_size != 0: st += read(fl) if len(st) > 0: # decimate or resample to 1Hz if np.all([tr.stats.sampling_rate == 100 for tr in st]): st.decimate(100, no_filter=True) else: st.resample(1.0, no_filter=True) st.merge(method=1, fill_value=0) # make sure 1 trace per sta/comp for tr in st: # rename channels to L* to match [edited] dataless tr.stats.channel = 'L' + tr.stats.channel[1:] # write miniseed ofile = os.path.join(mseed_dir_out,'EN-%s.%s.%s.mseed' % \ (dy.split('.')[0],dy.split('.')[1],dy.split('.')[2])) st.write(ofile, format='MSEED')
for ax in [ax1,ax2,ax3,ax4]: ax.legend(loc=2, prop={"size":12}) ax.yaxis.major.formatter.set_powerlimits((-1,2)) ax.set_xlim(0,max(AC[0].times())) fig.tight_layout() plt.show() # - # ### Resample, Filter and Rotate # Resample seismograms using **decimate** in order to reduce the size of the arrays (speeds up processing). # The seismograms are high-cut and low-cut filtered, depending on the frequency range of interest and the resolution of the instruments. # + RLAS.decimate(factor=4) AC.decimate(factor=4) high_cut = 1.0 low_cut = 0.005 RLAS.filter('bandpass', freqmax=high_cut, freqmin=low_cut, corners=2, zerophase=True) AC.filter('bandpass', freqmax=high_cut, freqmin=low_cut, corners=2, zerophase=True) # - # In order to align the seismometer recordings with the event direction, we need to rotate the horizontal components<br> # of the acceleration to transverse and radial.<br> # <br> # We can determine the theoretical rotation/direction angle (= backazimuth) from station and event location using **gps2dist_azimuth**.<br> # This function also yields the epicentral distance and the azimuth angle. # + from obspy.geodetics.base import gps2dist_azimuth