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_kis the length of the grid on which the convolution will be applied,N_k_convolvedis the length of the grid after convolution andN_keris the maximum length of the kernel. The convolution can be applied on an arrayf | 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 formf(x, x0)wherex0is the position of the center of the kernel. Must return a 1D array withlen(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
Cis 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), thengrid_convolved = grid[a <= grid <= b]. It dictates also the dimension off_convolved. If None, the convolution is defined on the whole grid.- threshfloat, optional
Only used when
kernelis callable to define the maximum length of the kernel. Truncate whenkernel < thresh.
- Returns:
- c_matrixndarray
Convolution matrix in sparse form
(N_k_convolved, N_k).