當前位置: 首頁>>代碼示例>>Python>>正文


Python Stream.merge方法代碼示例

本文整理匯總了Python中obspy.core.stream.Stream.merge方法的典型用法代碼示例。如果您正苦於以下問題:Python Stream.merge方法的具體用法?Python Stream.merge怎麽用?Python Stream.merge使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在obspy.core.stream.Stream的用法示例。


在下文中一共展示了Stream.merge方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: merger

# 需要導入模塊: from obspy.core.stream import Stream [as 別名]
# 或者: from obspy.core.stream.Stream import merge [as 別名]
def merger(noise_trace, st_events_poisson, samp_rate, delta):
    """ Merges the noise with the events """
    # Creates the stream with the noise and events
    newnoise_t_formerging = noise_trace.slice(0, (st_events_poisson[-1].stats.endtime)+100)
    seis = Stream()
    seis += newnoise_t_formerging
    seis += st_events_poisson
    figs = plt.figure(figsize=(14,5))
    seis.plot(fig = figs)
    figs.suptitle("Noise and events", fontsize = 12)
    ylab=figs.text(0.05, 0.5, 'Amplitude of signal', va='center', 
                rotation='vertical', fontsize=12)
    figs.text(0.5, 0, 'Timestamp', ha='center', fontsize=12)
    seis.merge()
    seis += st_events_poisson
    seis.merge(method = 1, interpolation_samples=-1)
    figs = plt.figure(figsize=(14,5))
    seis.plot(fig = figs)
    plt.title("Synthetic seismogram", fontsize = 12)
    ylab=figs.text(0.05, 0.5, 'Amplitude of signal', va='center', 
                rotation='vertical', fontsize=12)
    figs.text(0.5, 0, 'Timestamp', ha='center', fontsize=12)

    syn_seis = seis[0]
    syn_seis.stats.sampling_rate = samp_rate
    syn_seis.stats.delta = delta
    
    return syn_seis
開發者ID:rclement1,項目名稱:python,代碼行數:30,代碼來源:noisecodes.py

示例2: _read_filepattern

# 需要導入模塊: from obspy.core.stream import Stream [as 別名]
# 或者: from obspy.core.stream.Stream import merge [as 別名]
def _read_filepattern(fpattern, starttime, endtime, trim):
    """Read a stream from files whose names match a given pattern.
    """
    flist = glob.glob(fpattern)
    starttimes = []
    endtimes = []
    # first only read the header information
    for fname in flist:
        st = read(fname,headonly=True)
        starttimes.append(st[0].stats.starttime.datetime)
        endtimes.append(st[-1].stats.endtime.datetime)
    # now read the stream from the files that contain the period
    st = Stream()
    for ind,fname in enumerate(flist):
        if (starttimes[ind] < endtime) and (endtimes[ind] > starttime):
            if trim:
                st += read(fname,starttime=UTCDateTime(starttime),endtime=UTCDateTime(endtime))
            else:
                st += read(fname)
    try:
        st.merge()
    except:
        print "Error merging traces for requested period!"
        st = Stream()
    return st
開發者ID:miic-sw,項目名稱:miic,代碼行數:27,代碼來源:stream.py

示例3: getData

# 需要導入模塊: from obspy.core.stream import Stream [as 別名]
# 或者: from obspy.core.stream.Stream import merge [as 別名]
def getData(tstart, tend, opt):

    """
    Download data from files in a folder, from IRIS, or a Earthworm waveserver
    
    A note on SAC/miniSEED files: as this makes no assumptions about the naming scheme of
    your data files, please ensure that your headers contain the correct SCNL information!

    tstart: UTCDateTime of beginning of period of interest
    tend: UTCDateTime of end of period of interest
    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(',')
    
    st = Stream()
    
    if opt.server == 'SAC' or opt.server == 'miniSEED':
    
        # Generate list of files
        if opt.server == 'SAC':
            flist = list(itertools.chain.from_iterable(glob.iglob(os.path.join(
                root,'*.sac')) for root, dirs, files in os.walk(opt.sacdir)))+list(
                itertools.chain.from_iterable(glob.iglob(os.path.join(
                root,'*.SAC')) for root, dirs, files in os.walk(opt.sacdir)))
        elif opt.server == 'miniSEED':
            flist = list(itertools.chain.from_iterable(glob.iglob(os.path.join(
                root,'*.mseed')) for root, dirs, files in os.walk(opt.mseeddir)))+list(
                itertools.chain.from_iterable(glob.iglob(os.path.join(
                root,'*.MSEED')) for root, dirs, files in os.walk(opt.mseeddir)))
                
        # Determine which subset of files to load based on start and end times and
        # station name; we'll fully deal with stations below
        flist_sub = []
        for f in flist:
            # Load header only
            stmp = obspy.read(f, headonly=True)
            # Check if station is contained in the stas list
            if stmp[0].stats.station in stas:
                # Check if contains either start or end time
                ststart = stmp[0].stats.starttime
                stend = stmp[0].stats.endtime
                if (ststart<=tstart and tstart<=stend) or (ststart<=tend and
                    tend<=stend) or (tstart<=stend and ststart<=tend):
                    flist_sub.append(f)
        
        # Fully load data from file
        stmp = Stream()
        for f in flist_sub:
            tmp = obspy.read(f, starttime=tstart, endtime=tend+opt.maxdt)
            if len(tmp) > 0:
                stmp = stmp.extend(tmp)
    
        # Filter and merge
        stmp = stmp.filter('bandpass', freqmin=opt.fmin, freqmax=opt.fmax, corners=2,
            zerophase=True)
        stmp = stmp.taper(0.05,type='hann',max_length=opt.mintrig)
        for m in range(len(stmp)):
            if stmp[m].stats.sampling_rate != opt.samprate:
                stmp[m] = stmp[m].resample(opt.samprate)
        stmp = stmp.merge(method=1, fill_value=0)
        
        # Only grab stations/channels that we want and in order
        netlist = []
        stalist = []
        chalist = []
        loclist = []
        for s in stmp:
            stalist.append(s.stats.station)
            chalist.append(s.stats.channel)
            netlist.append(s.stats.network)
            loclist.append(s.stats.location)
            
        # Find match of SCNL in header or fill empty
        for n in range(len(stas)):
            for m in range(len(stalist)):
                if (stas[n] in stalist[m] and chas[n] in chalist[m] and nets[n] in
                    netlist[m] and locs[n] in loclist[m]):
                    st = st.append(stmp[m])
            if len(st) == n:
                print("Couldn't find "+stas[n]+'.'+chas[n]+'.'+nets[n]+'.'+locs[n])
                trtmp = Trace()
                trtmp.stats.sampling_rate = opt.samprate
                trtmp.stats.station = stas[n]
                st = st.append(trtmp.copy())
    
    else:   
     
        if '.' not in opt.server:
            client = Client(opt.server)
        else:
            client = EWClient(opt.server, opt.port)
        
        for n in range(len(stas)):
            try:
#.........這裏部分代碼省略.........
開發者ID:ahotovec,項目名稱:REDPy,代碼行數:103,代碼來源:trigger.py

示例4: _stream_dbread_view

# 需要導入模塊: from obspy.core.stream import Stream [as 別名]
# 或者: from obspy.core.stream.Stream import merge [as 別名]
                continue
            if (stations_ok) and (tr.stats.station not in stations):
                continue
            if (locations_ok) and (tr.stats.location not in locations):
                continue
            if (channels_ok) and (tr.stats.channel not in channels):
                continue
            st.append(tr)

    if st.count() > 0:
        # If the starttime is given then it trims the resulting traces
        if starttime:
            st.trim(starttime=starttime, endtime=endtime,
                    nearest_sample=nearest_sample)

        st.merge(method=1, fill_value=0, interpolation_samples=1)
    else:
        print "Empty stream"

    n_trace = st.count()
    return st, n_trace


if BC_UI:
    class _stream_dbread_view(HasTraits):
    
        time_interval = Float(30.0)
        networks = List(Str, value=['PF', 'YA'])
        stations = List(Str, value=['FOR', 'UV05'])
        locations = List(Str, value=['00', '10'])
        channels = List(Str, value=['HHZ', 'HLZ'])
開發者ID:ftilmann,項目名稱:miic,代碼行數:33,代碼來源:db.py


注:本文中的obspy.core.stream.Stream.merge方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。