[Thread Prev][Thread Next][Index]

Re: [ferret_users] current path length



Leela, Mick, et al.,

Towards using @weq to compute the path length of a contour...

Because @weq only creates interpolation coefficients for the first value it finds, this will only work if the contour is single-valued in latitude -- i.e. it wouldn't work for Mick's example near 120W, where the 25C contour loops back on itself. But it would work for, say, the segment in Mick's example between 160E and 140W. You might be able to handle a general case by masking out parts of the contour (with IF..THEN, or with SET REGION), and doing the mostly-horizontal and mostly-vertical segments separately, with separate integrals along x and y, and then summing up all the segment lengths.

The following approach could even be used in tandem with Mick's, to permit analysis of general contour shapes but without having to click quite so many points.

use levitus_climatology
set region/x=160:250/y=-30:-10
let contour_value = 25
let var = temp[k=1]

let zero_at_value = var - contour_value
let kernel = zero_at_value[y=@weq] * y[gy=var]
let y_at_contour = kernel[y=@sum]

let xval = x[gx=var]
let dx = xval[x=@shf] - xval
let dy = y_at_contour[x=@shf] - y_at_contour
let deg2rad = 3.14159 / 180
let r_earth_m = 6371000
let dx_m = dx*deg2rad * r_earth_m * cos(y_at_contour*deg2rad)
let dy_m = dy*deg2rad * r_earth_m

let length_seg = (dx_m^2 + dy_m^2)^.5
let length = length_seg[x=@sum]

This was just a quick reply -- I'm probably off by one gridcell at the end, and there may be other mistakes. Will leave it to others to work out the details -- please post any improvements to the list!

Andrew

On Thu, 19 May 2011, mick spillane wrote:

Hi Leela,

   This is not necessarily a better solution to your problem than use of
transformations like @loc or @weq, but it illustrates how using Ferret as a
digitizer, coupled with a Great Circle Distance calculator can be useful in a
variety of situations. Apologies if this is already known to you but it may
serve a wider audience.

First: Check that Ferret's "where" command is working for you:
   go ptest
   where
When you move the cursor over the plot and click. Ferret should report the
"mouse" coordinates in user units. This is the key to digitizing and a
variety of other tasks one could imagine.

Next: Add the attached scripts to your directories (I would typically put the
.jnl ones in my "ferret" directory and the shell script get_vertices [with
chmod +x get_vertices] in "bin")

Demo: Here is an illustration. What is the length of the 25C isotherm of
Levitus SST between Australia and South America?
   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
                       ! clicking offchart to the left. When this is done
the coords of
                       ! the point are loaded as a file with variables VX,VY
   sho data
  2> ./vertices.xy  (default)
name     title                             I         J         K         L
VX       VX                               ...       ...       1:76      ...
VY       VY                               ...       ...       1:76      ...
! As seen in the attached graphic I took 76 points to delineate the isotherm.

! In this case, where VX,VY are lon,lat values, what is needed is to sum the
great
! 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]
   list gckm[k=1:75@sum]  ! sum up the GC contributions, giving the answer
(in kilometers)
   18033.
Note that you sum over one less than the number of vertices so as not to run
off the end. I did the above twice, because I forgot to save the plot, and
the first time got 18042. This suggests the method is good enough for a
certain class of problem. Perhaps a better demo would have been to use the
hints in "greatcircle.jnl" to plot a portion of a great circle, then digitize
it and compare the result with the known answer, but this one at least
illustrates how it can deal with complex paths.

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

-----------------------------------------------------------------------------------




[Thread Prev][Thread Next][Index]
Contact Us
Dept of Commerce / NOAA / OAR / PMEL / Ferret

Privacy Policy | Disclaimer | Accessibility Statement