[ncl-talk] NCL uv2vr_cfd function on Python
Giorgio Graffino
giorgio.graffino at alice.it
Tue Sep 29 03:31:04 MDT 2015
Dear NCL Users,
I'm trying to adapt an NCL script I wrote to compute water vertical speed on Python.
In particular, I'm finding some difficulties on "translating" the NCL built-in function uv2vr_cfd into Python; I used that function to compute the vertical component of wind stress. On the web page (https://www.ncl.ucar.edu/Document/Functions/Built-in/uv2vr_cfd.shtml) it's stated that
According to H.B. Bluestein [Synoptic-Dynamic Meteorology in Midlatitudes, 1992,
Oxford Univ. Press p113-114], let D represent the partial derivative, a the radius of
the earth, phi the latitude and dx2/dy2 the appropriate longitudinal and latitudinal
spacing, respectively. Then, letting j be the latitude y-subscript, and i be the
longitude x-subscript:
rv = Dv/Dx - Du/Dy + (u/a)*tan(phi)
rv(j,i) = (v(j,i+1)-v(j,i-1))/dx2(j)
- (u(j+1,i)-u(j-1,i))/dy2(j)
+ (u(j,i)/a)*tan(phi(j))
Now, I tried to write that function on Python in this way
p, li { white-space: pre-wrap; }
def Curl(u,v,nlat,nlon):
rv = np.empty(shape=(nlat,nlon))
rv.fill(np.nan)
M0 = np.arange(1,nlat-1) # M0 = [1,...,nlat-1]
N0 = np.arange(1,nlon-1) # N0 = [1,...,nlon-1]
for m in M0: for n in N0: rv[m,n] = (v[m,n+1]-v[m,n-1])/(lons[n+1]-lons[n-1]) - \
(u[m+1,n]-u[m-1,n])/(lats[m+1]-lats[m-1]) + \
(u[m,n]/radius)*tans[m]
return rv
but, even if the pattern is similar, there are four orders of magnitude between the values. I attach results using NCL (MedDailyINDEX.png file) and Python (WindStressCurl.png) for the same day.
Could it be possible to know how exactly rv is computed inside uv2vr_cfd function? Because I think there is something missing in my implementation...
Thanks for your attention.
Regards,
Giorgio
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20150929/d5e47ba0/attachment-0001.html
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 20131231_MedDailyINDEX.png
Type: image/png
Size: 82947 bytes
Desc: not available
Url : http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20150929/d5e47ba0/attachment-0002.png
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 20131231_WindStressCurl.png
Type: image/png
Size: 200030 bytes
Desc: not available
Url : http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20150929/d5e47ba0/attachment-0003.png
More information about the ncl-talk
mailing list