def read_process_data(lst): stadata = SACStation(lst, only_r=True) idx = np.argsort(stadata.bazi) stadata.event = stadata.event[idx] stadata.bazi = stadata.bazi[idx] stadata.datar = stadata.datar[idx] time_axis = np.arange(stadata.RFlength) * stadata.sampling - stadata.shift return stadata, time_axis
def read_process_data(path, resamp_dt=0.1): stadata = SACStation(path) stadata.resample(resamp_dt) idx = np.argsort(stadata.bazi) stadata.event = stadata.event[idx] stadata.bazi = stadata.bazi[idx] stadata.datar = stadata.datar[idx] stadata.datat = stadata.datat[idx] return stadata
def read_process_data(lst, resamp_dt=0.1): stadata = SACStation(lst) stadata.resample(resamp_dt) idx = np.argsort(stadata.bazi) stadata.event = stadata.event[idx] stadata.bazi = stadata.bazi[idx] stadata.datar = stadata.datar[idx] stadata.datat = stadata.datat[idx] time_axis = np.arange(stadata.RFlength) * stadata.sampling - stadata.shift return stadata, time_axis
def makedata(cpara, velmod3d=None, log=setuplog()): if velmod3d is not None: if isinstance(velmod3d, str): if exists(velmod3d): model_3d = np.load(velmod3d) else: model_3d = None else: raise ValueError('Path to 3d velocity model should be in str') else: model_3d = None # cpara = ccppara(cfg_file) sta_info = Station(cpara.stalist) RFdepth = [] for i in range(sta_info.stla.shape[0]): rfdep = {} evt_lst = join(cpara.rfpath, sta_info.station[i], sta_info.station[i] + 'finallist.dat') stadatar = SACStation(evt_lst, only_r=True) log.RF2depthlog.info('the {}th/{} station with {} events'.format( i + 1, sta_info.stla.shape[0], stadatar.ev_num)) piercelat = np.zeros([stadatar.ev_num, cpara.depth_axis.shape[0]]) piercelon = np.zeros([stadatar.ev_num, cpara.depth_axis.shape[0]]) PS_RFdepth, end_index, x_s, x_p = psrf2depth(stadatar, cpara.depth_axis, stadatar.sampling, stadatar.shift, cpara.velmod, velmod_3d=model_3d, srayp=cpara.rayp_lib) for j in range(stadatar.ev_num): piercelat[j], piercelon[j] = latlon_from(sta_info.stla[i], sta_info.stlo[i], stadatar.bazi[j], rad2deg(x_s[j])) rfdep['Station'] = sta_info.station[i] rfdep['stalat'] = sta_info.stla[i] rfdep['stalon'] = sta_info.stlo[i] # rfdep['Depthrange'] = cpara.depth_axis # rfdep['events'] = _convert_str_mat(stadatar.event) rfdep['bazi'] = stadatar.bazi rfdep['rayp'] = stadatar.rayp # rfdep['phases'] = _convert_str_mat(stadatar.phase) rfdep['moveout_correct'] = PS_RFdepth rfdep['Piercelat'] = piercelat rfdep['Piercelon'] = piercelon rfdep['StopIndex'] = end_index RFdepth.append(rfdep) savemat(cpara.depthdat, {'RFdepth': RFdepth})
def hksta(hpara, isplot=False): station = basename(hpara.rfpath) stadata = SACStation(join(hpara.rfpath, station+'finallist.dat'), only_r=True) stack, _, allstack, _ = hkstack(stadata.datar, stadata.shift, stadata.sampling, srad2skm(stadata.rayp), hpara.hrange, hpara.krange, vp=hpara.vp, weight=hpara.weight) besth, bestk, cvalue, maxhsig, maxksig = ci(allstack, hpara.hrange, hpara.krange, stadata.ev_num) with open(hpara.hklist, 'a') as f: f.write('{}\t{:.3f}\t{:.3f}\t{:.1f}\t{:.2f}\t{:.2f}\t{:.3f}\n'.format(station, stadata.stla, stadata.stlo, besth, maxhsig, bestk, maxksig)) title = '{}\nMoho depth = ${:.1f}\pm{:.2f}$\nV_P/V_S = ${:.2f}\pm{:.3f}$'.format(station, besth, maxhsig, bestk, maxksig) if isplot: img_path = join(hpara.hkpath, station+'.pdf') plot(stack, allstack, hpara.hrange, hpara.krange, besth, bestk, cvalue, title=title, path=img_path) else: plot(stack, allstack, hpara.hrange, hpara.krange, besth, bestk, cvalue, title=title)
def makedata3d(cpara, velmod3d, log=setuplog()): mod3d = Mod3DPerturbation(velmod3d, cpara.depth_axis, velmod=cpara.velmod) sta_info = Station(cpara.stalist) if cpara.rayp_lib is not None: srayp = np.load(cpara.rayp_lib) else: srayp = None RFdepth = [] for i in range(sta_info.stla.shape[0]): rfdep = {} evt_lst = join(cpara.rfpath, sta_info.station[i], sta_info.station[i] + 'finallist.dat') stadatar = SACStation(evt_lst, only_r=True) log.RF2depthlog.info('the {}th/{} station with {} events'.format( i + 1, sta_info.stla.shape[0], stadatar.ev_num)) pplat_s, pplon_s, pplat_p, pplon_p, raylength_s, raylength_p, tpds = psrf_1D_raytracing( sta_info.stla[i], sta_info.stlo[i], stadatar, cpara.depth_axis, srayp=srayp) newtpds = psrf_3D_migration(pplat_s, pplon_s, pplat_p, pplon_p, raylength_s, raylength_p, tpds, cpara.depth_axis, mod3d) amp3d, end_index = time2depth(stadatar, cpara.depth_axis, newtpds) rfdep['Station'] = sta_info.station[i] rfdep['stalat'] = sta_info.stla[i] rfdep['stalon'] = sta_info.stlo[i] # rfdep['Depthrange'] = cpara.depth_axis # rfdep['events'] = _convert_str_mat(stadatar.event) rfdep['bazi'] = stadatar.bazi rfdep['rayp'] = stadatar.rayp # rfdep['phases'] = _convert_str_mat(stadatar.phase) rfdep['moveout_correct'] = amp3d rfdep['Piercelat'] = pplat_s rfdep['Piercelon'] = pplon_s rfdep['StopIndex'] = end_index RFdepth.append(rfdep) try: savemat(cpara.depthdat, {'RFdepth': RFdepth}) except FileNotFoundError: log.RF2depthlog.warning('No such file or directory: {}'.format( dirname(cpara.depthdat))) rfdep_path = input('Enter a exist path:') savemat(rfdep_path, {'RFdepth': RFdepth})