; $Id: scat_convolute.pro,v 1.1 2006/07/26 14:28:11 azuah Exp $
;###############################################################################
;
; NAME:
;  SCAT_CONVOLUTE
;
; PURPOSE:
;  Performs numerical convolution of two arrays.
;  Replacement for scat_convolve which only worked for data with equally
;  spaced x bins and with both the convolution kernel and the intrinsic 
;  function assumed to share the same x. This procedure makes use of 
;  of the convolute procedure which elliminates these restrictions.
;
; CATEGORY:
;  DAVE, Data Analysis, PAN, curve fitting
;
; AUTHOR:
;   Richard Tumanjong Azuah
;   NIST Center for Neutron Research
;   100 Bureau Drive
;   Gaithersburg, MD 20899
;   Jul, 2006
;
; LICENSE:
;  The software in this file is written by an employee of
;  National Institute of Standards and Technology
;  as part of the DAVE software project.
;
;  The DAVE software package is not subject to copyright protection
;  and is in the public domain. It should be considered as an
;  experimental neutron scattering data reduction, visualization, and
;  analysis system. As such, the authors assume no responsibility
;  whatsoever for its use, and make no guarantees, expressed or
;  implied, about its quality, reliability, or any other
;  characteristic. The use of certain trade names or commercial
;  products does not imply any endorsement of a particular product,
;  nor does it imply that the named product is necessarily the best
;  product for the stated purpose. We would appreciate acknowledgment
;  if the DAVE software is used of if the code in this file is
;  included in another product.
;
;###############################################################################
function scat_convolute, xFun, yFun, zFun, resStr
compile_opt idl2

ny = n_elements(yFun)
nx = n_elements(xFun)
xRes = resStr.x
zRes = resStr.z

fSize = size(zFun)
rSize = size(zRes)
if (fSize[0] ne 2 || rSize[0] ne 2) then return, 0

con = fltarr(nx,ny)
for i=0,ny-1 do $
   con[*,i] = convolute(xFun,zFun[*,i],xRes,zRes[*,i])

return, con

end
