hispecdrp.primitives.trace_fitting.tracepos_primitive

Functions

_compute_centroid_and_width(pixels, ...)

Compute the centroid, width, and integrated flux of a trace slice.

_compute_centroid_and_width_2pass(pixels, ...)

Two-pass centroid: the first pass centers the window on center_loc (the anchor carried from the previous row), the second re-centers it on the first pass's centroid so the fractional edge weights are symmetric about the measured trace rather than about the anchor.

_walk_trace_up_down(pixels, data, dq, y0, ...)

find_trace_positions(data, dq, deg_pos, ...)

walk_trace_up_down(pixels, data, dq, disp0, ...)

Classes

TracePositionPrimitive([dataset, config, ...])

Calculate the trace positions for each fiber/order.

class TracePositionPrimitive(dataset=None, config=None, context=None, log_config=None, parent=None, **kwargs)[source]

Bases: BasePrimitive

Calculate the trace positions for each fiber/order.

Parameters:
  • input (DataModel, str, Sequence[DataModel or str], or dict) – Input data. Can be a single DataModel or filename, a sequence of DataModels or filenames, or a dict mapping fiber numbers to DataModels or filenames.

  • deg_pos (int) – Degree of polynomial to fit for trace position as a function of pixel.

  • deg_width (int) – Degree of polynomial to fit for trace width as a function of pixel.

  • window_size (int) – Size of window (in pixels) to use when computing centroids and widths.

  • xdisp_range (tuple or dict) – Range in the cross dispersion direction (in pixels) to restrict trace finding for the central slice. Can be a single tuple for all fibers or a dict mapping fiber numbers to tuples.

  • disp_range (tuple or dict) – Range in the dispersion direction (in pixels) to restrict trace finding. Can be a single tuple for all fibers or a dict mapping fiber numbers to tuples.

  • prominence_factor (float) – Initial peak-finding threshold as a fraction of the maximum cross-dispersion profile value (default 0.05). Lower values recover fainter echelle orders on high dynamic-range fiber flats.

  • min_flux_frac (float) – Per-order signal floor for the trace walker (default 0.05). Rows whose windowed flux falls below this fraction of the order’s peak windowed flux are dropped from the polynomial fit, so faint blaze ends and partially illuminated orders cannot pull the trace into unphysical curves.

Returns:

output (TracePosModel) – Output model containing fitted trace positions and widths for each fiber.

_create_preview()[source]