Trace Fitting

Trace Positions

This algorithm identifies echelle orders on the detector using high-SNR fiber flats. It assumes only one fiber is illuminated at a time and that orders are oriented approximately along the horizontal (x) axis.

The procedure is:

  1. Select a 1D vertical slice in the cross-dispersion (y) direction near the image center, applying additional smoothing.

  2. Crop the slice to the desired orders using the input yrange = (y_start, y_end).

  3. Identify integer peak locations in the slice using scipy.find_peaks, then refine them via centroiding.

  4. For each trace, step left (toward smaller x values) and compute the centroid position in each column; also compute the second moment.

  5. Repeat step 4 stepping right (toward larger x values).

  6. Fit polynomials to the trace positions and second moments as functions of x.

  7. Repeat steps 4-6 for all traces.

Documentation

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]

Trace Profiles

High SNR fiber flats are used to determine the trace profiles. Currently this algorithm simply converts the input fiber flat data into a TraceProfModel.

Documentation

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

Bases: BasePrimitive

Build the 2-D trace profile from fiberflat rate maps.

When an LFC rate map (and trace positions) are supplied, also measure spectroperfection moments: iso-λ shear and spectral/spatial 2nd moments.

Parameters:
  • lfc (DataModel or path or None) – Simulated or observed LFC L0 (2-D rate). Required for shear / LSF moments used by method='spectroperfection'.

  • tracepos (TracePosModel or path or None) – Trace positions for moment windows. Required with lfc.

  • extraction_aperture (float) – Cross-dispersion window for moment measurement.

  • orders (list[int] or None) – Restrict moment measurement to these echelle orders. None uses all.