예제 #1
0
subset = data_model.iloc[sel] ; txt = 'Synthetics_based_on_5_upholes'
fig, m_axs = plt.subplots(sample_rows,4,figsize=(13,6*sample_rows))
fig.subplots_adjust(wspace=0.45)
i=0

for (ax1,ax2,ax3,ax4), (_,files) in zip(m_axs, subset.iterrows()):
    print("file = ",files['shot'])
    input_data  =  ReadSegyio(segyfile=files['shot'],
                              keep_hdrs=[],drop_hdrs=[],
                              gather_id="FieldRecord",verbose=2)
    dt = input_data.sample_rate/1000
    # Extract numpy array with trace values and transpose so 
    # col=time and row=trace
    d = input_data.data["gather"][0].T
    # Apply simple processing: tpow gain to balance amplitudes upto time=maxt
    d = gains.tpow(d,dt,tpow=0.25,tmin=0,maxt=2)
    # 95th percentile gain to clip large outliers
    d = gains.perc(d,95)
    tmax = (input_data.n_samples-1)*dt
    d = gains.standardize(d)
    
    ax1.imshow(d,cmap='Greys',aspect='auto',extent=[0,DX*input_data.n_traces,
                                                    1000*dt*input_data.n_samples,0])
    if i==0: ax1.set_title('data')
    if i==len(subset)-1: ax1.set_xlabel('Offset (m)')
    ax1.set_ylabel('Time (ms)')

    # Convert shot gather to phase velocity vs. frequency panel
    fv_abs = np.squeeze(d_to_fv(d,dt=dt,side=1,f_abs=0).numpy())
    fvimg1 = ax2.imshow(fv_abs,cmap='jet',aspect='auto',extent=[0,FMAX,VMIN,VMAX],
                        vmin=-3,vmax=3)
예제 #2
0
def get_seismic_and_vpvs(data_file, model_file):
    """
    Used in training data loader to create input and two outputs
    Reads data and model SEGY from path strings and returns Tensorflow objects

    Model: SEGY file consisting of Vp, Vs and density. This functions extracts 
    only vp and vs and converts to float32 tensors
    
    Data: SEGY file. This function extract trace values and applies 
    pre-processing to balance amplitudes, low-cut filter. Then the shot gather
    is transformed from t-x to v-f (freq vs phase velocity)
    
    The phase velocity vs. frequency panel is resized to IMSZ[0] x IMSZ[1]
    Data augmentation is commented out. Perhaps data augmentation is best applied
    in the time domain

    Relies on global parameter IMSZ and boolean AUGMENT!

    Parameters:
    data_file           Full path to SEGY format seismic data
    model_filename      Full path to SEGY format model

    Output
    fv (input_1)        phase velocity (col) vs. frequency (row) panel (tf.float32)
    vp (vp_output)      1D array of velocity values (tf.float32)
    vs (vs_output)      1D array of velocity values (tf.float32)
    """

    # Process filenames
    # Convert to numpy and then convert bytestreams to ASCII
    data_file = data_file.numpy().decode('ASCII')
    model_file = model_file.numpy().decode('ASCII')

    # For debugging
    #print("data_file: {}, model_file: {}".format(data_file, model_file))

    # Read SEGY model file with SEGYIO
    model1d = ReadSegyio(segyfile=model_file,
                         keep_hdrs=[],
                         drop_hdrs=[],
                         gather_id="FieldRecord",
                         verbose=0)

    # Extract numpy array with trace values
    m = model1d.data["gather"][0].T

    # Extract Vs information
    vp = m[:IZMAX, 0]
    vs = m[:IZMAX, 1]

    # Convert to tensorflow Tensor dtype
    vp = tf.convert_to_tensor(vp)
    vs = tf.convert_to_tensor(vs)

    # Read SEGY data file with SEGYIO
    seismic = ReadSegyio(segyfile=data_file,
                         keep_hdrs=[],
                         drop_hdrs=[],
                         gather_id="FieldRecord",
                         verbose=0)
    dt = seismic.sample_rate / 1000
    # Extract numpy array with trace values and transpose so
    # col=time and row=trace
    d = seismic.data["gather"][0].T
    # Apply simple processing: tpow gain to balance amplitudes upto time=maxt
    d = gains.tpow(d, dt, tpow=0.25, tmin=0, maxt=2)
    # Apply a high-pass filter
    #d = np.apply_along_axis(lambda m: butter_highpass_filter(m,order=6,
    #                                                         lowcut=6,fs=1/dt),
    #                              axis=0, arr=d)
    # 95th percentile gain to clip large outliers
    d = gains.perc(d, 95)

    # Convert shot gather to phase velocity vs. frequency panel
    fv = d_to_fv(d, dt=dt, side=1)

    #if AUGMENT:
    #    # Randomly change amplitudes (bulk changes)
    # Careful: random_brightness changes the mean
    #    fv = tf.image.random_brightness(fv, 1,       seed=42)
    #    fv = tf.image.random_contrast(  fv, 0.75, 2, seed=42)

    # Resize image, avoid tf.image.resize
    # Bi-linear interpolation is fine, it preserve the amplitude ranges fairly
    # well if we turn off the antialias filter. More advanced schemes lessen
    # the dynamic range
    fv = tf.image.resize(fv, [IMSZ[0], IMSZ[1]],
                         method='bilinear',
                         antialias=False)

    # Force to specified dtypes to reduce memory requirements. Note that
    # tf.image.resize always outputs float32. These have to be consistent
    # with the dtypes specified in the Tout option in the tf.py_function during
    # loading with the parallel mapping function
    fv = tf.cast(fv, dtype=tf.float32)
    vp = tf.cast(vp, dtype=tf.float32)
    vs = tf.cast(vs, dtype=tf.float32)

    # Return dictionary so when can specify named input/output in the
    # Tensorflow model
    return ({"input_1": fv}, {"vp_output": vp, "vs_output": vs})
예제 #3
0
def get_seismic(data_file):
    """
    Used in data loader with seismic only (in case no velocity model is 
    available. Reads data SEGY file from path strings and returns Tensorflow 
    object

    Data: SEGY file. This function extract trace values and applies 
    pre-processing to balance amplitudes, low-cut filter. Then the shot gather
    is transformed from t-x to v-f (freq vs phase velocity)
    
    The phase velocity vs. frequency panel is resized to IMSZ[0] x IMSZ[1]

    Relies on global parameter IMSZ !

    Parameters:
    data_file           Full path to SEGY format seismic data

    Output
    fv                  phase velocity (col) vs. frequency (row) panel (tf.float32)
    """

    # Process filename
    # Convert to numpy and then convert bytestreams to ASCII
    data_file = data_file.numpy().decode('ASCII')

    # Read SEGY data file with SEGYIO
    seismic = ReadSegyio(segyfile=data_file,
                         keep_hdrs=[],
                         drop_hdrs=[],
                         gather_id="FieldRecord",
                         verbose=0)
    dt = seismic.sample_rate / 1000
    # Extract numpy array with trace values and transpose so
    # col=time and row=trace
    d = seismic.data["gather"][0].T
    # Apply simple processing: tpow gain to balance amplitudes upto time=maxt
    d = gains.tpow(d, seismic.sample_rate / 1000, tpow=0.25, tmin=0, maxt=2)
    # Apply a high-pass filter
    #d = np.apply_along_axis(lambda m: butter_highpass_filter(m,order=6,
    #                                                         lowcut=6,fs=1/dt),
    #                              axis=0, arr=d)
    # 95th percentile gain to clip large outliers
    d = gains.perc(d, 95)

    # Convert shot gather to phase velocity vs. frequency panel
    fv = d_to_fv(d, dt=dt, side=OFFSIDE)

    # Resize image, avoid tf.image.resize
    # Bi-linear interpolation is fine, it preserve the amplitude ranges fairly
    # well if we turn off the antialias filter. More advanced schemes lessen
    # the dynamic range
    fv = tf.image.resize(fv, [IMSZ[0], IMSZ[1]],
                         method='bilinear',
                         antialias=False)

    # Force to specified dtypes to reduce memory requirements. Note that
    # tf.image.resize always outputs float32. These have to be consistent
    # with the dtypes specified in the Tout option in the tf.py_function during
    # loading with the parallel mapping function
    fv = tf.cast(fv, dtype=tf.float32)

    return fv
예제 #4
0
    #for (ax1,ax2,ax3), (_,c_row) in zip(m_axs, model_1d.sample(sample_rows).iterrows()):
    #for (ax1,ax2,ax3), (_,c_row) in zip(m_axs, model_2b.sample(sample_rows).iterrows()):
    for (ax1, ax2, ax3), (_, c_row) in zip(m_axs, subset.iterrows()):
        input_data = ReadSegyio(segyfile=c_row['shot'],
                                keep_hdrs=[],
                                drop_hdrs=[],
                                gather_id="FieldRecord",
                                verbose=2)
        input_model = ReadSegyio(segyfile=c_row['model'],
                                 keep_hdrs=[],
                                 drop_hdrs=[],
                                 gather_id="FieldRecord",
                                 verbose=2)
        dt = input_data.sample_rate / 1000
        d = input_data.data["gather"][0].T
        d = gains.tpow(d, dt, tpow=0.25, tmin=0, maxt=2)
        d = gains.perc(d, 95)
        tmax = (input_data.n_samples - 1) * dt
        d = gains.standardize(d)

        fv = np.squeeze(d_to_fv(d, dt=dt, side=1).numpy())
        m = input_model.data["gather"][0].T
        vs1d = m[:IZMAX, 1]  # 0=Vp, 1=Vs, 2=rho
        vp1d = m[:IZMAX, 0]  # 0=Vp, 1=Vs, 2=rho

        ax1.imshow(d,
                   cmap='Greys',
                   aspect='auto',
                   extent=[
                       0, DX * input_data.n_traces,
                       1000 * dt * input_data.n_samples, 0