def perform_2Dconvolution(cube,kernels,use_fftconvolution=False,verbose=True):
"""
Perform 2D convolution in data cube layer by layer
--- INPUT ---
cube Data cube to convolve
kernels List of (astropy) kernels to apply on each (z/wavelengt)layer of the cube
use_fftconvolution To convolve in FFT space set this keyword to True
verbose Toggle verbosity
--- EXAMPLE OF USE ---
# see tdose_utilities.gen_psfed_cube()
"""
csh = cube.shape
cube_convolved = np.zeros(csh)
for zz in xrange(csh[0]): # looping over wavelength layers of cube
layer = cube[zz,:,:]
if use_fftconvolution:
layer_convolved = ac.convolve_fft(layer, kernels[zz], boundary='fill')
else:
layer_convolved = ac.convolve(layer, kernels[zz], boundary='fill')
cube_convolved[zz,:,:] = layer_convolved
return cube_convolved
# = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
评论列表
文章目录