%matplotlib inline
import matplotlib.pyplot as plt
import netCDF4 as NC
import numpy as np
data = NC.Dataset('../../Operational/ops_y2012m12d13.nc')
precip = data.variables['precip'][:]
lat = data.variables['nav_lat'][:]
lon = data.variables['nav_lon'][:]
print precip.shape
(24, 266, 256)
# wanted 49.11'42'' and 123 10 55
latwant = 49+(11+42/60.)/60.
lonwant = 123+(10+55/60.)/60.
print latwant, lonwant
49.195 123.181944444
x,y = np.zeros((100)), np.zeros((100))
print x.shape
x[0]=100; y[0]=100
x[1]=150; y[1]=100
x[2]=150; y[2]=200
x[3]=150; y[3]=150
x[4]=120; y[4]=150
x[5]=140; y[5]=150
x[6]=140; y[6]=160
x[7]=140; y[7]=155
x[8]=139; y[8]=155
x[9]=139; y[9]=156
for i in range(10):
print x[i],y[i],lat[x[i],y[i]],lon[x[i],y[i]]-360.
(100,) 100.0 100.0 48.161 -124.687088013 150.0 100.0 49.1933 -125.015151978 150.0 200.0 49.5766 -121.812637329 150.0 150.0 49.3994 -123.422134399 120.0 150.0 48.7751 -123.248291016 140.0 150.0 49.1911 -123.363540649 140.0 160.0 49.2286 -123.044616699 140.0 155.0 49.21 -123.204147339 139.0 155.0 49.1891 -123.198410034 139.0 156.0 49.1929 -123.166534424
plt.plot(precip[:,x[9],y[9]])
[<matplotlib.lines.Line2D at 0x7f223f80cc10>]
p = np.zeros(31)
p[13]= precip[:,x[9],y[9]].sum()
data14 = NC.Dataset('../../Operational/ops_y2012m12d14.nc')
precip14 = data14.variables['precip'][:]
p[14]= precip14[:,x[9],y[9]].sum()
data14.close()
data15 = NC.Dataset('../../Operational/ops_y2012m12d15.nc')
precip15 = data15.variables['precip'][:]
p[15]= precip15[:,x[9],y[9]].sum()
data15.close()
data16 = NC.Dataset('../../Operational/ops_y2012m12d16.nc')
precip16 = data16.variables['precip'][:]
p[16] =precip16[:,x[9],y[9]].sum()
data16.close()
data17 = NC.Dataset('../../Operational/ops_y2012m12d17.nc')
precip17 = data17.variables['precip'][:]
p[17] =precip17[:,x[9],y[9]].sum()
data17.close()
o=np.zeros(31)
o[13]=17.6; o[14]=4.4; o[15]=12.6; o[16]=13.0; o[17]=11.8 # YVR rain
o = o/86400. #mm per second
o = o/1000. #m per second
o = o*1000. # kg/m2/s
w=np.zeros(31)
w[13]=20.8 # West Van AUT rain
w = w/86400.
p=p/24.
plt.plot(p,'o',o,'x',w,'+')
[<matplotlib.lines.Line2D at 0x7f223f704ad0>, <matplotlib.lines.Line2D at 0x7f223f704d10>, <matplotlib.lines.Line2D at 0x7f223f7113d0>]
plt.plot(precip14[:,x[9],y[9]])
[<matplotlib.lines.Line2D at 0x7f223f643a90>]