The image::Wcs
and image::TanWcs
classes have gone away, replaced by geom::SkyWcs
. This was merged 2018-02-16 from ticket DM-10765.
The primary reason for this change is to support more flexible models of WCS models than those supported by FITS. This will eventually be used by jointcal to provide a superior fit WCS. From the beginning it will also be used to add an initial distortion model to the WCS in raw images that is derived from camera geometry.
The internals of SkyWcs are implemented using AST. via the astshim package. This will rarely be visible to users, but code that does sophisticated things with WCS will have to know something about it.
Primary Changes in afw
-
image::makeWcs(crval, crpix, cd1_1, cd1_2, cd2_1, cd2_2)
->geom::makeSkyWcs(crpix, crval, cd, projection="TAN")
, often withgeom::makeCdMatrix
to create the CD matrix. Note thatcrpix
andcrval
are swapped;crpix
is first because a WCS converts from pixels to sky in the forward direction in the contained transform. However, you may use named arguments in Python, and I have done so in all conversions. -
SkyWcs
is immutable. Thus any code that formerly modified Wcs in place now returns a new WCS, including:-
image::Wcs.flipImage
->geom::makeFlippedWcs
. I renamed it because I found the name confusing, especially since it is very different thanafwMath.flipImage
. -
image::Wcs.shiftReferencePixel
->geom::SkyWcs.copyAtShiftedPixelOrigin
. The name “pixel origin” matches the existing getPixelOrigin. -
image::Wcs.rotateImageBy90
is gone, since it is not used anywhere. However, it could easily be added as geom::makeRotatedWcs. (Note that free functionmath::rotateImageBy90
also exists and is used.)
-
-
SkyWcs
always works in ICRS coordinates with axis order RA, Dec. Images and exposures that use other coordinate systems or use Dec, RA axis order are normalized as they are read in. Note that use ofcoord::IcrsCoord
is temporary, since we plan to replace allCoord
classes withSkyCoord
.This may result in your code computing different sky positions now, especially if it used a wcs without paying attention its coordinate system. Even FK5 J2000 has small differences from ICRS. Always working in ICRS is much simpler and safer, especially since all of our reference catalogs have ICRS positions.
-
SkyWcs.pixelToSky
returnscoord::IcrsCoord
instead ofstd::shared_ptr<Coord>
-
SkyWcs
has no default constructor. -
Wcs.pixelScale()
->SkyWcs.getPixelScale()
to standardize the name -
Wcs.getCDMatrix()
->ScyWcs.getCdMatrix()
to standardize the name -
image::DistortedTanWcs(wcs, transform)
->geom::makeModifiedWcs(transform, wcs)
. Note the argument order change! This is to make the order clear, since the behavior is: newWcs.pixelsToSky = first transform in the forward direction, then apply oldWcs.pixelsToSky -
geom::XYTransformFromWcsPair(dest, src)
->geom::makeWcsPairTransform(src, dest)
; note that the arguments are swapped, in order to make code eaiser to read. The result (as before) is: src.pixelsToSky then dest.skyToPixels -
geom::warpImage(..., XYTransform srcToDest...)
is gone; usegeom::warpImage(..., TransformPoint2ToPoint2 srcToDest, ...)
instead. Warning: I swapped the direction of the transform in the pre-existingTransform
version in order to match theXYTransform
version because theXYTransform
version was much more widely used and its order seemed more natural.
Changes in ip_isr
-
IsrTask.addDistortionModel
is a new method which adds a distortion model to the WCS using transforms found in the camera and the Detector. -
IsrTask.run
has a new argument:camera
. This is needed byIsrTask.addDistortionModel
. -
IsrTaskConfig
has a new entry:doAddDistortionModel
which defaults to True. This allows IsrTask to apply a distortion model to the WCS. obs_decam changes the default to False because raw images have TPV terms and these presumably already model distortion. obs_sdss does not run the relevant code and continues to use the WCS as provided (though now normalized to ICRS RA, Dec).
Other Changes
-
The functions
lsst.afw.table.updateRefCentroids
andupdateSourceCoords
are now written in C++, for improved performance. Also the former now sets thehasCentroid
field. These functions are the recommended ways to apply a WCS to a reference catalog or source catalog. -
afw
no longer depends onwcslib
. -
Polygon
,Ellipse
andQuadrupole
are now available inlsst.afw.geom
; formerly they had to be imported fromlsst.afw.geom.ellipses
in order to avoid a circular import. Note other symbols fromlsst.afw.geom.ellipses
, such asAxes
, are not made available inlsst.afw.geom
because they are potentially ambiguous. -
You must manually
import lsst.afw.coord
in Python code in order to useSkyWcs.pixelToSky
. This nuisance will go away when theCoord
classes go away. -
WCS no longer uses
LTV1, LTV2
forXY0
; it now matches Image and MaskedImage in usingCRVAL1A, CRVAL2A
-
New pybind11 wrapper function for table persistable objects:
addPersistableMethods
; this replacesdeclarePersistableFacade
, which is now deprecated. Thanks to Jim Bosch for suggesting this.