SplineField#

final class lsst.images.fields.SplineField(bounds: Bounds, data: ndarray, *, y: ndarray, x: ndarray, unit: UnitBase | None = None)#

Bases: BaseField

A 2-d Akima spline interpolation of data on a regular grid.

Parameters#

bounds

The region where this field can be evaluated.

data

The data points to be interpolated. Missing values (indicated by NaN) are allowed. Will be set to read-only in place.

y

Coordinates for the first dimension of data. Will be set to read-only in place.

x

Coordinates for the second dimension of data. Will be set to read-only in place.

unit

Units of the field.

Notes#

This field is much faster to evaluate on a grid via render than at arbitrary points via the function-call operator.

Attributes Summary

bounds

The region over which this field can be evaluated (Bounds).

data

The data points to be interpolated (numpy.ndarray).

unit

The units of the field (astropy.units.UnitBase or None).

x

Coordinates for the second dimension of data (numpy.ndarray).

y

Coordinates for the first dimension of data (numpy.ndarray).

Methods Summary

__call__(*, x, y[, quantity])

Call self as a function.

deserialize(model, archive)

Deserialize the spline field from an input archive.

evaluate(*, x, y[, quantity])

Evaluate at non-gridded points.

from_legacy_background(legacy_background[, unit])

Convert from a legacy lsst.afw.math.BackgroundMI instance.

multiply_constant(factor)

Multiply by a constant, returning a new field of the same type.

render([bbox, dtype])

Create an image realization of the field.

serialize(archive)

Serialize the spline field to an output archive.

Attributes Documentation

bounds#
data#

The data points to be interpolated (numpy.ndarray).

May have missing values indicated by NaNs.

unit#
x#

Coordinates for the second dimension of data (numpy.ndarray).

y#

Coordinates for the first dimension of data (numpy.ndarray).

Methods Documentation

__call__(*, x: ndarray, y: ndarray, quantity: bool = False) ndarray | Quantity#

Call self as a function.

static deserialize(model: SplineFieldSerializationModel, archive: InputArchive[Any]) SplineField#

Deserialize the spline field from an input archive.

evaluate(*, x: ndarray, y: ndarray, quantity: bool = False) ndarray | Quantity#

Evaluate at non-gridded points.

Parameters#

x

X coordinates to evaluate at.

y

Y coordinates to evaluate at; must be broadcast-compatible with x.

quantity

If True, return an astropy.units.Quantity instead of a numpy.ndarray. If unit is None, the returned object will be a dimensionless Quantity.

static from_legacy_background(legacy_background: LegacyBackground, unit: astropy.units.UnitBase | None = None) SplineField#

Convert from a legacy lsst.afw.math.BackgroundMI instance.

Notes#

SplineField.render and the lsst.afw background interpolator both use Akima splines, but with slightly different boundary conditions. They should produce equivalent to single-precision round-off error when evaluated within the region enclosed by bin centers (i.e. where no extrapolation is necessary) and when there are five or more points to be interpolated in each row and column.

multiply_constant(factor: float | Quantity | UnitBase) SplineField#

Multiply by a constant, returning a new field of the same type.

Parameters#

factor

Factor to multiply by. When this has units, those should multiply self.unit or set the units of the returned field if self.unit is None.

render(bbox: Box | None = None, *, dtype: type[Any] | dtype[Any] | _SupportsDType[dtype[Any]] | tuple[Any, Any] | list[Any] | _DTypeDict | str | None = None) Image#

Create an image realization of the field.

Parameters#

bbox

Bounding box of the image. If not provided, self.bounds.bbox will be used.

dtype

Pixel data type for the returned image.

serialize(archive: OutputArchive[Any]) SplineFieldSerializationModel#

Serialize the spline field to an output archive.