comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » How to obtain contour data through contour command?
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
How to obtain contour data through contour command? [message #86259] Tue, 22 October 2013 05:12 Go to next message
jacobsvensmark is currently offline  jacobsvensmark
Messages: 7
Registered: October 2013
Junior Member
So I have regularly gridded f(x,y) values, and I wish to know for which x,y I have f(x,y)=k. I imagine this is exactly what the contour command does, though I don't believe it can only plot the curve, not output the curve in an array.

I apologize if this is super trivial.
Re: How to obtain contour data through contour command? [message #86262 is a reply to message #86259] Tue, 22 October 2013 06:14 Go to previous messageGo to next message
Mats Löfdahl is currently offline  Mats Löfdahl
Messages: 263
Registered: January 2012
Senior Member
On 2013-10-22 14:12, jacobsvensmark@gmail.com wrote:
> So I have regularly gridded f(x,y) values, and I wish to know for which x,y I have f(x,y)=k. I imagine this is exactly what the contour command does, though I don't believe it can only plot the curve, not output the curve in an array.

The array indices are easy to find:

IDL> f = [[1, 2, 3], [2, 3, 2]]
IDL> print, f
1 2 3
2 3 2
IDL> print, array_indices(f, where(f eq 2))
1 0
0 1
2 1

If the x and y coordinates are different from the grid indices you will
need to use the indices to get them. How that is done depends on how
those coordinates are specified.
Re: How to obtain contour data through contour command? [message #86263 is a reply to message #86259] Tue, 22 October 2013 06:32 Go to previous messageGo to next message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
jacobsvensmark@gmail.com writes:

> So I have regularly gridded f(x,y) values, and I wish to know for which x,y I have f(x,y)=k. I imagine this is exactly what the contour command does, though I don't believe it can only plot the curve, not output the curve in an array.

You can get the output contour values from the Contour command using the
PATH_*** keywords. Or, you can use the hard to decipher ISOCONTOUR
command to do the same thing.

Cheers,

David



--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
Sepore ma de ni thue. ("Perhaps thou speakest truth.")
Re: How to obtain contour data through contour command? [message #86283 is a reply to message #86263] Tue, 22 October 2013 14:50 Go to previous message
kagoldberg is currently offline  kagoldberg
Messages: 26
Registered: November 2012
Junior Member
An example of looks like this

contour, image, levels=[30.,40.], path_info=pinfo, path_xy=pxy, /path_data_coords, /closed

Here, pinfo is a structure that tells you about the information contained in pxy.
You have to write some flexible code to handle this properly because pxy is a single, 2xN array that actually contains all of the contours you requested, strung together vertically. pxy[0,*] are the x values, and pxy[1,*] are the y values.

To make it usable, you have to sort through pinfo. pinfo is an array of structures with fields {type, high_low, level, n, offset, value}. The pinfo.offset field elements tell you the index values of pxy where each contour starts, and pinfo.n elements tell you how many points are in each contour.

Here is one array for each contour.
xy0 = pxy[0:1, pinfo[0].offset : pinfo[0].offset + pinfo[0].N - 1]
xy1 = pxy[0:1, pinfo[1].offset : pinfo[1].offset + pinfo[1].N - 1]

Where you have to be careful, I've found, is that sometimes you get two (or more?) contours for the same level value. In my example I have 2 levels, but you could end up with 3 or more contour "pieces." So check the pinfo.value field to see if you have separate contours with matching level values, and group/concatenate them if necessary.

-Ken
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Using Minimum operator with NaN values
Next Topic: Strange error: % Keyword parameters not allowed in call.

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 11:39:24 PDT 2025

Total time taken to generate the page: 0.00471 seconds