specsrbench.sample¶
The small tutorial dataset: 24 held-out spectra, fetched from the Hub.
The benchmark proper reads a 267 MB cache that this package does not ship and
most readers will never rebuild – it needs the raw JADES DR4 tree, the Hub
weights and a few CPU-hours. That is a poor first experience for someone who
has just run pip install specsrbench and wants to see what the thing does.
This module is the other end of that scale. One 1.9 MB archive, downloaded on
first use and cached by huggingface_hub thereafter, carrying everything the
benchmark needs on a small subset: the prism input, the grating reference, the
measured line-spread function, the SR2 prediction, and the tuned classical
parameters. Every classical baseline runs on it in seconds with no torch, no
survey data and no configuration.
What the numbers off it mean¶
24 galaxies, not 572. The ordering of the methods reproduces and so does the lesson – SR2 leads raw MAE by ~30% at 0.58 of the reference amplitude, and ranks last once that is corrected for – but the individual figures carry the error bar of a 24-spectrum sample and are not the paper’s. Quote the paper for the paper’s numbers.
The galaxies are the evaluation set sorted by redshift and sampled at evenly
spaced ranks, so they are held out by construction and span z = 0.31 to 13.86
rather than being chosen for how good they look. tests/test_tutorial_sample.py
checks that against the split.
Warning
sigma_pix here is the derived kernel, the one
specsrbench.classical.load_sigma_pix() returns. The evaluation set
ships a different array under that name which does not describe the data –
roughly constant in nanometres where a real spectrograph is fixed in
detector pixels, and up to 2.3x too broad at 5 um. Deconvolving with it
merges line pairs the input still resolves. Nothing in this archive carries
that array.
Module Attributes
Hub dataset repo holding the archive. |
|
|
Branch, tag or commit. |
The one file in it. |
Functions
|
The tutorial sample, downloading it from the Hub on first use. |
|
Local path to the archive, downloading it if necessary. |
Classes
|
24 held-out spectra and everything needed to benchmark against them. |
- class specsrbench.sample.Sample(path)[source]¶
Bases:
object24 held-out spectra and everything needed to benchmark against them.
Attributes mirror
specsrbench.data.Cachewhere they mean the same thing, so code written against one mostly reads on the other.- Parameters:
path (Path | str)
- property mf_lines: ndarray¶
Rest wavelengths the matched filter places templates at, in microns.
Carried here so the matched filter runs without
specsr, which owns the line list and pulls in torch.
- property x_low: ndarray¶
The prism input, cubic-interpolated onto the high-resolution grid.
This is both the input every deconvolver takes and the no-deconvolution baseline every one of them has to beat.
- property x_high_err: ndarray¶
Reference flux uncertainty, normalised like
x_high; NaN where invalid.
- property tuned: dict¶
Just the per-method parameter blocks, keyed as
reconstruct()expects.
- reconstruct(methods=None)[source]¶
Run the classical baselines at the tuned parameters.
Returns
{display name: array}including the two reconstructions that need no work –"Cubic (LR)", the prism input, and"ML (SR2)", the precomputed prediction – so the result is the full comparison table rather than only the part that had to be computed.Takes a few seconds for all six on 24 spectra.
- specsrbench.sample.load_sample(path=None, *, repo_id=None, revision=None)[source]¶
The tutorial sample, downloading it from the Hub on first use.
- specsrbench.sample.sample_path(repo_id=None, revision=None)[source]¶
Local path to the archive, downloading it if necessary.
SPECSRBENCH_SAMPLEpoints at a local.npzand wins outright: no network, no Hub account, and the way to work against a rebuilt sample before it is published.
- specsrbench.sample.DEFAULT_REPO = 'aryana-haghjoo/specsr-benchmark'¶
Hub dataset repo holding the archive. Override with
SPECSRBENCH_SAMPLE_REPO.
- specsrbench.sample.FILENAME = 'specsrbench_sample.npz'¶
The one file in it.