Notebook to look at one day of Data from Kao-Shen...
%matplotlib inline
import matplotlib.pyplot as plt
import netCDF4 as NC
import numpy as np
from salishsea_tools import tidetools
date = 'Sep 10, 2014'
time = 0
resultsloc = '/data/dlatorne/MEOPAR/SalishSea/results/gem-res-10sep14/'
name = 'SalishSea_1h_20140910_20140910_grid_'
filename = resultsloc+name+'V.nc'
fU = NC.Dataset(resultsloc+name+'U.nc')
fV = NC.Dataset(filename,'r')
print fV.variables['v_wind_stress']
windU = fU.variables['u_wind_stress'][:]
windV = fV.variables['v_wind_stress'][:]
<type 'netCDF4.Variable'> float32 v_wind_stress(time_counter, y, x) units: N/m2 standard_name: Wind Stress along j-axis _FillValue: 9.96921e+36 long_name: Wind Stress along j-axis online_operation: ave(X) interval_operation: 10.0 interval_write: 3600.0 coordinates: time_counter nav_lat nav_lon unlimited dimensions: time_counter current shape = (24, 898, 398) filling on
#grid
bathy, X, Y = tidetools.get_SS_bathy_data()
#Latitude: 49.1059. Longitude: -123.3033.
i,j = tidetools.find_closest_model_point(-123.3033,49.1059,X,Y,bathy)
print X[i,j],Y[i,j]
print tidetools.find_closest_model_point(-123-18/60.,49+29./60,X,Y,bathy)
-123.307228088 49.1056976318 (501, 340)
print i,j
428 292
fig, ax = plt.subplots(1,1,figsize=(5,5))
ax.plot(windU[:,i,j],windV[:,i,j])
ax.set_xlim((-0.3,0.05))
ax.set_ylim((-0.2,0.15))
k=14
ax.plot(windU[k,i,j],windV[k,i,j],'o')
print windU[k,i,j],windV[k,i,j]
raw = np.arctan2(windV[k,i,j],windU[k,i,j])*180./(np.pi)
print raw,360-raw+90-29
print np.sqrt(np.sqrt(windU[:,i,j]**2+windV[:,i,j]**2)/2.)*3.6
-0.250865 0.0972174 158.817225147 262.182774853 [ 0.23229708 0.27938715 0.29106802 0.28930068 0.28722027 0.27554178 0.19501147 0.22295611 0.28819403 0.3458221 0.39657277 0.48651183 0.78410727 1.18766797 1.32038009 1.34503174 1.21021926 1.08382142 0.96192819 0.80306321 0.67555678 0.53652459 0.42451215 0.3287825 ]
# 1400 UTC = 0600 PST = 0700 PDT
# during this time Sandheads winds are direction 27 which is from the West
print 0.002*1.2*(10/3.6)**2
#dir=np.array([17,16,18,15,12,12,9,9,11,9,13,10,23,7,26,27,29,28,30,28])
#mag = np.array([13,15,15,12,13,11,10,15,13,9,8,10,7,5,6,4,6,9,11,10])/3.6
dir=np.array([36,34,36,33,35,31,35,33,4,5])
mag = np.array([14,11,13,2,11,6,9,10,43,44])/3.6
stress = 0.002*1.2*mag**2
vs = stress*np.cos((dir*10+29)/180.*np.pi)
us = stress*np.sin((dir*10+29)/180.*np.pi)
fig, ax = plt.subplots(1,1,figsize=(5,5))
ax.plot(-us,-vs)
ax.plot(0.,0.,'o')
ax.plot(windU[:,i,j],windV[:,i,j])
ax.set_xlim((-0.5,0.05))
ax.set_ylim((-0.4,0.15))
print dir*10-29
0.0185185185185 [331 311 331 301 321 281 321 301 11 21]
w=11
print w*w*1.2*0.002
0.2904