DL-FWI:数据(第二次培训作业)

代码:

import scipy.io
import matplotlib
import numpy as np
import matplotlib.pylab as plt
matplotlib.use('TkAgg')
from mpl_toolkits.axes_grid1 import make_axes_locatable
import cv2

font21 = {
        'family': 'Times New Roman',
        'weight': 'normal',
        'size': 21,
    }

font18 = {
        'family': 'Times New Roman',
        'weight': 'normal',
        'size': 18,
    }

def pain_seg_seismic_data(para_seismic_data):
    '''
    Plotting seismic data images of SEG salt datasets

    :param para_seismic_data:   Seismic data (400 x 301) (numpy)
    :param is_colorbar:         Whether to add a color bar (1 means add, 0 is the default, means don't add)
    '''

    fig, ax = plt.subplots(figsize=(6.2, 8), dpi = 120)

    im = ax.imshow(para_seismic_data, extent=[0, 300, 400, 0], cmap=plt.cm.seismic, vmin=-0.4, vmax=0.44)

    ax.set_xlabel('Position (km)', font21)
    ax.set_ylabel('Time (s)', font21)

    ax.set_xticks(np.linspace(0, 300, 5))
    ax.set_yticks(np.linspace(0, 400, 5))
    ax.set_xticklabels(labels = [0,0.75,1.5,2.25,3.0], size=21)
    ax.set_yticklabels(labels = [0.0,0.50,1.00,1.50,2.00], size=21)

    plt.rcParams['font.size'] = 14      # Set colorbar font size
    divider = make_axes_locatable(ax)
    cax = divider.append_axes("top", size="3%", pad=0.32)
    plt.colorbar(im, ax=ax, cax=cax, orientation='horizontal')

    plt.subplots_adjust(bottom=0.08, top=0.98, left=0.11, right=0.99)

    plt.show()


def pain_openfwi_seismic_data(para_seismic_data):
    '''

    Plotting seismic data images of openfwi dataset

    :param para_seismic_data:   Seismic data (1000 x 70) (numpy)
    '''
    data = cv2.resize(para_seismic_data, dsize=(400, 301), interpolation=cv2.INTER_CUBIC)

    fig, ax = plt.subplots(figsize=(6.1, 8), dpi = 120)
    im = ax.imshow(data, extent=[0, 0.7, 1.0, 0], cmap=plt.cm.seismic, vmin=-18, vmax=19)

    ax.set_xlabel('Position (km)', font21)
    ax.set_ylabel('Time (s)', font21)

    ax.set_xticks(np.linspace(0, 0.7, 5))
    ax.set_yticks(np.linspace(0, 1.0, 5))
    ax.set_xticklabels(labels=[0, 0.17, 0.35, 0.52, 0.7], size=21)
    ax.set_yticklabels(labels=[0, 0.25, 0.5, 0.75, 1.0], size=21)

    plt.rcParams['font.size'] = 14      # Set colorbar font size
    divider = make_axes_locatable(ax)
    cax = divider.append_axes("top", size="3%", pad=0.3)
    plt.colorbar(im, ax=ax, cax=cax, orientation='horizontal')
    plt.subplots_adjust(bottom=0.08, top=0.98, left=0.11, right=0.99)

    plt.show()

def pain_openfwi_velocity_model(para_velocity_model):
    '''
    Plotting seismic data images of openfwi dataset

    :param para_velocity_model: Velocity model (70 x 70) (numpy)
    :param min_velocity:        Upper limit of velocity in the velocity model
    :param max_velocity:        Lower limit of velocity in the velocity model
    :param is_colorbar:         Whether to add a color bar (1 means add, 0 is the default, means don't add)
    :return:
    '''

    fig, ax = plt.subplots(figsize=(5.8, 6), dpi=150)

    im = ax.imshow(para_velocity_model, extent=[0, 0.7, 0.7, 0])

    ax.set_xlabel('Position (km)', font18)
    ax.set_ylabel('Depth (km)', font18)
    ax.set_xticks(np.linspace(0, 0.7, 8))
    ax.set_yticks(np.linspace(0, 0.7, 8))
    ax.set_xticklabels(labels=[0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7], size=18)
    ax.set_yticklabels(labels=[0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7], size=18)

    plt.rcParams['font.size'] = 14      # Set colorbar font size
    divider = make_axes_locatable(ax)
    cax = divider.append_axes("top", size="3%", pad=0.35)
    plt.colorbar(im, ax=ax, cax=cax, orientation='horizontal')
    plt.subplots_adjust(bottom=0.10, top=0.95, left=0.13, right=0.95)

    plt.show()

def pain_seg_velocity_model(para_velocity_model):
    '''

    :param para_velocity_model: Velocity model (200 x 301) (numpy)
    :param min_velocity:        Upper limit of velocity in the velocity model
    :param max_velocity:        Lower limit of velocity in the velocity model
    :return:
    '''

    fig, ax = plt.subplots(figsize=(5.8, 4.3), dpi=150)
    im = ax.imshow(para_velocity_model, extent=[0, 3, 2, 0])

    ax.set_xlabel('Position (km)', font18)
    ax.set_ylabel('Depth (km)', font18)
    ax.tick_params(labelsize=14)

    plt.rcParams['font.size'] = 14  # Set colorbar font size
    divider = make_axes_locatable(ax)
    cax = divider.append_axes("top", size="3%", pad=0.32)
    plt.colorbar(im, ax=ax, cax=cax, orientation='horizontal')
    plt.subplots_adjust(bottom=0.12, top=0.95, left=0.11, right=0.99)

    plt.show()

if __name__ == '__main__':
    # SEG
    seismic_SEGReal = scipy.io.loadmat(r"C:\Users\86183\PycharmProjects\FWI\simple_data\seismic_SEGReal.mat")["data"]
    vmodel_SEGReal = scipy.io.loadmat(r"C:\Users\86183\PycharmProjects\FWI\simple_data\vmodel_SEGReal.mat")["data"]
    seismic_SEGSimulation = scipy.io.loadmat(r"C:\Users\86183\PycharmProjects\FWI\simple_data\seismicseismic_SEGSimulation.mat")["data"]
    vmodel_SEGSimulation = scipy.io.loadmat(r"C:\Users\86183\PycharmProjects\FWI\simple_data\vmodel_SEGSimulation.mat")["data"]

    # OpenFWI
    seismic_curvefaulta = np.load(r"C:\Users\86183\PycharmProjects\FWI\simple_data\seismic_openfwi_CurveFaultA.npy")
    vmodel_curvefaulta = np.load(r"C:\Users\86183\PycharmProjects\FWI\simple_data\vmodel_openfwi_CurveFaultA.npy")

    # SEG
    print(seismic_SEGReal.shape)
    print(vmodel_SEGReal.shape)
    print(seismic_SEGSimulation.shape)
    print(vmodel_SEGSimulation.shape)

    # OpenFWI
    print(seismic_curvefaulta.shape)
    print(vmodel_curvefaulta.shape)

    # show
    pain_seg_seismic_data(seismic_SEGReal[:,:,15])
    pain_seg_velocity_model(vmodel_SEGReal)
    pain_seg_seismic_data(seismic_SEGSimulation[:, :, 15])
    pain_seg_velocity_model(vmodel_SEGSimulation)

    pain_openfwi_seismic_data(seismic_curvefaulta[300,2,:,:])
    pain_openfwi_velocity_model(vmodel_curvefaulta[300,0,:,:])

    # show trace
    trace_id = 150

    fig,ax = plt.subplots(figsize = (6.0,5.0),dpi = 150)
    trace_curve = seismic_SEGSimulation[:, trace_id,15]
    im = ax.plot(trace_curve,label = "Middle trace")
    ax.set_xlabel("Time", font18)
    ax.set_ylabel("Amplitude",font18)
    plt.legend()
    plt.show()

结果:

DL-FWI:数据(第二次培训作业)_第1张图片 

 

DL-FWI:数据(第二次培训作业)_第2张图片

你可能感兴趣的:(python)