Re: hist_2d, contour [message #66572] |
Wed, 27 May 2009 05:58 |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
David Fanning writes:
> I don't know. I always use Scale_Vector for this:
>
> dist = Hist_2d(xdata, ydata...)
> s = Size(dist, /DIMENSIONS)
> x = Scale_Vector(Indgen(s[0]), Min(xdata), Max(xdata))
> y = Scale_Vector(Indgen(s[1]), Min(ydata), Max(ydata))
Yikes, should be "Findgen", not "Indgen"!
Cheers,
David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
|
|
|
Re: hist_2d, contour [message #66573 is a reply to message #66572] |
Wed, 27 May 2009 05:39  |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
Nicolas Aunai writes:
> so the help is wrong ? :-)
Not wrong so much as, well, let's just say a jokester.
I think it was written by a cousin of Coyote's. :-)
> last question :
>
> should I do :
>
> eci = MIN(ec(*,0)) + bin*lindgen(ceil((max(ec(*,0))-min(ec(*,0)))/bin))
>
> or
>
>
> eci = MIN(ec(*,0)) + bin*lindgen(1+(max(ec(*,0))-min(ec(*,0)))/bin)
I don't know. I always use Scale_Vector for this:
dist = Hist_2d(xdata, ydata...)
s = Size(dist, /DIMENSIONS)
x = Scale_Vector(Indgen(s[0]), Min(xdata), Max(xdata))
y = Scale_Vector(Indgen(s[1]), Min(ydata), Max(ydata))
Scale_Vector is a Coyote Library file.
Cheers,
David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
|
|
|
Re: hist_2d, contour [message #66574 is a reply to message #66573] |
Wed, 27 May 2009 05:13  |
Nicolas Aunai
Messages: 5 Registered: May 2009
|
Junior Member |
|
|
David Fanning wrote:
> Nicolas Aunai writes:
>
>> I have a problem trying to contour the return value of HIST_2D.
>> my code is the following :
>
> I think the first thing I would try would be setting
> the MIN and MAX keywords in HIST_2D. My experience with
> IDL is that when you let it decide what to do, unexpected
> results are the rule. :-)
>
> Cheers,
>
> David
OH !
the following code does what I want :
tstudy = 8.0
!p.multi = [0,1,1,0]
window,2,retain=2
bin = 0.05
eci = MIN(ec(*,0)) + bin*lindgen(1+(max(ec(*,0))-min(ec(*,0)))/bin)
ecf = MIN(ec(*,tstudy)) +
bin*lindgen(1+(max(ec(*,tstudy))-min(ec(*,tstudy)))/bin)
;distr = HIST_2D(ec(*,0) , ec(*,tstudy), bin1=bin, bin2=bin)
distr = HIST_2D(ec(*,0) , ec(*,tstudy), bin1=bin, bin2=bin,
min1=min(ec(*,0)), max1=max(ec(*,0)), min2=min(ec(*,tstudy)), $
max2=max(ec(*,tstudy)))
just like you said I have just set the min1,min2,max1,max2 values... to
what I thought were the DEFAULT values (this is what the help says...)
I get :
IDL> help,eci,ecf,distr
ECI FLOAT = Array[132]
ECF FLOAT = Array[135]
DISTR LONG = Array[132, 135]
while the previous code :
IDL> tstudy = 8.0
IDL> !p.multi = [0,1,1,0]
IDL> window,2,retain=2
IDL>
IDL> bin = 0.05
IDL> eci = MIN(ec(*,0)) + bin*lindgen(1+(max(ec(*,0))-min(ec(*,0)))/bin)
IDL> ecf = MIN(ec(*,tstudy)) +
bin*lindgen(1+(max(ec(*,tstudy))-min(ec(*,tstudy)))/bin)
IDL> distr = HIST_2D(ec(*,0) , ec(*,tstudy), bin1=bin, bin2=bin)
gives :
ECI FLOAT = Array[132]
ECF FLOAT = Array[135]
DISTR LONG = Array[132, 137]
so the help is wrong ? :-)
last question :
should I do :
eci = MIN(ec(*,0)) + bin*lindgen(ceil((max(ec(*,0))-min(ec(*,0)))/bin))
or
eci = MIN(ec(*,0)) + bin*lindgen(1+(max(ec(*,0))-min(ec(*,0)))/bin)
??
thx a lot for your help
|
|
|
Re: hist_2d, contour [message #66576 is a reply to message #66574] |
Wed, 27 May 2009 04:51  |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
Nicolas Aunai writes:
> I have a problem trying to contour the return value of HIST_2D.
> my code is the following :
I think the first thing I would try would be setting
the MIN and MAX keywords in HIST_2D. My experience with
IDL is that when you let it decide what to do, unexpected
results are the rule. :-)
Cheers,
David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
|
|
|