Skip to content
GSPICE

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.

Shell
pip install pygspice

Drag 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.

0.20.40.60.81.00306090120
Spectrum 1 of 8

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.

Fit a model to training spectra, then predict the masked pixels of other spectra.

Python
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 replaced
result.var # the variance of each pixel

Each array has the shape (number of spectra, number of pixels). The Quickstart runs this code on simulated spectra.

Boxes are objects, and the names on the arrows are functions. The spectra to predict also go into pixelwise, infill and repair.

If you use GSPICE in your research, cite the paper by Finkbeiner, Speagle and Karim (Finkbeiner et al., 2025).