embed_spectrum¶
Compute a fixed-length, L2-normalised embedding of a spectrum.
| Category | Embeddings |
| Backend | scipy - implemented here on top of scipy primitives |
| Version | 1.2.1 |
| Reads | ctx.spectrum (a Spectrum1D) |
| Writes | embedding, extras.embedding_provenance, metrics.embedding_dim, metrics.embedding_norm |
The actual maths lives in spectro_kernel.embeddings so a downstream service can batch-embed thousands of spectra without paying the per-call audit-trail overhead — but go through this algorithm if you want the ProcessingStep + content-hash record alongside the vector. Older strategy names ('pca', 'autoencoder') still work but emit a DeprecationWarning. Non-finite samples (NaN/inf) make the brick fail cleanly: the recipes act on the sample index, so bad pixels cannot be dropped — interpolate or mask them first.
Parameters¶
| Parameter | Default | Required | Description |
|---|---|---|---|
dim |
256 |
- | Output vector length (positive integer). |
strategy |
'naive' |
- | Embedding recipe: one of ('naive', 'dct', 'multiscale_dct'). Older names 'pca' and 'autoencoder' are accepted as aliases with a DeprecationWarning. |
norm_method |
'min_max' |
- | Pre-embedding flux normalisation: one of ('none', 'min_max', 'z_score', 'continuum'). none skips normalisation (useful when the spectrum is already normalised by an upstream pipeline step). |
Use it¶
References¶
- Ahmed, Natarajan & Rao 1974, 'Discrete Cosine Transform', IEEE Trans. Computers, C-23, 90.
- Bu et al. 2014, ApJS, 211, 28 — z-score standardisation for spectra.
- Sharma et al. 2020, MNRAS, 491, 2280 — min-max rescaling of stellar spectra.
- Sanchez-Saez et al. 2021, AJ, 162, 206 — spectral representations for anomaly detection.
Related algorithms¶
embed_band_power- Embed a spectrum as the integrated flux in N adjacent wavelength bands.embed_continuum_subtracted- Subtract the polynomial continuum, then embed the line residual.embed_lick_indices- Embed a spectrum as the canonical Lick/IDS line-strength indices.embed_log_lambda- Resample to a uniform log-λ grid, then embed.embed_pretrained- Embed a spectrum with a local pre-trained PyTorch model.embed_remote- Embed a spectrum via a remote HTTPS inference endpoint.embed_wavelets- Embed a spectrum via a truncated discrete wavelet transform.