Beispiel #1
0
def makedata3d(cpara, velmod3d, log=setuplog(), raytracing3d=True):
    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 = RFStation(evt_lst, only_r=True)
        stadatar.stel = sta_info.stel[i]
        stadatar.stla = sta_info.stla[i]
        stadatar.stlo = sta_info.stlo[i]
        if stadatar.prime_phase == 'P':
            sphere = True
        else:
            sphere = False
        log.RF2depthlog.info('the {}th/{} station with {} events'.format(
            i + 1, sta_info.stla.shape[0], stadatar.ev_num))
        if raytracing3d:
            pplat_s, pplon_s, pplat_p, pplon_p, newtpds = psrf_3D_raytracing(
                stadatar, cpara.depth_axis, mod3d, srayp=srayp, sphere=sphere)
        else:
            pplat_s, pplon_s, pplat_p, pplon_p, raylength_s, raylength_p, tps = psrf_1D_raytracing(
                stadatar,
                cpara.depth_axis,
                srayp=srayp,
                sphere=sphere,
                phase=cpara.phase)
            newtpds = psrf_3D_migration(pplat_s, pplon_s, pplat_p, pplon_p,
                                        raylength_s, raylength_p, tps,
                                        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)
    np.save(cpara.depthdat, RFdepth)
Beispiel #2
0
def makedata(cpara, velmod3d=None, modfolder1d=None, log=setuplog()):
    ismod1d = False
    if velmod3d is not None:
        if isinstance(velmod3d, str):
            velmod = velmod3d
        else:
            raise ValueError('Path to 3d velocity model should be in str')
    elif modfolder1d is not None:
        if isinstance(modfolder1d, str):
            if exists(modfolder1d):
                ismod1d = True
            else:
                raise FileNotFoundError(
                    'No such folder of {}'.format(modfolder1d))
        else:
            ValueError('Path to 1d velocity model files should be in str')
    else:
        ismod1d = True

    # 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 = RFStation(evt_lst, only_r=True)
        stadatar.stel = sta_info.stel[i]
        stadatar.stla = sta_info.stla[i]
        stadatar.stlo = sta_info.stlo[i]
        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]])
        if stadatar.prime_phase == 'P':
            sphere = True
        else:
            sphere = False
        if ismod1d:
            if modfolder1d is not None:
                velmod = _load_mod(modfolder1d, sta_info.station[i])
            else:
                velmod = cpara.velmod
        PS_RFdepth, end_index, x_s, _ = psrf2depth(stadatar,
                                                   cpara.depth_axis,
                                                   velmod=velmod,
                                                   srayp=cpara.rayp_lib,
                                                   sphere=sphere,
                                                   phase=cpara.phase)
        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'] = stadatar.phase[i]
        rfdep['moveout_correct'] = PS_RFdepth
        rfdep['piercelat'] = piercelat
        rfdep['piercelon'] = piercelon
        rfdep['stopindex'] = end_index
        RFdepth.append(rfdep)
    # savemat(cpara.depthdat, {'RFdepth': RFdepth})
    np.save(cpara.depthdat, RFdepth)