示例#1
0
def getCatData(date, opt):

    """
    Download data from IRIS or Earthworm waveserver with padding and filter it. This is
    a specialized version getData() for catalog events, pulling a smaller amount of time
    around a known event.

    date: UTCDateTime of known catalog event
    opt: Options object describing station/run parameters
    
    Returns ObsPy stream objects, one for cutting and the other for triggering
    """    
    
    nets = opt.network.split(',')
    stas = opt.station.split(',')
    locs = opt.location.split(',')
    chas = opt.channel.split(',')
    
    if opt.server == "IRIS":
        client = Client("IRIS")
    else:
        client = EWClient(opt.server, opt.port)
        
    st = Stream()
    for n in range(len(stas)):
        try:
            stmp = client.get_waveforms(nets[n], stas[n], locs[n], chas[n],
                    date - opt.atrig, date + 3*opt.atrig)
            stmp = stmp.filter("bandpass", freqmin=opt.fmin, freqmax=opt.fmax,
                corners=2, zerophase=True)
            stmp = stmp.merge(method=1, fill_value='interpolate')
        except (obspy.fdsn.header.FDSNException):
            try: # try again
                stmp = client.get_waveforms(nets[n], stas[n], locs[n], chas[n],
                        date - opt.atrig, date + 3*opt.atrig)
                stmp = stmp.filter("bandpass", freqmin=opt.fmin, freqmax=opt.fmax,
                    corners=2, zerophase=True)
                stmp = stmp.merge(method=1, fill_value='interpolate')
            except (obspy.fdsn.header.FDSNException):
                print('No data found for {0}.{1}'.format(stas[n],nets[n]))
                trtmp = Trace()
                trtmp.stats.sampling_rate = opt.samprate
                trtmp.stats.station = stas[n]
                stmp = Stream().extend([trtmp.copy()])
        # Resample to ensure all traces are same length
        if stmp[0].stats.sampling_rate != opt.samprate:
            stmp = stmp.resample(opt.samprate)
        st.extend(stmp.copy()) 
    
    st = st.trim(starttime=date-opt.atrig, endtime=date+3*opt.atrig, pad=True,
        fill_value=0)
    stC = st.copy() 

    return st, stC
示例#2
0
time_max = 80

dir = '/raid3/zl382/Data/20161225/fk_analysis/az_330.0dist_123.0/'
seislist = glob.glob(dir + '*PICKLE')

#Load data
st = Stream()
for i, seisname in enumerate(seislist):
    seis = read(seisname, format='PICKLE')
    st += seis.select(channel='BHT')
    st[i].stats.coordinates = AttribDict({
        'latitude': seis[0].stats['stla'],
        'elevation': seis[0].stats['stelv'] / 1000,
        'longitude': seis[0].stats['stlo']
    })
st.resample(10)
# Execute array_processing
Sdifftime = seis[0].stats.traveltimes['Sdiff'] or seis[0].stats.traveltimes['S']
stime = st[0].stats['eventtime'] + Sdifftime - 40
etime = st[0].stats['eventtime'] + Sdifftime + 80
zerotime = st[0].stats['eventtime'] + Sdifftime

kwargs = dict(
    # slowness grid: X min, X max, Y min, Y max, Slow Step
    sll_x=-5.0,
    slm_x=5.0,
    sll_y=-5.0,
    slm_y=5.0,
    sl_s=0.05,
    # sliding window properties
    win_len=10.0,
示例#3
0
# 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')
示例#4
0
            tr.data = np.abs(hilbert(tr.data))
        tr.normalize()
        if np.isnan(tr.data).any():
            continue
        strmacc1.append(tr.copy())
        stalist1.append(tr.id)

        reftime = fppdp(70, evdep1)
        ctime = fppdp(dis1.delta, evdep1)
        ctime = reftime - ctime
        data = np.roll(tr.data, int(np.round(ctime * rsample)))
        tr.data = data

    print('finishing', time.time() - start)

    strmacc1.resample(rsample)
    if len(strmacc1) < 10:
        print('small no. of traces:', len(strmacc1))
        continue

    refdismax = 70

    nsta = len(strmacc1)
    npts = strmacc1[0].stats.npts
    depstack = np.zeros(npts, )

    #     print reflat,reflon,refdismax,len(strmacc1)

    reftime = fppdp(refdismax, evdep1)
    #         data = abs(hilbert(strmacc1[0].data.copy()))
    data = strmacc1[0].data.copy()