function big_smooth_dfsr,data,width

;+
;NAME:
;       big_smooth
;SAMPLE CALLING SEQUENCE:
;       out = big_smooth_dfsr(data, 15)
;PURPOSE:
;	To permit "boxcar" smoothing of an vector or an 
;	image without producing the irritating
;	unsmoothed border at the boundaries.
;
;       This program forms an array bigger than the original
;       array by half of the smoothing width on each side and fills
;       the corners with valid average "near edge" data and then smooths
;       the extended array.  It then plucks out and array the size of
;       the original out of the smoothed big array.
;INPUT:
;       data = the 1-d or 2-d array to be smoothed
;	width = the number of pixels over which to smooth.
;OUTPUTS:
;       out = the smoothed array of same type as input array
;	    (Note:  Actual smoothing is done in floating point.)
;RESTRICTIONS:
;       Use only on a single array at a time, not a data cube.
;
;HISTORY:
;       Written by L. Acton on 2/22/94.
;	Corrected indexing errors, 2/23/94.  LWA
;	Changed to extend the image with average data,
;	  avoiding the "problem columns" at the edge.  LWA 3/20/94
;	Modified to handle 1-d smoothing.  LWA 3/20/94
;	Made from big_smooth for the purpose of sxt_diffuser2.pro.
;			LWA 4/29/94
;-


wid=width
array=reform(data)

siz=size(array)
x=siz(1)
y=siz(2)
xx=x-1
yy=y-1

w=wid/2
ww=wid/2+1

case 1 of
   (siz(0) eq 1) : begin  ; ONE DIMENSIONAL VECTOR
      big=fltarr(x+2*ww)
      sizb=size(big)
      xb=sizb(1)-1
      big(ww:ww+xx)=array
      for i=0,w do big(i)=total(float(array(0:0+w)))/ww
      for i=0,w do big(i+ww+xx)=total(float(array(xx-w:xx)))/ww
      smth_array=smooth(big,wid)
      out=smth_array(ww:ww+xx)
   end
   
   (siz(0) eq 2) : begin  ; TWO DIMENSIONAL IMAGE
;siz=size(array)
;x=siz(1)
;y=siz(2)
;xx=x-1
;yy=y-1
;w=wid/2
;ww=wid/2+1
      big=fltarr(x+2*ww,y+2*ww)
      sizb=size(big)
      xb=sizb(1)-1
      yb=sizb(2)-1

      ;  Put image in center of BIG
      big(ww:ww+xx,ww:ww+yy)=array
      ;  Extend LH side with an average value,
      ;   offset to avoid "problem columns" at edge of CCD.
      for i=0,w+2 do big(i,ww:ww+yy)=float(array(0,*))
      ;  Likewise, extend RH side
      for i=0,w+1 do big(i+ww+xx,ww:ww+yy)=float(array(xx,*))
      ;  Extend bottom
      for i=0,w+2 do big(ww:ww+xx,i)=float(array(*,1))
      ;  Extend top
      for i=0,w do big(ww:ww+xx,i+ww+yy+1)=float(array(*,yy))
      ;  Corners:  Lower left, Upper left, Upper right, Lower right
      big(0:w,0:w)=array(2:w+2,2:w+2)
      big(0:w,yb-w:yb)=array(2:w+2,yy-w:yy)
      big(xb-w:xb,yb-w:yb)=array(xx-w-1:xx-1,yy-w:yy)
      big(xb-w:xb,0:w)=array(xx-w-1:xx-1,2:w+2)

      smth_array=smooth(big,wid)
      out=smth_array(ww:ww+xx,ww:ww+yy)
   end
endcase

;  Set type of output to agree with input.
if (siz(0) eq 2) then ii=3 else ii=2
if (siz(ii) eq 1) then out=byte(out)
if (siz(ii) eq 2) then out=fix(out)
if (siz(ii) eq 3) then out=long(out)

return,out

end

