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

Home » Public Forums » archive » Finding peak with cgHistoplot and bin confusion
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
Finding peak with cgHistoplot and bin confusion [message #87111] Wed, 08 January 2014 05:39 Go to next message
rjp23 is currently offline  rjp23
Messages: 97
Registered: June 2010
Member
I'm using cgHistoplot with the binsize value set like so:

cgHistoplot, data, binsize=100, xrange=[0, 8000]

Is there a simple way to find the x value where the histogram peaks?

I thought using the histdata keyword would have worked and then something like find=where(histdata EQ max(histdata)).

The problem though is then knowing which bin that subscript refers to. I assumed because I specify xrange starting from 0 then my first bin would be 0-99. However, if I use the omin keyword it returns a value of 698.045. Does that mean by first bin is 600-699? or 698.045-797.045?

Cheers
Re: Finding peak with cgHistoplot and bin confusion [message #87112 is a reply to message #87111] Wed, 08 January 2014 05:59 Go to previous messageGo to next message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
rjp23@le.ac.uk writes:

>
> I'm using cgHistoplot with the binsize value set like so:
>
> cgHistoplot, data, binsize=100, xrange=[0, 8000]
>
> Is there a simple way to find the x value where the histogram peaks?
>
> I thought using the histdata keyword would have worked and then something like find=where(histdata EQ max(histdata)).
>
> The problem though is then knowing which bin that subscript refers to. I assumed because I specify xrange starting from 0 then my first bin would be 0-99. However, if I use the omin keyword it returns a value of 698.045. Does that mean by first bin is 600-699? or 698.045-797.045?

I would do something like this:

cgHistoplot, data, binsize=100, xrange=[0, 8000], HistData=d
maxValue = Max(d, binNumber)

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: Finding peak with cgHistoplot and bin confusion [message #87113 is a reply to message #87112] Wed, 08 January 2014 06:33 Go to previous messageGo to next message
rjp23 is currently offline  rjp23
Messages: 97
Registered: June 2010
Member
On Wednesday, January 8, 2014 1:59:29 PM UTC, David Fanning wrote:
>
> I would do something like this:
>
>
>
> cgHistoplot, data, binsize=100, xrange=[0, 8000], HistData=d
>
> maxValue = Max(d, binNumber)
>

Hi David,

Sorry I don't think I explained very well. What you've posted there is just the equivalent of find=where(histdata EQ max(histdata)) isn't it?

What is causing me trouble is then using the returned bin subscript to get the correct bin value.

I think my problem is that I assumed that the first bin was at the bottom of my xrange but it's actually at the bottom of my data range (I think?).

If I do this it looks like it works to get to the middle of the bin in which the distribution peaks:

peak=omin+binsize*find+binsize/2.
Re: Finding peak with cgHistoplot and bin confusion [message #87115 is a reply to message #87113] Wed, 08 January 2014 09:09 Go to previous message
Phillip Bitzer is currently offline  Phillip Bitzer
Messages: 223
Registered: June 2006
Senior Member
According to the documentation, xrange is passed to the plot command. You're probably wanting mininput/maxinput, not xrange:

http://www.idlcoyote.com/idldoc/cg/cghistoplot.html

But more to the point, you can always get the locations of the bins through a keyword:
cgHistoplot, data, binsize=100, LOCATIONS=loc, HISTDATA=h

maxHisto = MAX(h, binInd)
print, loc[binInd]

Keep in mind that the locations are the starting point of the bins. You might want to use the center of the bin for reporting purposes.
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Missing value and Image size in Image, Function Graphic
Next Topic: Thickness of Errorbar

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

Current Time: Wed Oct 08 13:48:38 PDT 2025

Total time taken to generate the page: 0.00469 seconds