Notebook to plot vertical velocity and calculate maximum vertical velocity
%matplotlib inline
from matplotlib import pylab
import matplotlib.pyplot as plt
import netCDF4 as NC
import numpy as np
fT = NC.Dataset('../../Results/Oct18OneDay/SalishSea_1h_20021018_20021018_grid_T.nc','r')
depth = fT.variables['deptht'][:]
fW = NC.Dataset('../../Results/Oct18OneDay/SalishSea_1h_20021018_20021018_grid_W.nc','r')
wvel = fW.variables['vovecrtz'][:]
mw = wvel == 0
wvel_masked = np.ma.array(wvel,mask=mw)
level = 28
print 0.5*(depth[28]+depth[29])
plt.figure(figsize=(10,10))
plt.subplot(2,2,1)
plt.pcolormesh(wvel_masked[15,level,300:370,220:320])
plt.colorbar()
plt.subplot(2,2,2)
plt.pcolormesh(wvel_masked[2,level,300:370,220:320])
plt.colorbar()
plt.subplot(2,2,3)
plt.pcolormesh(wvel_masked[4,level,300:370,220:320])
plt.colorbar()
plt.subplot(2,2,4)
plt.pcolormesh(wvel_masked[21,level,300:370,220:320])
plt.colorbar()
160.101974487
<matplotlib.colorbar.Colorbar instance at 0x119f0fb00>
alpha = np.zeros(39)
for level in np.arange(1,39):
print level,depth[level],np.max(wvel_masked[:,level]), np.min(wvel_masked[:,level]),(depth[level+1]-depth[level-1])/2./np.max(wvel_masked[:,level]),(depth[level+1]-depth[level-1])/2./np.min(wvel_masked[:,level])
alpha[level] = np.maximum(-(depth[level]-depth[level-1])/np.min(wvel_masked[:,level]),(depth[level]-depth[level-1])/np.max(wvel_masked[:,level]))
1 1.5 0.00471525 -0.00359669 212.079047427 -278.034880468 2 2.50001 0.00866984 -0.00719076 115.344023229 -139.069197756 3 3.50003 0.012158 -0.0107793 82.2527582699 -92.7729467497 4 4.50007 0.0159827 -0.0143591 62.5712771679 -69.6463336202 5 5.50015 0.0196053 -0.017926 51.0128356921 -55.791536869 6 6.50031 0.0230062 -0.0214737 43.4768826702 -46.5796724767 7 7.50062 0.0261837 -0.0249923 38.2094166206 -40.0309116039 8 8.50124 0.0291442 -0.0284724 34.3432256488 -35.1535499247 9 9.50243 0.0318963 -0.0319047 31.4069376712 -31.3986242057 10 10.5048 0.0344541 -0.035288 29.1239169303 -28.4356927068 11 11.5093 0.0368307 -0.0386226 27.3331698135 -26.0650463623 12 12.5182 0.0395887 -0.0419114 25.5893837277 -24.1712443155 13 13.5354 0.0427842 -0.0451596 23.9669907707 -22.7063227422 14 14.569 0.0459757 -0.0483752 22.8259146466 -21.6937222159 15 15.6343 0.0491892 -0.0515875 22.2832655262 -21.2473231149 16 16.7612 0.0524764 -0.0548486 22.6086974547 -21.6308750013 17 18.0071 0.055937 -0.0582731 24.3185365069 -23.3436454155 18 19.4818 0.0597516 -0.061934 28.3075482015 -27.3100550986 19 21.39 0.0642415 -0.0662223 35.946157602 -34.870952869 20 24.1003 0.0699244 -0.0717383 48.90949631 -47.6728099888 21 28.2299 0.0773941 -0.0796327 68.386989103 -66.4645103294 22 34.6858 0.0831598 -0.0890384 97.9307531715 -91.4650708437 23 44.5177 0.0706445 -0.0718904 168.439029874 -165.519800509 24 58.4843 0.0764807 -0.0896082 209.646704567 -178.933829905 25 76.5856 0.085657 -0.116157 231.029674106 -170.367042778 26 98.063 0.0940833 -0.13498 240.642791589 -167.732559798 27 121.867 0.108585 -0.159962 225.751426165 -153.244023735 28 147.089 0.140678 -0.177126 182.145870791 -144.664939142 29 173.114 0.160411 -0.167646 163.591332484 -156.530504154 30 199.573 0.161938 -0.148313 164.09301586 -179.167802961 31 226.26 0.143556 -0.146928 186.315899983 -182.039584179 32 253.067 0.148642 -0.16638 180.549113284 -161.30013916 33 279.935 0.136009 -0.163072 197.661425247 -164.858589631 34 306.834 0.115402 -0.116108 233.165919115 -231.748972083 35 333.75 0.0704 -0.0724132 382.38852154 -371.757687103 36 360.675 0.0275815 -0.0264799 976.251115347 -1016.86521353 37 387.603 0.00932059 -0.00657163 2889.27989902 -4097.8856887 38 414.534 0.00491386 -0.00436518 5480.70493167 -6169.60482006
plt.plot(np.log(alpha[1:39]))
plt.title("Log dz/w")
plt.xlabel("Vertical Level")
print np.min(alpha[1:39])
21.4741249084