hispecdrp.primitives.spectral_extraction.extract_cross_talk

Functions

_extract_cross_talk_numba(input_data, ...[, ...])

extract_spectra_cross_talk(input_data, ...)

Extract spectra for all fibers for a given order accounting for cross-talk between fibers.

get_design_matrix(trace_positions_x, ...[, ...])

Build the profile matrix P for cross-talk extraction.

solve_cross_talk(D, D_err, D_var_rnoise, ...)

_extract_cross_talk_numba(input_data, input_err, input_dq, input_var_rnoise, input_var_poisson, input_mid_time, trace_positions, profile, extraction_aperture, pix_range, spec_output, err_output, var_rnoise_output, var_poisson_output, dq_output, mid_time_output, orders_are_vertical=True)[source]
extract_spectra_cross_talk(input_data, input_err, input_dq, input_var_rnoise, input_var_poisson, input_mid_time, trace_positions, profile, extraction_aperture, pix_range=None, spec_output=None, err_output=None, var_rnoise_output=None, var_poisson_output=None, dq_output=None, mid_time_output=None, orders_are_vertical=True)[source]

Extract spectra for all fibers for a given order accounting for cross-talk between fibers.

Parameters:
  • input_data (np.ndarray) – 2D array of input data.

  • input_err (np.ndarray) – 2D array of input errors.

  • input_dq (np.ndarray) – 2D array of input data quality flags.

  • input_var_rnoise (np.ndarray) – 2D array of input read noise variance.

  • input_var_poisson (np.ndarray) – 2D array of input Poisson noise variance.

  • trace_positions (np.ndarray) – 2D array of trace positions for each fiber. Shape = (n_fibers, nx).

  • profile (np.ndarray) – 2D array of profiles for each fiber. Shape = (n_fibers, ny, nx).

  • extraction_aperture (float) – Width of the aperture to use for extraction.

  • pix_range (tuple) – Range of pixel-coordinates to extract (min, max) in the spectral direction. Defaults to the full range.

  • spec_output (np.ndarray) – 2D array to store extracted spectrum. Shape = (n_fibers, nx).

  • err_output (np.ndarray) – 2D array to store extracted errors. Shape = (n_fibers, nx).

  • var_rnoise_output (np.ndarray) – 2D array to store extracted read noise variance. Shape = (n_fibers, nx).

  • var_poisson_output (np.ndarray) – 2D array to store extracted Poisson noise variance. Shape = (n_fibers, nx).

  • dq_output (np.ndarray) – 2D array to store extracted data quality flags. Shape = (n_fibers, nx).

  • mid_time_output (np.ndarray) – 2D array to store extracted mid times. Shape = (n_fibers, nx).

  • orders_are_vertical (bool) – Whether the orders are oriented vertically.

Returns:

dict – Dictionary containing extracted flux, error, read noise variance for the box extracted spectrum.

get_design_matrix(trace_positions_x, profiles_x, extraction_aperture, orders_are_vertical=True)[source]

Build the profile matrix P for cross-talk extraction.

get_extraction_window(yc, window_size, n_pixels=-1)[source]

Computes the fractional overlap of pixels with the extraction window.

Parameters:
  • yc (float) – Center of the extraction window (in pixel coordinates).

  • window_size (float) – Size of the extraction window (in pixels) centered in yc.

  • n_pixels (int, optional) – When >= 0, clip candidate indices to [0, n_pixels - 1] so callers never receive out-of-bounds cross-dispersion indices (avoids Numba OOB segfaults when trace positions are extrapolated or non-finite).

Returns:
  • idx (np.ndarray) – Indices of the pixels that might have overlap with the extraction window.

  • W (np.ndarray) – Fractional overlap of each pixel in idx with the extraction window.

solve_cross_talk(D, D_err, D_var_rnoise, D_var_poisson, P, W, M)[source]