**To**:**"Balaguru, Karthik" <karthiknaidu@xxxxxxxxxxxx>****Subject**:**Re: [ferret_users] Integrating over irregular regions****From**:**mick spillane <mick.spillane@xxxxxxxx>**- Date: Mon, 19 Oct 2009 15:20:57 -0700
- Cc: oar.pmel.ferret_users@xxxxxxxx
- In-reply-to: <742829137.3002151255972949697.JavaMail.root@neo-mail-3>
- References: <742829137.3002151255972949697.JavaMail.root@neo-mail-3>
- Sender: owner-ferret_users@xxxxxxxx
- User-agent: Thunderbird 2.0.0.23 (Macintosh/20090812)

Hi Karthik,

So here is a demo that may be appropriate -- but note the following:

! demo of InsidePolygon use to get mean depth of an area in the pacific use etopo20 sho data shade/x=120:240/y=0:60 rose ! define CLOSED quadrilateral with ZSEQUENCE let vx=zsequence({160,200,220,210,160}) let vy=zsequence({20,30,40,50,20}) poly/o/nolab/line=2 vx,vy

! to check for "insideness" so, in this case: let x0=x[g=rose] ; let y0=y[g=rose] shade/o/nolab/pal=red/pat=dark_vertical inside let maskdepth=inside*rose list maskdepth[x=@din,y=@din]

Hope this helps, if not in your situation then in another. Good luck, Mick Balaguru, Karthik wrote:

Hi all, Is there a way in which we can integrate over an irregular region? Let's say I have a region in the shape of a parallelogram whose 4 corner co-ordinates are (longitude,latitude) respectively. How can I integrate a variable, say temperature over this region? Thanks a lot! Karthik.

! InsidePolygon : Tests if a point (X0,Y0) is inside a closed polygon defined ! by a set of vertices (VX,VY),K=1,NV whose last point duplicates ! its first. It is based on the number of intersections ! between the NV-1 edges of the polygon and a line from (X0,Y0) ! to (X0,YTOP) where YTOP is the upper limit of the domain (90 ! when X,Y are lon/lat coords). ! The point is INSIDE if the #intersections is ODD. ! Written 26-May-2009 by Mick.Spillane@xxxxxxxx let YTOP=90 ; let NEDGE=VX[k=@ngd]-1 ! An edge is a candidate if X0 lies between VX and VX[k=@shf] ... let XWORKS=if((X0-VX)*(X0-VX[k=@shf]) lt 0)then 1 ! ... but the Y-value of the edge, at X=X0, must also be between Y0 and YTOP let YPRIME=VY+XWORKS*(VY[k=@shf]-VY)*(X0-VX)/(VX[k=@shf]-VX) let ITCUTS=if((YPRIME-Y0)*(YPRIME-YTOP) lt 0)then 1 let INSIDE=if(mod(ITCUTS[K=1:`NEDGE`@ngd],2) eq 1)then 1

**References**:**[ferret_users] Integrating over irregular regions***From:*Balaguru, Karthik

- Previous by thread:
**Re: [ferret_users] Integrating over irregular regions** - Next by thread:
**Re: [ferret_users] Integrating over irregular regions**

Contact Us

Dept of Commerce / NOAA / OAR / PMEL / TMAP

Privacy Policy | Disclaimer | Accessibility Statement