예제 #1
0
        
#hard_start = 0
hard_start = eventpaths.index(boxpath + '/cutdata_s/Event_2010_06_13_03_08_57/AZ_PFO_HHE__2010_06_13_03_08_57.SAC')
print(hard_start)
        
        
#read in cut data, rmean and rtrend, find .resp file, correct and add to icorr dir
for i in range(hard_start,len(eventpaths)):#in this case event paths are all sac files
    base = path.basename(eventpaths[i])
    print 'correcting file: ' + base
    folder = eventpaths[i].split('/')[-2]
    network = base.split('_')[0]
    station = base.split('_')[1]
    full_channel = base.split('_')[2]
    #find response file
    respfile = response_path + '/' + network + '.' + station + '.' + channel + '.resp'
    #first rmean and rtrend
    stream = read(eventpaths[i])
    tr = stream[0]
    #check and make sure that the trace isn't empty
    if(tr.stats.npts > 0):
        tr.detrend(type = 'demean')#removes mean of data
        tr.detrend(type = 'simple')#rtrend linear from first and last samples
        #rewrite to a sac file
        tr.write('temp.sac', format = 'sac')
        sacfile = 'temp.sac'
        icorr_sacfile = icorr_path + '/' + folder + '/'+ base
        #uncorrected_sac_file,resp_file,corrected_sac_file,water_level_bds,resp_unit
        wf.remove_response(sacfile,respfile,icorr_sacfile,prefilt,tsunit)#prefilt values for HH
    
    
    raw_file_N = boxpath + '/cutdata_s/Event_' + eventid + '/' + network + '_' + station + '_HHN_' + loc + '_' + eventid + '.SAC'

    prefilt = (0, 0.4, 35, 50)
    respfile = top_dir + '/boxes/' + box + '/respfiles/' + network + '.' + station + '.HH*.resp'
    tsunit = 'VEL'
    icorr_sacfile = top_dir + '/boxes/' + box + '/icorrN.SAC'

    stream = read(raw_file_N)
    tr = stream[0]
    #    tr.detrend(type = 'demean')#removes mean of data
    #    tr.detrend(type = 'simple')#rtrend linear from first and last samples
    #rewrite to a sac file
    tr.write('temp.sac', format='sac')
    sacfile = 'temp.sac'

    wf.remove_response(sacfile, respfile, icorr_sacfile, prefilt, tsunit)

    stream = read(icorr_sacfile)
    tr = stream[0]
    dataN = tr.data

    raw_file_E = boxpath + '/cutdata_s/Event_' + eventid + '/' + network + '_' + station + '_HHE_' + loc + '_' + eventid + '.SAC'

    respfile = top_dir + '/boxes/' + box + '/respfiles/AZ.BZN.HH*.resp'
    tsunit = 'VEL'
    icorr_sacfile = top_dir + '/boxes/' + box + '/icorrE.SAC'
    stream = read(raw_file_E)
    tr = stream[0]
    #    tr.detrend(type = 'demean')#removes mean of data
    #    tr.detrend(type = 'simple')#rtrend linear from first and last samples
    #rewrite to a sac file
예제 #3
0
    #    st = stream
    tr = stream[0]
    ny = tr.stats.sampling_rate * 0.5
    print ny
    #    ny = 0.125
    ####################
    prefilt = (0.0, 0.01, 0.7 * ny, ny)

    tr.detrend(type='demean')  #removes mean of data
    tr.detrend(type='simple')  #rtrend linear from first and last samples
    #rewrite to a sac file
    tr.write('temp.sac', format='sac')
    sacfile = 'temp.sac'
    icorr_sacfile = icorr_path + '/' + base

    wf.remove_response(sacfile, respfile, icorr_sacfile, prefilt,
                       'VEL')  #, plot=True)#prefilt values for HH

f = glob.glob(workingdir + 'corrected/*.sac')
for i in range(len(f)):
    st = read(f[i])
    name = (f[i].split('/')[-1])[0:-4]  #.split('.')[0:4]
    print name
    fig = st.plot()
    fig.savefig(workingdir + 'corrected/' + name + '.png')

#f = glob.glob(workingdir + 'corrected/*.sac')
#for i in range(len(f)):
#    st = read(f[i])
#    name = (f[i].split('/')[-1])[0:-4]#.split('.')[0:4]
#    print name
##    st.filter("bandpass", freqmin=.001, freqmax=0.125,corners=2, zerophase=False)