specsrbench.data¶
Loading the tuned cache: one object, loaded once, shared by every figure.
Each of the six notebooks opened the cache itself, with its own load()
helper and its own list of .npy names. The lists had to be kept in step by
hand, and the error message when one drifted was FileNotFoundError naming a
file that had simply been renamed.
Arrays load lazily and are held after first access, so building all six figures in one process reads the 267 MB cache once rather than six times.
Functions
|
The cache at |
Classes
|
The arrays every figure reads, from one directory. |
Exceptions
|
Raised with the command that regenerates what is missing. |
- class specsrbench.data.Cache(directory=None)[source]¶
Bases:
objectThe arrays every figure reads, from one directory.
- Parameters:
directory (Path | str | None)
- property sigma_pix: ndarray¶
The LSF the caches were actually deconvolved with, in pixels.
A copy of the derived kernel, written by the build so that nothing downstream has to infer which kernel produced the arrays beside it.
eval_set.npzships a differentsigma_pixthat does not describe the data; never read that one.
- property arrays: dict[str, ndarray]¶
Every method’s reconstruction, keyed by canonical name.
In the target’s normalised (per-spectrum z-scored) units, which is what makes the MAE columns comparable across spectra of wildly different brightness.
- property x_high_err: ndarray¶
Reference flux uncertainty, in the same normalised units as
x_high.Scaled by each spectrum’s own standard deviation, matching the z-score applied to the fluxes; the mean is not subtracted, because an uncertainty is a width and has no offset.
Invalid pixels arrive as NaN. They are marked in the raw product by a sentinel of 1.0 against fluxes of order 1e-21; left unmasked, that one value drives the mean normalised uncertainty to 3e18 instead of ~0.5. The masking happens at build time, and
tests/test_cache_integrity.pyasserts it here.
- x_high_err_floored()[source]¶
(errors, floor, mean)with a 1st-percentile floor applied.A handful of pixels carry an uncertainty of essentially zero, and dividing a residual by one of those produces an
infthat swallows the mean. The floor is the 1st percentile of the finite positive values, computed on this cache rather than hard-coded.