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

Home » Public Forums » archive » Re: How can i get the co-ordinates of the peaks in a plot?
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
Re: How can i get the co-ordinates of the peaks in a plot? [message #50321] Mon, 25 September 2006 13:29 Go to next message
Paul Van Delst[1] is currently offline  Paul Van Delst[1]
Messages: 1157
Registered: April 2002
Senior Member
zircola wrote:
> I used max function to get the y value but don't know how to get the
> corresponding x value and how to get the xy value of the more than one
> peaks. please help. thanks:)

Take the derivative (use DERIV) of your curve to locate all the peaks (where the
derivative crosses the zero line. Then, as Mike Braedley's post detailed, use the MAX
function with the optional subscript to get the x value at each zero crossing. You *may*
have to interpolate if the x-axis resolution of your data is too low, but I'd be leery of
doing that.

There's probably an easier way if you use HISTOGRAM. :o)

cheers,

paulv

--
Paul van Delst Ride lots.
CIMSS @ NOAA/NCEP/EMC Eddy Merckx
Ph: (301)763-8000 x7748
Fax:(301)763-8545
Re: How can i get the co-ordinates of the peaks in a plot? [message #50332 is a reply to message #50321] Mon, 25 September 2006 05:05 Go to previous messageGo to next message
Braedley is currently offline  Braedley
Messages: 57
Registered: September 2006
Member
zircola wrote:
> I used max function to get the y value but don't know how to get the
> corresponding x value and how to get the xy value of the more than one
> peaks. please help. thanks:)

An optional argument for max is max_subscript. Set this to a named
variable to get the index of the array that contains the maximum value.
Then it's as simple as subscripting your x array with that named
variable.

y_val=max(y, max_index, /abs)
x_val=x[max_index]
print, 'The maximum occured at ', x_val, ' and had a value of ', y_val
Re: How can i get the co-ordinates of the peaks in a plot? [message #50333 is a reply to message #50332] Mon, 25 September 2006 02:10 Go to previous messageGo to next message
Tigran Khanzadyan is currently offline  Tigran Khanzadyan
Messages: 5
Registered: September 2006
Junior Member
zircola wrote:
> I used max function to get the y value but don't know how to get the
> corresponding x value and how to get the xy value of the more than one
> peaks. please help. thanks:)

Hi,

I can quickly answer to your first question:

sizeim=size(image)
szx=sizeim(1)*1.
szy=sizeim(2)*1.
inx=where(image eq max(image))
xv=round((inx/szx-fix(inx/szx))*szx)
xv=xv(0)
yv=fix(inx/szx)
yv=yv(0)

xx=findgen(szx)-xv
yy=findgen(szy)-yv
xx=xx*(image pixel scale)*(-1.) ; for correct RA direction
yy=yy*(image pixel scale)

You can use this coordinates to make a plot with 0 on maximum value.
For more peaks, maybe you can overplot contours and show that way
some of your peaks.

I hope this can solve some of your problems.

Cheers
Re: How can i get the co-ordinates of the peaks in a plot? [message #50484 is a reply to message #50321] Thu, 28 September 2006 17:45 Go to previous message
zircola is currently offline  zircola
Messages: 8
Registered: September 2006
Junior Member
thank you IDL gurus, i am learning a lot. works great.
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: Closing out of a Window
Next Topic: How can i get the co-ordinates of the peaks in a plot?

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

Current Time: Wed Oct 08 19:56:20 PDT 2025

Total time taken to generate the page: 0.00540 seconds