Plot GERMAINE FDFD data
Daniel Köhn Kiel, 07/08/2017
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
FDFD data dimensions
In [ ]:
NSRC = 144 # number of sources
NF = 6 # number of frequencies
NREC = 660 # number of receivers
#clip = 2.5e-1 # clip GERMAINE
clip = 2e2 # clip TOY2DAC
Define fonts
In [ ]:
FSize = 14
font = {'color': 'black',
'weight': 'normal',
'size': FSize}
mpl.rc('xtick', labelsize=FSize)
mpl.rc('ytick', labelsize=FSize)
rcParams['figure.figsize'] = 17, 12
Read FDFD data
In [ ]:
name_FDFD = "../seis/marmousi_true/marmousi_p_stage_1.bin"
f = open (name_FDFD)
data_type = np.dtype ('float32').newbyteorder ('<')
data_FDFD = np.fromfile(f, dtype=data_type)
data_FDFD = data_FDFD.reshape(NF*NSRC,2*NREC)
data_FDFD = np.transpose(data_FDFD)
data_FDFD = np.flipud(data_FDFD)
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, title, vpmin, vpmax):
ax=plt.subplot(2, 3, n)
#ax.set_xticks([1, 2, 3, 4, 5, 6, 7, 8, 9, 10])
#ax.set_yticks([0.5, 1, 1.5, 2, 2.5, 3, 3.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)
NSRC1 = 0 + (n-1) * NSRC
NSRC2 = NSRC - 1 + (n-1) * NSRC
plt.imshow(model[0:2*NREC-1:2,NSRC1:NSRC2], cmap=cm, interpolation='none', extent=[1,NSRC,1,NREC], vmin=vpmin, vmax=vpmax, aspect=0.25)
a = gca()
#a.set_xticklabels(a.get_xticks(), font)
#a.set_yticklabels(a.get_yticks(), font)
#plt.axis('scaled')
if(n==1 or n==4):
plt.ylabel('Receiver no.', fontdict=font)
if(n>=4):
plt.xlabel('Source no.', fontdict=font)
plt.title(title, fontdict=font)
plt.gca().invert_yaxis()
# cbar=plt.colorbar(aspect=8, pad=0.02)
# cbar.set_label(title, fontdict=font, labelpad=10)
# plt.text(0.1, 0.4,an,fontdict=font,color='white')
Plot SubPlots
In [ ]:
plt.close('all')
plt.figure()
do_plot(1, data_FDFD, 'seismic', '3 Hz', -clip, clip)
do_plot(2, data_FDFD, 'seismic', '4 Hz', -clip, clip)
do_plot(3, data_FDFD, 'seismic', '5 Hz', -clip, clip)
do_plot(4, data_FDFD, 'seismic', '6 Hz', -clip, clip)
do_plot(5, data_FDFD, 'seismic', '7 Hz', -clip, clip)
do_plot(6, data_FDFD, 'seismic', '8 Hz', -clip, clip)
plt.tight_layout()
plt.savefig('test.pdf', bbox_inches='tight', format='pdf')
#plt.savefig('test.png', bbox_inches='tight', format='png')
plt.show()