**To**:**Leela Frankcombe <leela.frankcombe@xxxxxxxxx>****Subject**:**Re: [ferret_users] current path length****From**:**mick spillane <mick.spillane@xxxxxxxx>**- Date: Thu, 19 May 2011 13:02:10 -0700
- Cc: oar.pmel.ferret_users@xxxxxxxx
- In-reply-to: <BFAB582F-8F26-4C35-9E1B-B07FCA7CC798@xxxxxxxxx>
- References: <BFAB582F-8F26-4C35-9E1B-B07FCA7CC798@xxxxxxxxx>
- Sender: owner-ferret_users@xxxxxxxx
- User-agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:1.9.2.17) Gecko/20110414 Lightning/1.0b2 Thunderbird/3.1.10

Hi Leela,

First: Check that Ferret's "where" command is working for you: go ptest where

use levitus_climatology ; let sst=temp[k=1] fill/x=140:310/y=-30:10 sst ; cont/o/lev=(25)/x=140:310/y=-30:10 sst go polydef ! prompts user to click on desired points, terminating by

sho data 2> ./vertices.xy (default) name title I J K L

! circle distances along the curve. One way to do this is as follows: go greatcircle ! definitions for great circle calculations let lon1=vx ; let lat1=vy ; let lon2=vx[k=@shf] ; let lat2=vy[k=@shf]

18033.

Hope it is of use, Mick ---------------- On 5/19/11 11:06 AM, Leela Frankcombe wrote:

Dear Ferreters, I've come across a question which is simple in theory but in practice I'm having a little trouble. So I'm wondering if anyone else has found a solution. What I would like to do is calculate the path length of an ocean current. To define the path of the current I pick a particular sea surface height contour, now I would like to be able to calculate the length of that contour. I've been trying to use @loc or @weq to select the points at which SSH reaches the value that I've chosen but they only find the first instance along a given latitude or longitude so they miss parts where the current meanders (and also sometimes pick up eddies). Is there a way to use @loc or @weq to find every instance of a particular value? Or has someone got a better solution? Thanks! Leela. ----------------------------------------------------------------------------------- Leela Frankcombe Post-doctoral researcher Institute for Marine and Atmospheric research Utrecht Utrecht University The Netherlands www.phys.uu.nl/~frankcmb l.m.frankcombe@xxxxx -----------------------------------------------------------------------------------

**Attachment:
demo.png**

! polydef : use mouse click to define polygon vertices can mode verify let done=0 ; sp rm -f vertices.xy say "****************************************************" say "* *" say "* Add polygon vertices by mouse clicks. Terminate *" say "* by clicking to the left of the plot area. *" say "* *" say "****************************************************" ! add new vertices to the file vertices.xy repeat/range=1:1000 go add_vertex ! then read in the resulting file sp get_vertices ; go get_vertices set mode verify

! add a new vertex to the vertex file while done=0 if `done eq 0` then where if `($XMOUSE) gt ($XAXIS_MIN)` then list/nohead/app/form=(2f12.6)/file=vertices.xy ($XMOUSE),($YMOUSE) ! if visible marks at the vertices are not desired drop the next line plot/o/nolab/vs/sym=1 ($XMOUSE),($YMOUSE) else let done=1 endif endif

! greatcircle : definitions for great circle calculations between ! two locations lon1,lat1 and lon2,lat2 (in degrees) ! let d2r=atan(1.)/45 let rlon1=d2r*lon1 ; let rlat1=d2r*lat1 let rlon2=d2r*lon2 ; let rlat2=d2r*lat2 ! define great circle distances from lon1,lat1 to lon2,lat2 in radians ... let/title="Great Circle Distance (radians)" \ gcrad=acos(sin(rlat1)*sin(rlat2)+cos(rlat1)*cos(rlat2)*cos(rlon2-rlon1)) ! ... and kilometers let/title="Great Circle Distance (km)" gckm=111.11*gcrad/d2r let/title="Great Circle Distance (nm)" gcnm=60*gcrad/d2r ! define initial heading from lon1,lat1 to lon2,lat2 (clockwise from north) let gcharg=acos((sin(rlat2)-sin(rlat1)*cos(gcrad))/(sin(gcrad)*cos(rlat1))) ! correct for near north-south pairings let gchfix=gcharg[x=@fln]/d2r let/title="Initial Heading (degrees)" \ gchead=if(sin(rlon2-rlon1) gt 0)then gchfix else 360-gchfix let/title="Secant Distance (3-D separation in km)" seckm=gckm*sin(gcrad/2)/(gcrad/2) let lat=atan((tan(d2r*lat2)*sin(d2r*(lon-lon1))-tan(d2r*lat1)*sin(d2r*(lon-lon2)))/ \ sin(d2r*(lon2-lon1)))/d2r ! Usage: the results "gcrad", "gckm", and "gchead" are computed based on ! existing variables lon1,lat1 representing the start point and ! lon2,lat2 representing the destination. ! ! NOTE : To plot a greatcircle from lon1,lat1 to lon2,lat2 define a variable "lon" ! that spans the interval between them with sufficient resolution, for example ! def axis/x=`lon1`:`lon2`:0.1 xax ; let lon=x[gx=xax] ! plot/o/vs/nolab/line=2 lon,lat ! If a gridded file such as a topography is available it may be convenient to ! use that x-axis for "lon": ! let lon=x[g=...] ! plot/o/vs/nolab/line=2/x=`lon1`:`lon2` lon,lat !

#! /bin/csh -f # get_vertices : create ferret script to access vertex data set nrec=`wc -l vertices.xy | awk '{print $1}'` echo 'def axis/z=1:'$nrec':1/mod zpoly ; def grid/z=zpoly gpoly' >! get_vertices.jnl echo 'file/form=free/g=gpoly/var=vx,vy vertices.xy' >> get_vertices.jnl

**Follow-Ups**:**Re: [ferret_users] current path length***From:*Andrew Wittenberg

**Re: [ferret_users] current path length***From:*Jaison Kurian

**References**:**[ferret_users] current path length***From:*Leela Frankcombe

- Previous by thread:
**[ferret_users] current path length** - Next by thread:
**Re: [ferret_users] current path length**

Dept of Commerce / NOAA / OAR / PMEL / Ferret

Privacy Policy | Disclaimer | Accessibility Statement