Beispiel #1
0
 def __init__(self, eqs, para, width=21, height=11, dpi=100):
     self.eqs = eqs
     self.row_num = eqs.shape[0]
     self.para = para
     self.log = setuplog()
     self.idx = 0
     self.init_figure(width=width, height=height, dpi=dpi)
     self.plot()
     self.drop_lst = []
     self.drop_color = 'lightgray'
Beispiel #2
0
 def __init__(self, rfpath, width=21, height=11, dpi=100, xlim=[-2, 30]):
     super(RFFigure, self).__init__()
     self.width = width
     self.height = height
     self.dpi = dpi
     self.log = setuplog()
     self.rfpath = rfpath
     self.enf = 3.5
     self.ipage = 0
     self.maxidx = 20
     self.xlim = xlim
Beispiel #3
0
 def __init__(self, cfg_file=None, log=None):
     if log is None:
         self.logger = setuplog()
     else:
         self.logger = log
     if cfg_file is None:
         self.cpara = CCPPara()
     elif isinstance(cfg_file, str):
         self.load_para(cfg_file)
     else:
         raise ValueError('cfg_file must be str format.')
     self.stack_data = []
Beispiel #4
0
 def __init__(self, log=None):
     if log is None:
         self.logger = setuplog()
     else:
         self.logger = log
     self.lats = np.array([])
     self.lons = np.array([])
     self.deps = np.array([])
     self.vps = np.array([])
     self.vss = np.array([])
     self.ddvsddvp = np.array([[150, 200, 250, 300, 350, 400, 450, 500, 550, 600, 650, 700],
                              [1.85, 1.75, 1.75, 1.75, 1.79, 1.75, 2, 1.79, 1.61, 1.67, 1.67, 2.13]])
Beispiel #5
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)
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})
Beispiel #7
0
    def __init__(self, rfpath, width=21, height=11, dpi=100):
        super(RFFigure, self).__init__()

        self.log = setuplog()
        self.rfpath = rfpath
        self.enf = 3
        self.ipage = 0
        self.maxidx = 20
        self.xlim = [-2, 30]

        self.init_figure(width=21, height=11, dpi=100)
        self.read_sac()
        self.set_page()
        self.init_variables()
        self.plotwave()
        self.plotbaz()
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})
Beispiel #9
0
 def __init__(self, eqs, para, logger, width=21, height=11, dpi=100):
     self.eqs = eqs
     self.logger = logger
     self.row_num = eqs.shape[0]
     self.picker_time = pd.DataFrame({
         'trigger_shift':
         np.array([
             eqs.iloc[i]['data'].trigger_shift for i in range(self.row_num)
         ])
     })
     self.picker_time.set_index(eqs.index, inplace=True)
     self.para = para
     self.log = setuplog()
     self.idx = 0
     self.init_figure(width=width, height=height, dpi=dpi)
     self.plot()
     self.drop_lst = []
     self.drop_color = 'lightgray'
Beispiel #10
0
 def __init__(self, cfg_file=None, log=None):
     if cfg_file is None:
         self.para = para()
     elif isinstance(cfg_file, str):
         self.para = CfgParser(cfg_file)
     else:
         raise TypeError('cfg should be \'str\' not \'{0}\''.format(
             type(cfg_file)))
     if not isinstance(self.para, para):
         raise TypeError('Input value should be class seispy.rf.para')
     if log is None:
         self.logger = setuplog()
     else:
         self.logger = log
     self.eq_lst = pd.DataFrame()
     self.eqs = pd.DataFrame()
     self.model = TauPyModel('iasp91')
     self.stainfo = stainfo()
Beispiel #11
0
 def __init__(self, cfg_file=None, log=None):
     if log is None:
         self.logger = setuplog()
     else:
         self.logger = log
     if cfg_file is None:
         self.para = para()
     elif isinstance(cfg_file, str):
         if not exists(cfg_file):
             self.logger.RFlog.error('No such file of {}.'.format(cfg_file))
             sys.exit(1)
         self.para = CfgParser(cfg_file)
     else:
         raise TypeError(
             'cfg should be in \'str\' format rather than \'{0}\''.format(
                 type(cfg_file)))
     if not isinstance(self.para, para):
         raise TypeError('Input value should be class seispy.rf.para')
     self.eq_lst = pd.DataFrame()
     self.eqs = pd.DataFrame()
     self.model = TauPyModel('iasp91')
     self.stainfo = stainfo()
     self.baz_shift = 0
Beispiel #12
0
    def __init__(self, cfg_file=None, log=None):
        """Class for 3-D CCP stacking, Usually used to study mantle transition zone structure.

        :param cfg_file: Path to configure file. If not defined a instance of CCP3D.cpara will be initialed, defaults to None
        :type cfg_file: str, optional
        :param log: A logger instance. If not defined, seispy.sutuplog.logger will be initialed, defaults to None
        :type log: seispy.sutuplog.logger , optional
        """
        if log is None:
            self.logger = setuplog()
        else:
            self.logger = log
        if cfg_file is None:
            self.cpara = CCPPara()
        elif isinstance(cfg_file, str):
            self.load_para(cfg_file)
        else:
            raise ValueError('cfg_file must be str format.')
        self.stack_data = []
        self.good_410_660 = np.array([])
        self.good_depth = np.array([])
        self.bin_loca = None
        self.bin_mat = None
        self.bin_map = None
Beispiel #13
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)