Compare FWI result with true model for the Overthrust model

Daniel Köhn Kiel, 16/07/2016

Import Libraries


In [ ]:
import matplotlib.pyplot as plt
import matplotlib as mpl
import numpy as np
from matplotlib.colors import LightSource, Normalize
from matplotlib.pyplot import gca
from pylab import rcParams
from matplotlib import rc
from matplotlib.ticker import FormatStrFormatter
from mpl_toolkits.axes_grid1 import make_axes_locatable
import pickle

Import Colormap


In [ ]:
fp = open('cmap_overthrust.pkl', 'rb')
my_cmap_cm = pickle.load(fp)
fp.close()

FD grid dimensions


In [ ]:
DH = 25.0;
NX = 800;
NY = 186;

Wavefield clip value


In [ ]:
vpmin = 2360.0;
vpmax = 6000.0;

Define fonts


In [ ]:
FSize = 20
font = {'color':  'black',
        'weight': 'normal',
        'size': FSize}
mpl.rc('xtick', labelsize=FSize) 
mpl.rc('ytick', labelsize=FSize) 
rcParams['figure.figsize'] = 16, 8

Read FWI result and true model


In [ ]:
f = open("../start/overthrust_true.vp")
data_type = np.dtype ('float32').newbyteorder ('<')
mod_true = np.fromfile (f, dtype=data_type)
mod_true = mod_true.reshape(NX,NY)
mod_true = np.transpose(mod_true)
mod_true = np.flipud(mod_true)

In [ ]:
f = open("29_09_2016_lbfgs_app_Hessian/modelTest_vp_stage_8.bin")
#f = open("../start/overthrust_start_smooth2.vp")
data_type = np.dtype ('float32').newbyteorder ('<')
mod_fwi = np.fromfile (f, dtype=data_type)
mod_fwi = mod_fwi.reshape(NX,NY)
mod_fwi = np.transpose(mod_fwi)
mod_fwi = np.flipud(mod_fwi)

Define Axis


In [ ]:
x = np.arange(0.0, DH*NX, DH)
y = np.arange(0.0, DH*NY, DH)
x = np.divide(x,1000.0);
y = np.divide(y,1000.0);

Define SubPlot


In [ ]:
def do_plot(n, model, cm, an, title, vpmin, vpmax):
    
    ax=plt.subplot(2, 1, n)
    ax.set_xticks([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20])
    ax.set_yticks([1, 2, 3, 4, 5])
    
    #plt.rc('font',**{'family':'sans-serif','sans-serif':['Helvetica']})
    rc('font',**{'family':'sans-serif','sans-serif':['Helvetica']})
    ## for Palatino and other serif fonts use:
    #rc('font',**{'family':'serif','serif':['Palatino']})
    #plt.rc('text', usetex=True)
    rc('text', usetex=True)
    
    # plt.pcolor(x, y, vp, cmap=cm, vmin=vpmin)
    im1 = plt.imshow(model, cmap=cm, interpolation='none', extent=[0.0,NX*DH/1000.0,0.0,NY*DH/1000.0], vmin=vpmin, vmax=vpmax)
    a = gca()
    a.set_xticklabels(a.get_xticks(), font)
    a.set_yticklabels(a.get_yticks(), font)
    plt.axis('scaled')
    plt.title(title, fontdict=font)
    plt.ylabel('Depth [km]', fontdict=font)
    if n==2:
        plt.xlabel('Distance [km]', fontdict=font)
    plt.gca().invert_yaxis()
    
    # add annotation
    plt.text(0.1, 0.4,an,fontdict=font,color='white')
    
    # fit and label colorbar
    divider = make_axes_locatable(ax)
    cax = divider.append_axes("right", size="2.5%", pad=0.05)
    cbar = plt.colorbar(im1, cax=cax)
    cbar.set_label(r"Vp [m/s]", fontdict=font, labelpad=1)

Plot SubPlots


In [ ]:
plt.close('all')
plt.figure()
do_plot(1, mod_fwi, 'gray_r', '(a)', r"FWI result (f = 20.6 Hz)", vpmin, vpmax)
#do_plot(1, mod_fwi, 'gray_r', '(a)', r"Initial model", vpmin, vpmax)
do_plot(2, mod_true, 'gray_r', '(b)', r"True Overthrust model", vpmin, vpmax)
#plt.savefig('test.png', format='png', dpi=100)
plt.savefig('test.pdf', bbox_inches='tight', format='pdf')
plt.tight_layout()
plt.show()

In [ ]: