%N binfid %F $MIR/src/subs/zeebin.for
%D Adjust window size and fiddle bin sizes for spacial avg'ing
%P nebk
%: profile analysis
%B
      subroutine binfid (iwin, aveop, size, axis, bin, blc, trc, nbin)
      implicit none
      integer size, axis, bin, blc, trc, nbin, iwin
      character aveop*1

     Adjust the size of the window so that the bin width fits
     an integer number of times and fiddle the bin sizes for
     spatial averaging

     Input:
        iwin     i    Window number
        aveop    c   'a' or 's' for averaging or summing
        size     i    Size of axis in (unbinned) image
        axis     i    Axis number 
     Input/output:
        bin      i    Bin width.  On output, for averaging, equal to
                      the window size for spatial axes
        blc,trc  i    Window corners.
     Output:
        nbin     i    Number of binned pixels in window
