detect_trace¶
Detect the spectral trace on ctx.image and expose it on ctx.extras["trace"].
| Category | Extraction (2-D to 1-D) |
| Backend | scipy - implemented here on top of scipy primitives |
| Version | 1.0.1 |
| Reads | ctx.image (an ImageFrame) |
| Writes | extras.trace, metrics.trace_center_row, metrics.trace_fwhm_px, metrics.trace_snr |
Sibling of the trace step inside extract_spectrum_boxcar / extract_spectrum_optimal — but standalone, pure-numpy, and exposing the result on ctx.extras so the geometry and sky bricks (subtract_sky_2d, correct_smile_polynomial, correct_slant_affine) can resolve their hand-tuned row parameters from a measured value rather than a config file. Required at the head of an 'automatic' reduction preset; the manual mode that pre-fills row parameters from a config remains valid.
Parameters¶
| Parameter | Default | Required | Description |
|---|---|---|---|
method |
'argmax' |
- | Per-slice centroid method: 'argmax' (integer pixel) or 'centroid' (sub-pixel). |
poly_order |
2 |
- | Polynomial order of the fitted trace y(x). |
search_half_width |
40 |
- | Half-window (rows) around the global peak in which each slice searches for its local maximum. |
n_slices |
20 |
- | Number of column slices sampled across the dispersion axis. |
min_snr |
5.0 |
- | Minimum trace SNR (peak above background / off-trace std). The algorithm fails rather than silently writing a bad trace. |
output_key |
'trace' |
- | ctx.extras key that receives the trace dict. |
Use it¶
The CLI loads a single 1-D spectrum with --input; this algorithm needs
ctx.image (an ImageFrame). Run it from Python or as a step of a pipeline preset.
{
"tool": "detect_trace",
"arguments": {
"session_id": "<session_id>",
"params": {
"method": "argmax",
"poly_order": 2,
"search_half_width": 40,
"n_slices": 20,
"min_snr": 5.0,
"output_key": "trace"
}
}
}
Every algorithm is an MCP tool of the same name; describe_algorithm returns
this page's metadata as JSON.
References¶
- Tody 1986, Proc. SPIE 627, 733 — IRAF apall / aptrace heritage.
- scipy.signal.find_peaks — global peak of the collapsed spatial profile.
Related algorithms¶
extract_sky_lateral_bands- Median-combine two off-trace sky bands into a 1D pixel-axis reference.extract_spectrum_boxcar- Trace (easyspec) + pure-numpy aperture extraction onctx.image.extract_spectrum_easyspec- Trace and extract a 1D spectrum from a 2D frame via easyspec.extract_spectrum_optimal- Optimal (Horne 1986) aperture extraction ofctx.image.extract_spectrum_sum- Extract a 1D spectrum fromctx.imageby summing across the trace.