hispecdrp.primitives.spectral_extraction.extract_spectroperfectionism
Full spectroperfectionism: sparse banded LS with HDF PSF deposit operator.
The forward operator matches _deposit_oversampled_psf_numba() (native
detector) followed by the sim orientation map used by Stage-1
(orders_are_vertical=True / _orient_hdf_pixel_xy()). Extraction
solves (Aᵀ N⁻¹ A) f = Aᵀ N⁻¹ d with SciPy sparse factorization.
Memory notes
HDF PSF stamps are large (~256×256 oversampled). Full-order assembly of
every stamp weight for all 4096 spectral samples can exceed 16 GB. Prefer:
pix_range=(lo, hi)for windowed extracts (readiness / fidelity),psf_rel_thresholdto crop near-zero stamp wings,a single process-wide HDF cache (see
e2e_pipeline.clear_hdf_model_cache).
Functions
|
Write oriented |
|
|
|
|
|
Crop a PSF stamp to the bounding box of significant flux. |
|
Deposit one scaled PSF into an oriented rate map (in-place). |
SP extract one echelle order using HDF PSF stamps + deposit-inverse WAVE. |
|
|
Banded weighted LS extract with HDF PSF deposit operator. |
|
Forward model |
- _emit_oriented_deposit_weights(out_row, out_col, out_val, psf, xc, yc, oversample, nx_native, abs_threshold)[source]
Write oriented
(row, col, weight)samples for one normalized PSF deposit.Skips
|psf| < abs_threshold. Returns the number of written entries. Capacity must be>=number of above-threshold samples × 4.
- _nearest_psf_index(psfw, lam)[source]
- _psf_oversample(block, pixelsize)[source]
- crop_psf_stamp(stamp, *, rel_threshold=0.01)[source]
Crop a PSF stamp to the bounding box of significant flux.
Returns
(cropped, dx_det, dy_det)where the detector-pixel offsets restore the original stamp-center →(xc, yc)deposit convention after the array shrinks (add toxc/ycbefore deposit).
- deposit_psf_to_oriented(det_oriented, psf, xc, yc, oversample, scale, nx_native)[source]
Deposit one scaled PSF into an oriented rate map (in-place).
- extract_order_spectroperfectionism_from_hdf(rate, rate_var, *, spectrograph, fiber, order, wave=None, spectral_bandwidth=None, pix_range=None, psf_rel_threshold=0.01, rate_dq=None)[source]
SP extract one echelle order using HDF PSF stamps + deposit-inverse WAVE.
- extract_spectrum_spectroperfectionism(rate, rate_var, wave, *, fx_native, fy_native, psfw, psf_stamps, oversample, nx_native, spectral_bandwidth=None, pix_range=None, psf_rel_threshold=0.01, rate_dq=None, do_not_use=1)[source]
Banded weighted LS extract with HDF PSF deposit operator.
rate/rate_varare oriented (spectral rows × cross-disp cols).- Parameters:
pix_range – Optional
(i0, i1)half-open spectral-row window to solve. Use this on 16 GB machines; full4096-pixel orders with256×256stamps can exhaust RAM.psf_rel_threshold – Crop each stamp to flux ≥ this fraction of the stamp peak before depositing (default
1e-2).
- forward_psf_deposit_oriented(spec, wave, *, fx_native, fy_native, psfw, psf_stamps, oversample, nx_native, det_shape=None, psf_rel_threshold=0.01)[source]
Forward model
M = A fvia direct oriented deposits.