;*********************************************************************** ; This program creates the frequency distribution ;*********************************************************************** pro histogram_1d_ireg_bins,data,bins,data_freq,data_counts ;************************************************************************ ; INPUTS ;************************************************************************ ; Bins passed in ;bins ;************************************************************************ ; Determine if the bins are increasing or decreasing ;************************************************************************ if bins[1] gt bins[0] then xinc=1 if bins[1] lt bins[0] then xinc=-1 ;************************************************************************ ; Set up the 1D histogram array ;************************************************************************ data_counts=make_array(n_elements(bins),/float,value=0) ;************************************************************************ ; Build the 1D histogram ;************************************************************************ for j=0,n_elements(bins)-2 do begin if xinc eq 1 then begin result=where(data ge bins[j] and $ data lt bins[j+1],count) endif else if xinc eq -1 then begin result=where(data le bins[j] and $ data gt bins[j+1],count) endif data_counts[j]=count ;print,bins[j],bins[j+1],count ;if count gt 0 then print,data[result] endfor ;end of loop through bins ; Now calculate a frequency array data_freq=make_array(n_elements(bins),/float,value=0) if total(data_counts) gt 0 then $ data_freq=float(data_counts)/float(total(data_counts)) end