import obspy from obspy.core.trace import Trace import numpy as np # Creating trace in obspy npts = 10000 trace_data = np.random.rand(npts) or_time = obspy.UTCDateTime(2019,10,15,10,0,0) # Origin Time dt = 1/20. Trace = Trace(trace_data, header={"starttime": or_time, 'delta': dt}) start = obspy.UTCDateTime(2019,10,15,10,1,0) end = obspy.UTCDateTime(2019,10,15,10,1,40) Trace.trim(starttime=start, endtime=end, pad=True, nearest_sample=True, fill_value=0.0) a=1
statsN.sampling_rate = 1.0 / sampling_rate_x statsN.delta = sampling_rate_x statsN.starttime = starttime statsN.npts = len(traceN.data) statsN.network = net statsN.station = stationname statsN.location = '' statsN.channel = channelnameN traceN.stats = statsN traceN.stats.sac = obspy.core.AttribDict() traceN.stats.sac.back_azimuth = plottheta # use this as azimuth of station #---applying filters---# traceN.filter('bandpass', freqmin=freqmin, freqmax=freqmax) tN = traceN.stats.starttime traceN.trim(starttime=tN, endtime=tN + trim_end_time) traceN.taper(0.05, side='right') #----------------------# stemp += Stream(traceN) # for EW components statsE = Stats() statsE.sampling_rate = 1.0 / sampling_rate_z statsE.delta = sampling_rate_z statsE.starttime = starttime statsE.npts = len(traceN.data) statsE.network = net statsE.station = stationname statsE.location = '' statsE.channel = channelnameE traceE.stats = statsE