[ncl-talk] R: NCL uv2vr_cfd function on Python
Giorgio Graffino
giorgio.graffino at alice.it
Tue Sep 29 08:29:52 MDT 2015
Ok, I think I've found the problem: dx2 and dy2 are distance in meters, not degrees.
Since u and v are given in latitude/longitude, there must be an implicit conversion inside the uv2vr_cfd function.
Anyone knows how this conversion is performed?
Giorgio
----Messaggio originale----
Da: giorgio.graffino at alice.it
Data: 29-set-2015 11.31
A: <ncl-talk at ucar.edu>
Ogg: [ncl-talk] NCL uv2vr_cfd function on Python
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
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/122f3f4b/attachment.html
More information about the ncl-talk
mailing list