lezargus.library.container.functionality.convolution module

lezargus.library.container.functionality.convolution module#

Convolution functions specifically tailored to Lezargus containers.

We seperate the logic for containers into functions which make it a little easier to understand. Moreover, these functions can also be used separately. The logic is similar to Numpy’s functions like py:func:numpy.mean and numpy.ndarray.mean; and other modules in lezargus.library.container.functionality.

lezargus.library.container.functionality.convolution.convolve_cube_by_image_kernel(cube: hint.LezargusCube, kernel: hint.NDArray | None = None, kernel_stack: hint.NDArray | None = None, kernel_function: hint.Callable | None = None) hint.LezargusCube[source]#

Convolve the cube by an image kernel convolving image slices.

Convolving a spectral cube can either be done one of two ways; convolving by image slices or convolving by spectral slices. We here convolve by image slices.

Parameters:
  • cube (LezargusCube) – The cube we are convolving.

  • kernel (ndarray, default = None) – A static 2D image kernel. If provided, we use this static kernel to convolve the cube by. Exclusive with other kernel options.

  • kernel_stack (ndarray, default = None) – A variable 2D image kernel stack. If provided, we use the variable kernel stack to convolve the cube by. Exclusive with other kernel options.

  • kernel_function (Callable, default = None) – A dynamic 2D kernel function. If provided, we use the dynamic kernel function to convolve the cube by. Exclusive with other kernel options.

Returns:

convolved_cube – A near copy of the data cube after convolution.

Return type:

ndarray

lezargus.library.container.functionality.convolution.convolve_cube_by_spectral_kernel(cube: hint.LezargusCube, kernel: hint.NDArray | None = None, kernel_stack: hint.NDArray | None = None, kernel_function: hint.Callable | None = None) hint.LezargusCube[source]#

Convolve the cube by a spectral kernel convolving spectra slices.

Convolving a spectral cube can either be done one of two ways; convolving by image slices or convolving by spectral slices. We here convolve by spectral slices.

Parameters:
  • cube (LezargusCube) – The cube we are convolving.

  • kernel (ndarray, default = None) – A static 1D spectral kernel. If provided, we use this static kernel to convolve the cube by. Exclusive with other kernel options.

  • kernel_stack (ndarray, default = None) – A variable 1D spectral kernel stack. If provided, we use the variable kernel stack to convolve the cube by. Exclusive with other kernel options.

  • kernel_function (Callable, default = None) – A dynamic 1D kernel function. If provided, we use the dynamic kernel function to convolve the cube by. Exclusive with other kernel options.

Returns:

convolved_cube – A near copy of the data cube after convolution.

Return type:

ndarray

lezargus.library.container.functionality.convolution.convolve_spectrum_by_spectral_kernel(spectrum: hint.LezargusSpectrum, kernel: hint.NDArray | None = None, kernel_stack: hint.NDArray | None = None, kernel_function: hint.Callable | None = None) hint.LezargusSpectrum[source]#

Convolve the spectrum with a spectral kernel.

We compute the convolution and return a near copy of the spectrum after convolution. The wavelength is not affected.

As spectrum are 1D, there is no dimension to have a variable kernel, as variable kernels need a non-convolution axis to vary on. There can only be a static or dynamic kernel.

Parameters:
  • spectrum (LezargusCube) – The spectrum we are convolving.

  • kernel (ndarray, default = None) – A static 1D spectral kernel. If provided, we use this static kernel to convolve the spectrum by. Exclusive with other kernel options.

  • kernel_stack (ndarray, default = None) – A variable 1D spectral kernel stack. If provided, we use the variable kernel stack to convolve the spectrum by. Exclusive with other kernel options.

  • kernel_function (Callable, default = None) – A dynamic 1D kernel function. If provided, we use the dynamic kernel function to convolve the spectrum by. Exclusive with other kernel options.

Returns:

convolved_spectrum – A near copy of the spectrum after convolution.

Return type:

ndarray