0

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
  • Works for me. Are `data`, `dmin`, and `dmax` defined? Is `HISTO` in a file named 'histo.pro` in a directory that IDL will search? – mgalloy Aug 20 '18 at 20:54
  • Another thing to check is if there might be another program named histo.pro in your PATH, which takes a different number of arguments. If such a program exists, you may be unknowingly compiling and calling the wrong program. You can use `doc_library, 'histo'` to verify the full path of the compiled histo.pro. – Steve G Aug 21 '18 at 12:52

0 Answers0