Results from this notebook:
Caveats regarding this notebook:
Hopes for the use of this notebook:
This iPython notebook was originally developed at NOAA/GFDL, and it is provided freely to the MOM6 community. GFDL scientists developing MOM6 make extensive use of Python for diagnostics. We solicit modifications/fixes that are useful to the MOM6 community.
In [2]:
import matplotlib.pyplot as plt # For plotting
import netCDF4 # For reading data
pylab.rcParams['figure.figsize'] = (17.0, 10.0) # Large figures
path = '../single_column_z/'
deltaz = 'CM4'
fname_deltaz = '_CM4'
expt_name = 'single_column_z'
dpi=200
In [3]:
visc = netCDF4.Dataset(path+'visc.nc')
for v in visc.variables: print v,
# recall data layout is (t,z,y,x)
time = visc.variables['Time'][:]
# KPP boundary layer depth as function of time (metre)
h = visc.variables['KPP_OBLdepth'][:,0,0]
# KPP tracer diffusivity as function of time and depth (m2/sec)
Kt = visc.variables['KPP_Kheat'][:,:,0,0]
# KPP velocity diffusivity as function of time and depth (m2/sec)
Ku = visc.variables['KPP_Kv'][:,:,0,0]
# surface (and penetrating) buoyancy flux, as used by [CVmix] KPP (m2/s3)
KPP_buoyFlux = visc.variables['KPP_buoyFlux'][:,:,0,0]
# Temperature tendency due to non-local transport of heat, as calculated by KPP (K/s)
KPP_dTdt = visc.variables['KPP_dTdt'][:,:,0,0]
# Saln tendency due to non-local transport of heat, as calculated by KPP (ppt/s)
KPP_dSdt = visc.variables['KPP_dSdt'][:,:,0,0]
# friction velocity used by KPP (m/s)
KPP_uStar = visc.variables['KPP_uStar'][:,0,0]
# Squared buoyancy frequency (1/s^2)
KPP_N2 = visc.variables['KPP_N2'][:,:,0,0]
In [4]:
prog = netCDF4.Dataset(path+'prog.nc')
for v in prog.variables: print v,
# depth of cell interface
zi = prog.variables['zi'][:]
# depth of cell center
zl = prog.variables['zl'][:]
# zonal velocity as function of time and depth
u = prog.variables['u'][:,:,0,0]
# zonal velocity as function of time and depth
v = prog.variables['v'][:,:,0,0]
# temperature as function of time and depth
temp = prog.variables['temp'][:,:,0,0]
# saln as function of time and depth
saln = prog.variables['salt'][:,:,0,0]
In [5]:
# thickness of cells
dz = zi[1:]-zi[:-1]
field = zi[1:]+dz[:]
#depth = np.ma.masked_array(data, mask=[data>400.])
depth = field
#print dz
#print dz[1901:2000]
print zi
figure(1)
fig, ax = plt.subplots(figsize=(16, 10), dpi=dpi)
S = plt.plot(dz,-depth,'*',linewidth=3)
plt.ylim((-400,0))
plt.xlim((0, 50))
yticks = [-400, -350, -300, -250, -200, -150, -100, -50, 0]
ax.set_yticks(yticks)
#xticks = [0, .1, .2, .3, .4, .5]
#xticks = [0, .2, .4, .6, .8, 1.0, 1.2]
#xticks = [0, 20, 40, 60, 80, 100, 120, 140, 160, 180, 200, 220, 240, 260]
xticks = [0, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50]
ax.set_xticks(xticks)
#plt.xlim((0, 40)
ax.set_xticks(xticks)
plt.grid()
plt.xlabel('Delta z (m)',fontsize=18)
plt.ylabel('depth (m)',fontsize=18)
plt.title(r'$\Delta z$ for configuration '+deltaz,fontsize=20)
ax.set_yticklabels(["$%.1f$" % y for y in yticks], fontsize=18)
ax.set_xticklabels(["$%.1f$" % x for x in xticks], fontsize=18);
In [6]:
# KPP related fields
plt.subplot(2,2,1)
data = KPP_buoyFlux
field = np.ma.masked_array(data, mask=[data==0.])
plt.contourf(time, -zi, field.T, 16, levels=numpy.arange(-2e-7, 2e-7, 1e-8))
CS = plt.plot(time, -h,'r-',linewidth=1)
plt.colorbar()
plt.xlim((0, 370))
plt.ylim((-30,0))
plt.ylabel(r'z(m) with $\Delta z$ ='+deltaz,fontsize=14)
plt.title(r'Upper ocn buoy flux $(m^2/s^3)$ for '+expt_name,fontsize=18)
#plt.xlabel('Time (days)',fontsize=14)
plt.subplot(2,2,2)
data = log10(sqrt(KPP_N2))
field = np.ma.masked_array(data, mask=[data==0.])
plt.contourf(time, -zi, field.T, 16, levels=numpy.arange(-5,-1,.25))
#plt.contourf(time, -zi, field.T, 16)
CS = plt.plot(time, -h,'r-',linewidth=1)
plt.colorbar()
plt.xlim((0, 370))
plt.ylim((-300,0))
plt.ylabel(r'z(m) with $\Delta z$ ='+deltaz,fontsize=14)
plt.title(r'$Log_{10}(N)$ $(1/s)$ for '+expt_name,fontsize=18)
plt.xlabel('Time (days)',fontsize=14)
plt.subplot(2,2,3)
data = KPP_buoyFlux[:,0]
CS = plt.plot(time,data,'*',linewidth=3)
plt.xlim((0, 370))
plt.xlim((0, 370))
plt.grid()
plt.title(r'Surface buoyancy flux for '+expt_name,fontsize=18)
plt.xlabel('Time (days)',fontsize=14)
plt.ylabel(r'Buoyancy flux $(m^2/s^3)$',fontsize=14)
plt.subplot(2,2,4)
CS = plt.plot(time,KPP_uStar,'*',linewidth=3)
#plt.ylim((-400,0))
plt.xlim((0, 370))
plt.grid()
plt.xlabel('Time (days)',fontsize=14)
plt.ylabel(r'$u^{*}$ (m/s))',fontsize=14)
plt.title(r'$u^{*}$ used in KPP for '+expt_name,fontsize=18)
#ax.set_yticklabels(["$%.1f$" % y for y in yticks], fontsize=18)
#ax.set_xticklabels(["$%.1f$" % x for x in xticks], fontsize=18);
In [7]:
# KPP related fields
plt.subplot(2,2,1)
data = Kt
field = np.ma.masked_array(data, mask=[data==0.])
plt.contourf(time, -zi, field.T, levels=numpy.arange(0,.5,.05))
plt.colorbar()
plt.ylim((-300,0))
plt.xlim((0, 370))
plt.ylabel(r'z(m) with $\Delta z$ ='+deltaz,fontsize=14)
plt.title(r'$\kappa_{\Theta} (m^2/s)$ for '+expt_name,fontsize=18)
plt.subplot(2,2,2)
data = Ku
field = np.ma.masked_array(data, mask=[data==0.])
plt.contourf(time, -zi, field.T, levels=numpy.arange(0,.5,.05))
plt.colorbar()
plt.xlim((0, 370))
plt.ylim((-300,0))
plt.ylabel(r'z(m) with $\Delta z$ ='+deltaz,fontsize=14)
plt.title(r'$\kappa_u (m^2/s)$ for '+expt_name,fontsize=18)
plt.subplot(2,2,3)
data = KPP_dTdt
field = np.ma.masked_array(data, mask=[data==0.])
plt.contourf(time, -zl, field.T, 16)
CS = plt.plot(time, -h,'r-',linewidth=1)
plt.colorbar()
plt.xlim((0, 370))
plt.ylim((-300,0))
plt.ylabel(r'z(m) with $\Delta z$ ='+deltaz,fontsize=14)
plt.title(r'Non-local $\Theta$ tendency $(K/s)$ for '+expt_name,fontsize=18)
plt.xlabel('Time (days)',fontsize=14)
plt.subplot(2,2,4)
data = KPP_dSdt
field = np.ma.masked_array(data, mask=[data==0.])
plt.contourf(time, -zl, field.T, 16)
CS = plt.plot(time, -h,'r-',linewidth=1)
plt.colorbar()
plt.xlim((0, 370))
plt.ylim((-300,0))
plt.ylabel(r'z(m) with $\Delta z$ ='+deltaz,fontsize=14)
plt.title(r'Non-local Saln tendency $(ppt/s)$ for '+expt_name,fontsize=18)
plt.xlabel('Time (days)',fontsize=14)
Out[7]:
In [8]:
# Boundary layer depth and SST
figure(4)
fig, ax = plt.subplots(figsize=(16, 10), dpi=dpi)
CS = plt.plot(time, -h,'-',linewidth=3)
plt.grid()
plt.xlabel('Time (days)',fontsize=18)
plt.ylabel(r'z(m) with $\Delta z$ ='+deltaz,fontsize=18)
plt.title(r'KPP boundary layer depth for '+expt_name,fontsize=18)
plt.xlim((0, 400))
xticks = [0, 50, 100, 150, 200, 250, 300, 350, 400]
ax.set_xticklabels(["$%.1f$" % x for x in xticks], fontsize=18);
plt.ylim((-300, 0))
yticks = [-300, -250, -200, -150, -100, -50, 0]
ax.set_yticklabels(["$%.1f$" % y for y in yticks], fontsize=18)
figure(5)
fig, ax = plt.subplots(figsize=(16, 10), dpi=dpi)
CS = plt.plot(time, temp[:,0],'-',linewidth=3)
plt.grid()
plt.xlabel('Time (days)',fontsize=18)
plt.ylabel('SST(C)',fontsize=18)
plt.title(r'SST for '+expt_name,fontsize=18)
plt.xlim((0, 400))
xticks = [0, 50, 100, 150, 200, 250, 300, 350, 400]
ax.set_xticklabels(["$%.1f$" % x for x in xticks], fontsize=18);
plt.ylim((18, 28))
yticks = [18, 20, 22, 24, 26, 28]
ax.set_yticklabels(["$%.1f$" % y for y in yticks], fontsize=18)
Out[8]:
In [9]:
# u,v,temp
plt.subplot(2,2,1)
data = u
field = np.ma.masked_array(data, mask=[data==0.])
plt.contourf(time, -zl, field.T, levels=numpy.arange(-.10,.11,.01))
plt.colorbar()
plt.ylim((-100,0))
plt.ylabel('z (m)',fontsize=14)
plt.title('u (m/s) for expt = '+expt_name,fontsize=16)
plt.subplot(2,2,2)
data = v
field = np.ma.masked_array(data, mask=[data==0.])
plt.contourf(time, -zl, field.T, levels=numpy.arange(-.10,.11,.01))
plt.colorbar()
plt.ylim((-100,0))
plt.ylabel('z (m)',fontsize=14)
plt.title('v (m/s) for expt = '+expt_name,fontsize=16)
plt.subplot(2,2,3)
data = temp
field = np.ma.masked_array(data, mask=[data==0.])
CS = plt.contourf(time, -zl, field.T,levels=numpy.arange(18,30,1))
plt.colorbar()
#C = plt.contour(time, -zl, temp.T, 8,linewidth=.5, colors='black')
#plt.clabel(C, inline=1, fontsize=10)
plt.ylim((-100,0))
plt.ylabel('z (m)',fontsize=14)
plt.title(r'$\Theta$ ($\degree$C) for expt = '+expt_name,fontsize=16)
plt.xlabel('Time (days)',fontsize=14);
plt.subplot(2,2,4)
data = saln[:,:]
field = np.ma.masked_array(data, mask=[data==0.])
CS = plt.contourf(time, -zl, field.T,levels=numpy.arange(36.3,37,.01))
#CS = plt.contourf(time, -zl, field.T)
plt.colorbar()
plt.ylim((-100,0))
plt.ylabel('z (m)',fontsize=14)
plt.title(r'$S$ ($ppt$) for expt = '+expt_name,fontsize=16);
plt.xlabel('Time (days)',fontsize=14);
In [9]:
In [9]:
In [1]:
In [1]:
In [1]:
In [1]:
In [ ]: