Transform#
- final class lsst.images.Transform(in_frame, out_frame, ast_mapping, in_bounds=None, out_bounds=None, components=())#
Bases:
GenericA transform that maps two coordinate frames.
- Parameters:
in_frame (
TypeVar(I, bound=Frame)) – Input coordinate frame.out_frame (
TypeVar(O, bound=Frame)) – Output coordinate frame.ast_mapping (
Mapping) – AST mapping that implements the transform.in_bounds (
Bounds|None, default:None) – Bounds of the input frame, defaulting to the input frame’s bounding box.out_bounds (
Bounds|None, default:None) – Bounds of the output frame, defaulting to the output frame’s bounding box.components (
Iterable[Transform[Any,Any]], default:()) – Component transforms that this transform was composed from.
Notes
The
Transformclass constructor is considered a private implementation detail. Instead of using this, various factory methods are available:from_fits_wcsconstructs a transform from a FITS WCS, as representedastropy.wcs.WCS;thencomposes two transforms;identityconstructs a trivial transform that does nothing;affinecontructs an affine transform from a 2x2 or 3x3 matrix;invertedreturns the inverse of a transform;from_legacyconverts anlsst.afw.geom.Transforminstance.
When applied to celestial coordinate systems,
x=raandy=dec.SkyProjectionprovides a more natural interface for pixel-to-sky transforms.Transformis 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
Coordinate frame for input points.
Coordinate frame for output points.
Methods Summary
affine(in_frame, out_frame, matrix)Construct an affine transform from a matrix.
apply_forward([point, x, y])Apply the forward transform to one or more points.
apply_forward_q([point, x, y])Apply the forward transform to one or more unit-aware points.
apply_inverse([point, x, y])Apply the inverse transform to one or more points.
apply_inverse_q([point, x, y])Apply the inverse transform to one or more unit-aware points.
as_fits_wcs(bbox)Return a FITS WCS representation of this transform, if possible.
Deconstruct a composed transform into its constituent parts.
from_fits_wcs(fits_wcs, in_frame, out_frame)Construct a transform from a FITS WCS.
from_legacy(legacy, in_frame, out_frame[, ...])Construct a transform from a legacy
lsst.afw.geom.Transform.identity(frame)Construct a trivial transform that maps a frame to itelf.
inverted()Return the inverse of this transform.
serialize(archive, *[, use_frame_sets])Serialize a transform to an archive.
show([simplified, comments])Return the AST native representation of the transform.
then(next[, remember_components])Compose two transforms into another.
Convert to a legacy
lsst.afw.geom.TransformPoint2ToPoint2instance.Attributes Documentation
- in_frame#
Coordinate frame for input points.
- out_frame#
Coordinate frame for output points.
Methods Documentation
- static affine(in_frame, out_frame, matrix)#
Construct an affine transform from a matrix.
- Parameters:
in_frame (
TypeVar(I, bound=Frame)) – Coordinate frame for input points to the forward transform.out_frame (
TypeVar(O, bound=Frame)) – Coordinate frame for output points from the forward transform.matrix (
ndarray) – Matrix of coefficients, either a 2x2 linear transform or a 3x3 augmented affine transform, with a shift embedded in the third column and[0, 0, 1]the third row.
- Return type:
Transform[TypeVar(I, bound=Frame),TypeVar(O, bound=Frame)]
- apply_forward(point=None, /, *, x=None, y=None)#
Apply the forward transform to one or more points.
- Parameters:
point (
Union[XY[Any],YX[Any],None], default:None) – AnXYorYXcoordinate pair to transform. Mutually exclusive withxandy.x (
float| array-like) –xvalues of the points to transform, as a scalar or any array-like. Results are broadcast againsty. Mutually exclusive withpoint.y (
float| array-like) –yvalues of the points to transform, as a scalar or any array-like. Results are broadcast againstx. Mutually exclusive withpoint.
- Returns:
The transformed point or points. A scalar input pair returns
XYoffloat; array-like inputs returnXYofnumpy.ndarraywith the broadcast shape ofxandy.- Return type:
XY[float|numpy.ndarray]
- apply_forward_q(point=None, /, *, x=None, y=None)#
Apply the forward transform to one or more unit-aware points.
- Parameters:
point (
Union[XY[Quantity],YX[Quantity],None], default:None) – AnXYorYXcoordinate pair ofQuantityto transform. Mutually exclusive withxandy.x (
Any, default:None) –xvalues of the points to transform. Mutually exclusive withpoint.y (
Any, default:None) –yvalues of the points to transform. Mutually exclusive withpoint.
- Returns:
The transformed point or points.
- Return type:
- apply_inverse(point=None, /, *, x=None, y=None)#
Apply the inverse transform to one or more points.
- Parameters:
point (
Union[XY[Any],YX[Any],None], default:None) – AnXYorYXcoordinate pair to transform. Mutually exclusive withxandy.x (
float| array-like) –xvalues of the points to transform, as a scalar or any array-like. Results are broadcast againsty. Mutually exclusive withpoint.y (
float| array-like) –yvalues of the points to transform, as a scalar or any array-like. Results are broadcast againstx. Mutually exclusive withpoint.
- Returns:
The transformed point or points. A scalar input pair returns
XYoffloat; array-like inputs returnXYofnumpy.ndarraywith the broadcast shape ofxandy.- Return type:
XY[float|numpy.ndarray]
- apply_inverse_q(point=None, /, *, x=None, y=None)#
Apply the inverse transform to one or more unit-aware points.
- Parameters:
point (
Union[XY[Quantity],YX[Quantity],None], default:None) – AnXYorYXcoordinate pair ofQuantityto transform. Mutually exclusive withxandy.x (
Any, default:None) –xvalues of the points to transform. Mutually exclusive withpoint.y (
Any, default:None) –yvalues of the points to transform. Mutually exclusive withpoint.
- Returns:
The transformed point or points.
- Return type:
- as_fits_wcs(bbox)#
Return a FITS WCS representation of this transform, if possible.
- Parameters:
bbox (
Box) – Bounding box of the array the FITS WCS will describe. This transform object is assumed to work on the same coordinate system in whichbboxis 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).- Return type:
Notes
This method assumes the transform maps pixel coordinates to world coordinates.
Not all transforms can be represented exactly; when a FITS represention is not possible,
Noneis returned. When the returned WCS is notNone, it will have the same functional form, but it may not evaluate identically due to small implementation differences in the order of floating-point operations.
- decompose()#
Deconstruct a composed transform into its constituent parts.
Notes
Most transforms will just return a single-element list holding
self. Identity transform will return an empty list, and transforms composed withthenwill return the original transforms. Transforms constructed byFrameSetmay or may not be decomposable.
- static from_fits_wcs(fits_wcs, in_frame, out_frame, in_bounds=None, out_bounds=None, x0=0, y0=0)#
Construct a transform from a FITS WCS.
- Parameters:
fits_wcs (
WCS) – FITS WCS to convert.in_frame (
TypeVar(I, bound=Frame)) – Coordinate frame for input points to the forward transform.out_frame (
TypeVar(O, bound=Frame)) – Coordinate frame for output points from the forward transform.in_bounds (
Bounds|None, default:None) – The region that bounds valid input points.out_bounds (
Bounds|None, default:None) – The region that bounds valid output points.x0 (
int, default:0) – Logical coordinate of the first column in the array this WCS relates to world coordinates.y0 (
int, default:0) – Logical coordinate of the first column in the array this WCS relates to world coordinates.
- Return type:
Transform[TypeVar(I, bound=Frame),TypeVar(O, bound=Frame)]
Notes
The
x0andy0parameters 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). Thetypesin this package (e.g.Image,Mask) allow them to be any pair of integers.See also
- static from_legacy(legacy, in_frame, out_frame, in_bounds=None, out_bounds=None)#
Construct a transform from a legacy
lsst.afw.geom.Transform.- Parameters:
legacy (
lsst.afw.geom.Transform) – Legacy transform object.in_frame (
TypeVar(I, bound=Frame)) – Coordinate frame for input points to the forward transform.out_frame (
TypeVar(O, bound=Frame)) – Coordinate frame for output points from the forward transform.in_bounds (
Bounds|None, default:None) – The region that bounds valid input points.out_bounds (
Bounds|None, default:None) – The region that bounds valid output points.
- Return type:
Transform[TypeVar(I, bound=Frame),TypeVar(O, bound=Frame)]
- static identity(frame)#
Construct a trivial transform that maps a frame to itelf.
- inverted()#
Return the inverse of this transform.
- serialize(archive, *, use_frame_sets=False)#
Serialize a transform to an archive.
- Parameters:
archive (
OutputArchive[TypeVar(P, bound=BaseModel)]) – Archive to serialize to.use_frame_sets (
bool, default:False) – IfTrue, decompose the transform and try to reference component mappings that were already serialized into aFrameSetin the archive. Note that if multiple transforms exist between a pair of frames (e.g. aSkyProjectionand its FITS approximation), this may cause the wrong one to be saved. When this option is used, the frame set must be saved before the transform, and it must be deserialized before the transform as well.
- Returns:
Serialized form of the transform.
- Return type:
- show(simplified=False, comments=False)#
Return the AST native representation of the transform.
- Parameters:
simplified (
bool, default:False) – Whether to ask AST to simplify the mapping before showing it. This will make it much more likely that two equivalent transforms have the sameshowresult. If the internal mapping is actually a frame set (as needed to round-trip legacylsst.afw.geom.SkyWcsobjects), this will also just show the mapping with no frame set information.comments (
bool, default:False) – Whether to include descriptive comments.
- Return type:
- then(next, remember_components=True)#
Compose two transforms into another.
- to_legacy()#
Convert to a legacy
lsst.afw.geom.TransformPoint2ToPoint2instance.- Return type:
TypeAliasType