hispecdrp.primitives.line_fitting.find_lines

Functions

_estimate_emission_spectrum_background(spec)

_nanmin_filter1d(data, width)

find_emission_lines(spec, spec_dq, ...[, ...])

Find the initial line positions using a peak finding algorithm followed by a centroid refinement (optional).

find_emission_lines(spec, spec_dq, min_line_spacing, background_filter_width=None, centroid_num_pixels=3, refine_with_centroid=True, drop_first_last=True, edge_margin_pix=15)[source]

Find the initial line positions using a peak finding algorithm followed by a centroid refinement (optional).

Parameters:
  • spec (np.ndarray) – The input spectrum.

  • spec_dq (np.ndarray) – The data quality mask for the spectrum (0=good).

  • min_line_spacing (int) – Minimum spacing between lines in pixels.

  • background_filter_width (int | None) – Number of pixels to use for background estimation. If None, no background subtraction is performed.

  • centroid_num_pixels (int) – Number of pixels to use for centroid refinement.

  • refine_with_centroid (bool) – Whether to refine the line positions using centroid calculation.

  • drop_first_last (bool) – Whether to drop the first / last detected peaks when they lie within edge_margin_pix of the array ends, where a line may be truncated by the array boundary. Interior first / last peaks are kept: dropping them by rank alone discards valid lines (e.g. the first comb mode of an echelle order, typically hundreds of pixels from the array edge) and needlessly shrinks the fitted range.

  • edge_margin_pix (int) – Distance from the array ends within which a first / last peak is considered possibly truncated. Default is 15 pixels (comparable to typical Gaussian fit windows).