コード例 #1
0
def trace_cwt_samp(trace, dt, freq_index, tw, tinc, ws=None):
    '''
    trace sampling. v2.0
    
    trace: the trace data
    freq_index: the index of frequencies
        for example, [26,27,29,31,33,35,37,40,44,48,53,59,66,76,89]
    
    tw: time window, the window step equals to the time window
    ws: window steps
    
    for example:
        tt = trace_cwt_samp(obs, dt, freq_index, tw, dt)
    '''
    nt = trace.shape[0]  # the number of time records of the trace
    if ws == None: ws = tw
    wn = int((nt - tw) / ws + 1)
    samps = np.zeros((wn, len(freq_index), int(tw / tinc)))

    cwtmatr, freqs = tf.spectrum_cwt(np.arange(nt) * dt * 1000,
                                     trace,
                                     colorscale=0.5,
                                     wavelet='morl',
                                     widths=100,
                                     freqmax=100,
                                     plot=False)

    for i in np.arange(wn) * ws:
        win0 = cwtmatr[freq_index, :]
        #[20,19.4,18,17,16,15,14.2,13.2,12,11,10,9,8,7,6]
        win = win0[:, np.arange(i, i + tw, tinc)]
        samps[int(i / ws), :, :] = win

    return samps
コード例 #2
0
dt = 0.002
nt = s1.shape[0]

fig, ax = f.seisplot_wig(s1, lw=0.8)
ax.set_yticks(np.arange(0, nt + 1, 50))
ax.set_yticklabels(np.arange(0, nt + 1, 50) * dt)
#fig.savefig('fig/micro.pdf', dpi=200)

t = np.arange(400) * dt * 1000
cwtmatr, freqs = tf.spectrum_cwt(t,
                                 s1[:, 13],
                                 wavelet='morl',
                                 widths=200,
                                 cmap='RdBu',
                                 colorscale=1,
                                 contour_dvision=41,
                                 freqmax=100,
                                 figsize=(12, 3),
                                 plot=True,
                                 ymin=5,
                                 ymax=80)

s1fb = f.fb_pick_gather_wholetrace(s1, fb_tr_step=1, method='kmeans', w=5, c=2)

fig, ax = f.seisplot_wig(s1, lw=0.8)
ax.scatter(s1fb[:, 0],
           s1fb[:, 1],
           s=50,
           facecolors='none',
           edgecolors='r',
           lw=2)
コード例 #3
0
Obs = Obso + np.random.randn(Obso.shape[0], Obso.shape[1]) * 0.04

ssnr = f.snrz(Obso, Obs)
print('The signal to noise ratio is:', ssnr)

nt = Obs.shape[0]  # the number of time records of a trace
dt = 0.0015  # time interval

t = np.arange(nt) * dt * 1000
cwtmatr, freqs = tf.spectrum_cwt(
    t,
    Obs[:, 260],
    wavelet='morl',  #'mexh''morl'
    widths=100,
    cmap='RdBu',
    colorscale=1,
    contour_dvision=41,
    freqmax=200,
    figsize=(12, 3),
    plot=True,
    ymin=5,
    ymax=30)

tw = 50  # time window size
ts = tw  # time window steps
freq_index = [26, 27, 29, 31, 33, 35, 37, 40, 44, 48, 53, 59, 66, 76, 89]
freq = freqs[freq_index, ]

ncols = 6
nrows = int(nt / tw / ncols)