[gradsusr] hdivg function

Eric Altshuler ela at cola.iges.org
Tue Nov 16 00:18:58 EST 2010


Jeff,

If you want to question my methodology, go right ahead, but it's wise to make sure your own expressions are correct before you post them. Your expression for 'divergence' is wrong.

divergence != cdiff(u,x)/dx + cdiff(v,y)/dy

Compare plots of that expression vs. hdivg(u,v) and you'll see major differences, especially at higher latitudes.

Eric

----- Original Message -----
From: "Jeffrey Duda" <jdduda at iastate.edu>
To: "GrADS Users Forum" <gradsusr at gradsusr.org>
Sent: Monday, November 15, 2010 4:32:13 PM
Subject: Re: [gradsusr] hdivg function


Instead of doing strange differentials inside the divergence calculation, I just calculate each component separately beforehand if it is at all complicated. Thus I use: 

dx = Re*cos(lat(3.14159/180))*cdiff(lon,x)*(3.14159/180) 
dy = Re*cdiff(lat,y)*(3.14159/180) 

Then, divergence = cdiff(u,x)/dx + cdiff(v,y)/dy 

Jeff Duda 


On Mon, Nov 15, 2010 at 12:53 PM, Eric Altshuler < ela at cola.iges.org > wrote: 


This issue also came up about a month ago. For those of us who aren't C programmers and would have difficulty determining the formulas from the source code, I will say there are several incorrect formulas for hdivg(u,v) in this thread, and one correct formula (in Yaqiang Wang's most recent message). To make the correct answer perfectly clear, here it is again: 


dx = cdiff(lon,x)*3.1416/180 

dy = cdiff(lat,y)*3.1416/180 

du = cdiff(u,x) 

dv = cdiff(v*cos(lat*3.1416/180),y) 

div = (du/dx+dv/dy)/(6.37e6*cos(lat*3.1416/180)) 

As an aside, I think it's possible to obtain more accurate approximations for divergence and vorticity than those given in the grads documentation, because the factor cos(lat) can be taken outside the derivative operator and differentiated analytically rather than using finite differencing. Using the product rule of differentiation and a bit of algebra, I have derived the following sequence of calculations for these quantities (my definitions of intermediate quantities are different, but the end result is the same): 

pi=3.14159265359 
dtr=pi/180 
a=6.371e6 
dx=a*cos(dtr*lat)*dtr*cdiff(lon,x) 
dy=a*dtr*cdiff(lat,y) 
div=cdiff(u,x)/dx+cdiff(v,y)/dy-v*tan(dtr*lat)/a 
vor=cdiff(v,x)/dx-cdiff(u,y)/dy+u*tan(dtr*lat)/a 
def1=cdiff(u,x)/dx-cdiff(v,y)/dy-v*tan(dtr*lat)/a 
def2=cdiff(v,x)/dx+cdiff(u,y)/dy+u*tan(dtr*lat)/a 

In these formulas, substitute your wind variable names for u and v. In addition to divergence and vorticity, there are also calculations of the components of deformation, def1 and def2, and total deformation is equal to mag(def1,def2). These formulas (in terms of continuous fields) can also be found in Bluestein (1992), "Synoptic-Dynamic Meteorology in Midlatitudes", Vol. I, p. 111. 

Best regards, 

Eric L. Altshuler 
Assistant Research Scientist 
Center for Ocean-Land-Atmosphere Studies 
4041 Powder Mill Road, Suite 302 
Calverton, MD 20705-3106 
USA 

E-mail: ela at cola.iges.org 
Phone: (301) 902-1257 
Fax: (301) 595-9793 




----- Original Message ----- 
From: "Arlindo da Silva" < dasilva at alum.mit.edu > 
To: "GrADS Users Forum" < gradsusr at gradsusr.org > 
Sent: Monday, November 15, 2010 10:55:55 AM 
Subject: Re: [gradsusr] hdivg function 


All, 


The most authoritative documentation on the hdivg function can be found here: 


http://opengrads.cvs.sourceforge.net/viewvc/opengrads/cola/grads2/src/gafunc.c?revision=1.1.1.9&view=markup 


That is, the source code :-). The hdivg() implementation can be found on line 2716. This file has the implementation of most grads functions. 


BTW, the link above is the web interface to the opengrads CVS repository. We keep in this particular directory the original releases from COLA, before any opengrads patches are applied: 


http://opengrads.cvs.sourceforge.net/viewvc/opengrads/cola/grads2/src/ 


There is a pulldown menu called "Sticky Tag" that you can use to select a particular grads version. 


Arlindo 







On Mon, Nov 15, 2010 at 12:44 AM, Yaqiang Wang < yaqiang.wang at gmail.com > wrote: 


The correct one should be: 

define du = cdiff(u,x) 

define dx = cdiff(lon,x)*3.1416/180 
define dv = cdiff(v*cos(lat*3.1416/180),y) 

define dy = cdiff(lat,y)*3.1416/180 
display (du/dx+dv/dy)/(6.37e6*cos(lat*3.1416/180)) 

Yaqiang 


Chinese Academy of Meteorological Sciences 
yaqiang.wang at gmail.com 




On Mon, Nov 15, 2010 at 12:47 PM, Yaqiang Wang < yaqiang.wang at gmail.com > wrote: 
> Thanks for Jeff's reply! But it seems that in GrADS the hdivg function 
> was calculated as following. Please mention the last sentence. 
> 
> define dv = cdiff(v,x) 
> define dx = cdiff(lon,x)*3.1416/180 
> define du = cdiff(u*cos(lat*3.1416/180),y) 
> define dy = cdiff(lat,y)*3.1416/180 
> display (du/dy+dv/dx)/(6.37e6*cos(lat*3.1416/180)) 
> 
> Yaqiang 
> 
> Chinese Academy of Meteorological Sciences 
> yaqiang.wang at gmail.com 
> 
> On Mon, Nov 15, 2010 at 11:56 AM, Jeffrey Duda < jdduda at iastate.edu > wrote: 
>> Yaqiang, 
>> You are exactly correct. 
>> 
>> Jeff Duda 
>> 
>> On Sun, Nov 14, 2010 at 9:22 PM, Yaqiang Wang < yaqiang.wang at gmail.com > 
>> wrote: 
>>> 
>>> The GrADS documentation said that the cdiff function may be used to 
>>> duplicate the calculation done by the hcurl function: 
>>> 
>>> define dv = cdiff(v,x) 
>>> define dx = cdiff(lon,x)*3.1416/180 
>>> define du = cdiff(u*cos(lat*3.1416/180),y) 
>>> define dy = cdiff(lat,y)*3.1416/180 
>>> display (dv/dx-du/dy)/(6.37e6*cos(lat*3.1416/180)) 
>>> 
>>> But there is no description of hdivg function. I guess hdivg function 
>>> could be duplicated using cdiff function as following. Please anybody 
>>> tell me if it is correct or not. Thanks! 
>>> 
>>> define dv = cdiff(v,x) 
>>> define dx = cdiff(lon,x)*3.1416/180 
>>> define du = cdiff(u*cos(lat*3.1416/180),y) 
>>> define dy = cdiff(lat,y)*3.1416/180 
>>> display (du/dx+dv/dy)/(6.37e6*cos(lat*3.1416/180)) 
>>> 
>>> Yaqiang Wang 
>>> 
>>> Chinese Academy of Meteorological Sciences 
>>> yaqiang.wang at gmail.com 
>>> _______________________________________________ 
>>> gradsusr mailing list 
>>> gradsusr at gradsusr.org 
>>> http://gradsusr.org/mailman/listinfo/gradsusr 
>> 
>> 
>> 
>> -- 
>> Jeff Duda 
>> Iowa State University 
>> Meteorology Graduate Student 
>> 3134 Agronomy Hall 
>> www.meteor.iastate.edu/~jdduda 
>> 
>> _______________________________________________ 
>> gradsusr mailing list 
>> gradsusr at gradsusr.org 
>> http://gradsusr.org/mailman/listinfo/gradsusr 
>> 
>> 
> 
_______________________________________________ 
gradsusr mailing list 
gradsusr at gradsusr.org 
http://gradsusr.org/mailman/listinfo/gradsusr 



-- 
Arlindo da Silva 
dasilva at alum.mit.edu 

_______________________________________________ 
gradsusr mailing list 
gradsusr at gradsusr.org 
http://gradsusr.org/mailman/listinfo/gradsusr 
_______________________________________________ 
gradsusr mailing list 
gradsusr at gradsusr.org 
http://gradsusr.org/mailman/listinfo/gradsusr 



-- 
Jeff Duda 
Iowa State University 
Meteorology Graduate Student 
3134 Agronomy Hall 
www.meteor.iastate.edu/~jdduda 

_______________________________________________
gradsusr mailing list
gradsusr at gradsusr.org
http://gradsusr.org/mailman/listinfo/gradsusr



More information about the gradsusr mailing list