hispecdrp.primitives.spectral_extraction.extract_box

Functions

_extract_box_numba(input_data, input_err, ...)

extract_spectrum_box(input_data, input_err, ...)

Box spectral extraction.

_extract_box_numba(input_data, input_err, input_dq, input_var_rnoise, input_var_poisson, input_mid_time, trace_positions, extraction_aperture, pix_range, spec_output, err_output, var_rnoise_output, var_poisson_output, dq_output, mid_time_output, orders_are_vertical=True)[source]
any_sc(arr)[source]

Optimized version of np.any which short circuits, unlike numpy.any.

extract_spectrum_box(input_data, input_err, input_dq, input_var_rnoise, input_var_poisson, input_mid_time, trace_positions, 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]

Box spectral extraction.

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.

  • input_mid_time (np.ndarray) – 2D array of input mid times for each pixel.

  • trace_positions (np.ndarray) – 2D array of y-coordinates for the extraction (order, ypos).

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

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

  • spec_output (np.ndarray) – 1D array to store extracted spectrum.

  • err_output (np.ndarray) – 1D array to store extracted errors.

  • var_rnoise_output (np.ndarray) – 1D array to store extracted read noise variance.

  • var_poisson_output (np.ndarray) – 1D array to store extracted Poisson noise variance.

  • dq_output (np.ndarray) – 1D array to store extracted data quality flags.

  • mid_time_output (np.ndarray) – 1D array to store extracted mid times.

  • 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_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.