Hide some pixels. The others predict them.
Survey spectra contain pixels that you cannot trust, such as cosmic rays, hot columns and pixels that the pipeline masked. GSPICE learns from your own spectra how the pixels vary together, and predicts any pixels from the others, with an uncertainty.
pip install pygspiceDrag the gray block, or drag its edges to resize it. With the plot focused, the arrow keys move the block, and Shift with an arrow key resizes it.
Pixels 50 to 69 masked (20). Mean σ 0.019. RMS error 0.003.
- observed flux
- prediction
- ±1σ
- ±2σ
- flux without noise
The prediction is that of gspice.infill with a model fitted to 4000 simulated spectra of 120 pixels. The ±1σ and ±2σ bands include the noise of the observed flux.
Predict the pixels that you mark, with a variance for each.
QuickstartFind artifacts in a surveyFind the pixels far from their prediction, then replace them.
Find and repair artifactsUnderstand the methodSee how a mean and a covariance predict any pixels from the others.
The modelFit, then fill
Section titled “Fit, then fill”Fit a model to training spectra, then predict the masked pixels of other spectra.
import gspice
model, clipped = gspice.fit(train.flux, train.ivar)result = gspice.infill(model, flux, ivar, mask=mask)result.flux # the input, with the masked pixels replacedresult.var # the variance of each pixelEach array has the shape (number of spectra, number of pixels). The Quickstart runs this code on simulated spectra.
How the pieces connect
Section titled “How the pieces connect”fit_blocksadds the block thresholds that repair needs.calibration,noise_auditcheck the uncertainties and the noise.save,loadwrite a model to a file and read it back.
pixelwise, infill and repair.Cite GSPICE
Section titled “Cite GSPICE”If you use GSPICE in your research, cite the paper by Finkbeiner, Speagle and Karim (Finkbeiner et al., 2025).