get_c_matrix

jwst.extract_1d.soss_extract.atoca_utils.get_c_matrix(kernel, grid, i_bounds=None, thresh=1e-05)[source]

Return a convolution matrix.

Returns a sparse matrix (N_k_convolved, N_k). N_k is the length of the grid on which the convolution will be applied, N_k_convolved is the length of the grid after convolution and N_ker is the maximum length of the kernel. The convolution can be applied on an array f | f = fct(grid) by a simple matrix multiplication:

f_convolved = c_matrix.dot(f)
Parameters:
kernelndarray or callable

Convolution kernel. Can be already 2D (N_ker, N_k_convolved), giving the kernel for each items of the convolved grid. Can be a callable with the form f(x, x0) where x0 is the position of the center of the kernel. Must return a 1D array with len(x), i.e., a kernel value for each pair of (x, x0).

gridndarray

The 1D grid on which the convolution will be applied. For example, if C is the convolution matrix, f_convolved = C.f(grid).

i_bounds2-elements object, optional, default None

The bounds of the grid on which the convolution is defined. For example, if bounds = (a,b), then grid_convolved = grid[a <= grid <= b]. It dictates also the dimension of f_convolved. If None, the convolution is defined on the whole grid.

threshfloat, optional

Only used when kernel is callable to define the maximum length of the kernel. Truncate when kernel < thresh.

Returns:
c_matrixndarray

Convolution matrix in sparse form (N_k_convolved, N_k).