Skip to content
GSPICE

Getting started

What you get back

GSPICE returns read-only container objects whose array fields have explicit shapes and physical units. A value without a unit is a count, a mask, or a dimensionless ratio. In the shapes below, nspec is the number of spectra and npix is the number of pixels.

gspice.fit() returns a gspice.Model and a mask:

Python
model, clipped = gspice.fit(flux, ivar)

The mask clipped has the shape (nspec, npix). It is True at each pixel that fit left out of its final estimate. It is also True at every pixel of a spectrum that fit did not use.

A model has one mean and one covariance for each S/N bin. There is one bin unless you call fit(..., snr_bins=n). The mean and the covariance are in scaled units, not flux units. Continuum normalization explains the scaling.

FieldType and shapeHolds
meanarray (nbin, npix)The mean of each bin, in scaled units
covtuple of nbin arrays (npix, npix), or of LowRankThe covariance of each bin, in scaled units squared
n_traintuple of nbin integersThe number of training spectra of each bin
edgestuple of nbin − 1 floatsThe signal-to-noise ratios (S/N) between the bins
centerfloat or NoneThe constant center in flux units, or None for a mean-centered model
noiseboolTrue for a noise-aware model
weightedboolTrue if fit had unequal weights
blocksBlocks or NoneThe block thresholds of fit_blocks, or None without them

A noise-aware model, from fit(..., noise=True), has one bin. Its mean is in flux units, and its cov is the covariance of the flux without noise, in flux².

gspice.fit_blocks() returns a copy of the model whose blocks is a gspice.Blocks. gspice.repair() reads it.

FieldType and shapeHolds
startsarray of int64 (nblock,)The first pixel of each block
widthintThe number of pixels of each block
nguardintThe half-width of the guard window around each block, in pixels
thresholdsarray (nbin, nblock)The threshold of each bin and block

gspice.pixelwise() predicts each pixel from the pixels outside a guard window around it. It returns a gspice.Prediction.

FieldShapeHolds
flux(nspec, npix)The prediction of each pixel, in flux units
var(nspec, npix)Its variance, which includes the noise, in flux²
z(nspec, npix)The input flux minus the prediction, divided by √var; NaN at bad pixels

gspice.infill() and gspice.repair() return a gspice.Repaired. The replaced pixels hold their prediction. The ignored pixels are neither replaced nor used to predict the others.

FieldShapeHolds
flux(nspec, npix)The prediction at the replaced pixels, and the input flux elsewhere, in flux units
var(nspec, npix)In flux²: the variance of the prediction at the replaced pixels, which includes the noise; 1/ivar at the other good pixels; inf at the other bad pixels
replaced(nspec, npix), boolThe replaced pixels
ignored(nspec, npix), boolThe ignored pixels
chi2(nspec,)The χ² of the input values at the replaced pixels that are good in the input; 0 if there are none
dof(nspec,), int64The number of those pixels
fs(nspec,)The finite-sample factor of chi2
draws(nspec, npix), or NoneOne random draw at the replaced pixels, and the input flux elsewhere, in flux units
blocks(nspec, nblock), bool, or NoneThe blocks that repair flagged in each spectrum

Three fields depend on the call:

  • draws is None unless you pass rng, a numpy.random.Generator.
  • blocks is None for a result of infill, and of repair(..., blockwise=False).
  • Repaired.covariance(s) returns the replaced pixels of spectrum s and their covariance, in flux². It needs a call with covariance=True.