Projection#

final class lsst.images.Projection(pixel_to_sky: Transform[F, SkyFrame], fits_approximation: Transform[F, SkyFrame] | None = None)#

Bases: Generic

A transform from pixel coordinates to sky coordinates.

Parameters#

pixel_to_sky

A low-level transform that maps pixel coordinates to sky coordinates.

fits_approximation

An approximation to pixel_to_sky that is guaranteed to have a as_fits_wcs method that does not return None. This should not be provided if pixel_to_sky is itself representable as a FITS WCS.

Notes#

Transform is conceptually immutable (the internal AST Mapping should never be modified in-place after construction), and hence does not need to be copied when any object that holds it is copied.

Attributes Summary

fits_approximation

An approximation to this projection that is guaranteed to have an as_fits_wcs method that does not return None.

pixel_bounds

The region that bounds valid pixel points (Bounds | None).

pixel_frame

Coordinate frame for the pixel grid.

pixel_to_sky_transform

Low-level transform from pixel to sky coordinates (Transform).

sky_frame

Coordinate frame for the sky.

sky_to_pixel_transform

Low-level transform from sky to pixel coordinates (Transform).

Methods Summary

as_astropy([bbox])

Return an astropy.wcs view of this Projection.

as_fits_wcs(bbox[, allow_approximation])

Return a FITS WCS representation of this projection, if possible.

deserialize(model, archive)

Deserialize a projection from an archive.

from_fits_wcs(fits_wcs, pixel_frame[, ...])

Construct a transform from a FITS WCS.

from_legacy(sky_wcs, pixel_frame[, pixel_bounds])

Construct a transform from a legacy lsst.afw.geom.SkyWcs.

pixel_to_sky(*, x, y)

Transform one or more pixel points to sky coordinates.

serialize(archive, *[, use_frame_sets])

Serialize a projection to an archive.

show([simplified, comments])

Return the AST native representation of the transform.

sky_to_pixel(sky)

Transform one or more sky coordinates to pixels

to_legacy()

Convert to a legacy lsst.afw.geom.SkyWcs instance.

Attributes Documentation

fits_approximation#

An approximation to this projection that is guaranteed to have an as_fits_wcs method that does not return None.

pixel_bounds#

The region that bounds valid pixel points (Bounds | None).

pixel_frame#

Coordinate frame for the pixel grid.

pixel_to_sky_transform#

Low-level transform from pixel to sky coordinates (Transform).

sky_frame#

Coordinate frame for the sky.

sky_to_pixel_transform#

Low-level transform from sky to pixel coordinates (Transform).

Methods Documentation

as_astropy(bbox: Box | None = None) ProjectionAstropyView#

Return an astropy.wcs view of this Projection.

Parameters#

bbox

Bounding box of the array the view will describe. This projection object is assumed to work on the same coordinate system in which bbox is defined, while the Astropy view will consider the first row and column in that box to be (0, 0).

Notes#

This returns an object that satisfies the astropy.wcs.wcsapi.BaseHighLevelWCS and astropy.wcs.wcsapi.BaseLowLevelWCS interfaces while evaluating the underlying Projection itself. It is not an astropy.wcs.WCS instance, which is a type that also satisfies those interfaces but only supports FITS WCS representations (see as_fits_wcs).

as_fits_wcs(bbox: Box, allow_approximation: bool = False) WCS | None#

Return a FITS WCS representation of this projection, if possible.

Parameters#

bbox

Bounding box of the array the FITS WCS will describe. This transform object is assumed to work on the same coordinate system in which bbox is defined, while the FITS WCS will consider the first row and column in that box to be (0, 0) (in Astropy interfaces) or (1, 1) (in the FITS representation itself).

allow_approximation

If True and this Projection holds a FITS approximation to itself, return that approximation.

static deserialize(model: ProjectionSerializationModel[TypeVar], archive: InputArchive) Projection[Any]#

Deserialize a projection from an archive.

Parameters#

model

Seralized form of the projection.

archive

Archive to read from.

static from_fits_wcs(fits_wcs: WCS, pixel_frame: F, pixel_bounds: Bounds | None = None, x0: int = 0, y0: int = 0) Projection[F]#

Construct a transform from a FITS WCS.

Parameters#

fits_wcs

FITS WCS to convert.

pixel_frame

Coordinate frame for the pixel grid.

pixel_bounds

The region that bounds valid pixels for this transform.

x0

Logical coordinate of the first column in the array this WCS relates to world coordinates.

y0

Logical coordinate of the first column in the array this WCS relates to world coordinates.

Notes#

The x0 and y0 parameters reflect the fact that for FITS, the first row and column are always labeled (1, 1), while in Astropy and most other Python libraries, they are (0, 0). The types in this package (e.g. Image, Mask) allow them to be any pair of integers.

See Also#

Transform.from_fits_wcs

static from_legacy(sky_wcs: LegacySkyWcs, pixel_frame: F, pixel_bounds: Bounds | None = None) Projection[F]#

Construct a transform from a legacy lsst.afw.geom.SkyWcs.

Parameters#

sky_wcslsst.afw.geom.SkyWcs

Legacy WCS object.

pixel_frame

Coordinate frame for the pixel grid.

pixel_bounds

The region that bounds valid pixels for this transform.

pixel_to_sky(*, x: T, y: T) SkyCoord#

Transform one or more pixel points to sky coordinates.

Parameters#

xnumpy.ndarray | float

x values of the pixel points to transform.

ynumpy.ndarray | float

y values of the pixel points to transform.

Returns#

astropy.coordinates.SkyCoord

Transformed sky coordinates.

serialize(archive: OutputArchive, *, use_frame_sets: bool = False) ProjectionSerializationModel[TypeVar]#

Serialize a projection to an archive.

Parameters#

archive

Archive to serialize to.

use_frame_sets

If True, decompose the underlying transform and try to reference component mappings that were already serialized into a FrameSet in the archive. The FITS approximation transform is never decomposed.

Returns#

ProjectionSerializationModel

Serialized form of the projection.

show(simplified: bool = False, comments: bool = False) str#

Return the AST native representation of the transform.

Parameters#

simplified

Whether to ask AST to simplify the mapping before showing it. This will make it much more likely that two equivalent transforms have the same show result.

comments

Whether to include descriptive comments.

sky_to_pixel(sky: SkyCoord) XY[ndarray | float]#

Transform one or more sky coordinates to pixels

Parameters#

sky

Sky coordinates to transform.

Returns#

XY [numpy.ndarray | float]

Transformed pixel coordinates.

to_legacy() LegacySkyWcs#

Convert to a legacy lsst.afw.geom.SkyWcs instance.