There is a short script that computes a histogram of the input data. data, dmin, dmax, bin are inputs and defined before calling the script; h, x, xmean are outputs.
I checked that histo.pro is in the right location..
Calling the script causes error (in idl85p):
IDL> .r histo.pro
IDL> histo, data, dmin, dmax, bin, h, x, xmean
% HISTO: Incorrect number of arguments.
% Execution halted at: $MAIN$
I would appreciate some help with it. Thanks
The script:
PRO histo, data, dmin, dmax, bin, h, x, xmean
on_error, 2
; compute histogram
h = histogram(float(data), BINSIZE = float(bin), MIN = float(dmin), $
MAX = float(dmax), REVERSE_INDICES = r)
; compute center of each bin
range = float(dmax - dmin) & nbin = long(range/bin) + 1
x = findgen(nbin) * bin + dmin + bin/2.
; compute mean data value for each bin
n_el = n_elements(h) & xmean = fltarr(n_el)
for n = 0L, n_el - 1 do begin
lo = r[n] & up = r[n+1] - 1
if lo lt up then $
xmean[n] = mean(data[r[lo:up]]) else xmean[n] = x[n]
endfor
return
end