[Thread Prev][Thread Next][Index]

Re: [ferret_users] how to calculate the streamfunction and velocity potential

Sorry everybody, but the script I sent yesterday may be confusing because the header at the top lists the passed arguments incorrectly (there are two sets of arg1 and arg2). The code is correct but the comments are not. The second set of arg1/arg2 should be arg3/arg4 (3rd and 4th passed arguments, used in the code as $3 and $4). Here is the corrected version:

! compute the horizontal streamfunction from model file (make vertical integral)
! arg1=variable name for u
! arg2=variable name for v
! arg3=x0 (must be on a gridpoint or set mode interp)
! arg4=y0 (likewise)
! psi=int(y0,y)u(x,y)dy - int(x0,x)v(x,y0)dx
! u=d(psi)/dy, v=-d(psi)/dx
! as noted by RF, this is only correct when d(u[z=@din])/dx + d(v [z=@din])/dy = 0 (nondivergent)

set mode interp
! must find y0 and z0
let y1a=y[g=$2,j=1]
def sym y1 `y1a`
def sym y0 `$4`
let x1a=x[g=$1,i=1]
def sym x1 `x1a`
def sym x0 `$3`
! ferret has a problem with blanks and @iin
let ub=if $1 then $1 else 0
let vb=if $2 then $2 else 0
! second term
let t2=vb[z=@din,l=@ave,y=($y0),x=@iin]-vb[z=@din,l=@ave,y=($y0),x= ($x1):($x0)@din]
! first term
let t1=ub[z=@din,l=@ave,y=@iin]-ub[k=@din,l=@ave,y=($y1):($y0)@din]
!! streamfunction
let strmfnxy=t1-t2
let usf=strmfnxy[y=@ddc]
let vsf=strmfnxy[x=@ddc]*(-1)
say x0=`($x0)`  y0=`($y0)`

[Thread Prev][Thread Next][Index]

Contact Us
Dept of Commerce / NOAA / OAR / PMEL / TMAP

Privacy Policy | Disclaimer | Accessibility Statement