Re: HISTOGRAM data type bug? [message #71344 is a reply to message #71325] |
Mon, 14 June 2010 05:36   |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
FĂ–LDY Lajos writes:
> From the docs:
> ----------
> BINSIZE
> Set this keyword to the size of the bin to use. If this keyword is not
> specified, and NBINS is not set, then a bin size of 1 is used. If NBINS is
> set, the default is BINSIZE = (MAX - MIN) / (NBINS - 1).
>
> Note
> The data type of the value specified for BINSIZE should match the data
> type of the Array argument. Since BINSIZE is converted to the data type of
> Array, specifying mismatched data types may produce undesired results.
> ----------
>
> So, your BINSIZE is 0 (calculated as ULONG). This may cause a 'divide by
> zero' crash. I think IDL forgets to check BINSIZE.
Crashing is only the most extreme of the bad things
that can happen if you don't match the binsize
variable with the data type of the argument. If
you don't believe me, try writing a wrapper for
the Histogram command and make it available on a
public forum. Your phone will soon be ringing off
the hook with people facing inexplicably wrong
results. :-)
It seems to me this is something ITTVIS might be
able to fix, especially in such a high profile
routine like HISTOGRAM. It's pretty disconcerting
to read the Note above after you have spent five
maddening hours trying to figure out why your
program doesn't work.
In the meantime, you might find the Coyote Library
routine Convert_to_Type of interest. It was created
specifically to solve this problem.
http://www.dfanning.com/programs/convert_to_type.pro
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.")
|
|
|