Compare FWI result with true model for 2 Inclusion model
Daniel Köhn Kiel, 03/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
import pickle
Import Colormap
FD grid dimensions
In [ ]:
DH = 40.0;
NX = 250;
NY = 125;
Wavefield clip value
In [ ]:
vpmin = 2500.0;
vpmax = 4500.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'] = 12.5, 11
Read FWI result and true model
In [ ]:
f = open("../start/inclusions_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("../model/modelTest_vp_stage_8.bin")
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])
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)
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()
cbar=plt.colorbar(aspect=10,pad=0.03)
cbar.set_label(r"Vp [m/s]" , fontdict=font, labelpad=10)
plt.text(0.1, 0.5,an,fontdict=font,color='black')
plt.tight_layout()
Plot SubPlots
In [ ]:
plt.close('all')
plt.figure()
do_plot(1, mod_fwi, 'magma', '(a)', r"FWI result", vpmin, vpmax)
do_plot(2, mod_true, 'magma', '(b)', r"True 2 inclusion model", vpmin, vpmax)
#plt.savefig('test.png', format='png', dpi=100)
#plt.savefig('test.pdf', format='pdf')
plt.show()
In [ ]: