Hi Feng, You could redefine your coordinate axes so their units are not longitude and latitude, for the purposes of this calculation. Then the order of the integral and derivitive can be interchanged and you should get the result you want. Ansley FENG HE wrote: Hi Ansley Thank you for your reply. Right now, I understand the curvature of earth gives the difficulty for this problem. I would like to know what is the right way to calculate the streamfunction using Kessler's script (http://ferret.pmel.noaa.gov/Ferret/Mail_Archives/fu_2002/msg00155.html) Mathematically, the solution (Psi = Int{y0:y}u dy - Int{x_0:x}v(x,y_0) dx) is perfect, but in Ferret, because it could not support swapping integral and differential, I could not reproduce v using -d(Psi)/dx Best regards Feng He Center for Climate Research Atmospheric and Oceanic Sciences University of Wisconsin - Madison ----- Original Message ----- From: Ansley Manke <Ansley.B.Manke@noaa.gov> Date: Friday, March 17, 2006 10:02 am Subject: Re: [ferret_users] Why does ferret fail to support swapping integral and differential? To: FENG HE <fenghe@wisc.edu> Cc: oar.pmel.ferret_users@noaa.govHi Feng, Thank you for sending a clear example. This turns out to be because derivatives and integrals on fields in latitude and longitude are done in units of meters on the earth, rather than degrees latitude and longitude. The fact that degrees of longitude are not a constant length over the earth means that the computations are not linear. Try this case, where the numbers may be easier to interpret. yes? use coads_climatology yes? set reg/x=1:3/y=51:55/L=1 yes? let uu_ddb = uu[x=@ddb] yes? let uu_ddb_iin = uu_ddb[y=@iin] yes? let uu_iin = uu[y=@iin] yes? let uu_iin_ddb = uu_iin[x=@ddb] ! Define a function with simple integer values yes? let uu = x[gx=uwnd] + y[gy=uwnd] yes? list uu ! Set the axes so they are NOT in units of degrees ! longitude and latitude. yes? set axis/units=" " coadsx yes? set axis/units=" " coadsy ! The results are as you would expect. yes? list uu_ddb yes? list uu_iin yes? list uu_ddb_iin yes? list uu_iin_ddb |