def testWarnings(self):
     """Test that approximateWcs raises a UserWarning when it cannot achieve desired tolerance"""
     radialTransform = afwGeom.makeRadialTransform([0, 2.0, 3.0])
     wcs = afwGeom.makeModifiedWcs(pixelTransform=radialTransform, wcs=self.tanWcs,
                                   modifyActualPixels=False)
     with self.assertRaises(UserWarning):
         approximateWcs(wcs=wcs, bbox=self.bbox, order=2)
Пример #2
0
 def testWarnings(self):
     """Test that approximateWcs raises a UserWarning when it cannot achieve desired tolerance"""
     radialTransform = afwGeom.makeRadialTransform([0, 2.0, 3.0])
     wcs = afwGeom.makeModifiedWcs(pixelTransform=radialTransform,
                                   wcs=self.tanWcs,
                                   modifyActualPixels=False)
     with self.assertRaises(UserWarning):
         approximateWcs(wcs=wcs, bbox=self.bbox, order=2)
Пример #3
0
    def doTest(self, name, transform, order=3, doPlot=False):
        """Add the specified distorting transform to a TAN WCS and fit it

        The resulting WCS pixelToSky method acts as follows:
            pixelToSky(transform.applyForward(pixels))
        """
        wcs = afwGeom.makeModifiedWcs(pixelTransform=transform,
                                      wcs=self.tanWcs,
                                      modifyActualPixels=False)

        fitWcs = approximateWcs(
            wcs=wcs,
            bbox=self.bbox,
            order=order,
        )

        if doPlot:
            self.plotWcs(wcs, fitWcs, self.bbox, transform)

        msg = "ERROR: %s failed with order %s" % (name, order)
        self.assertWcsAlmostEqualOverBBox(wcs,
                                          fitWcs,
                                          self.bbox,
                                          maxDiffSky=0.001 *
                                          afwGeom.arcseconds,
                                          maxDiffPix=0.02,
                                          msg=msg)
Пример #4
0
    def getTanSipWcs(self, order=3, skyToleranceArcSec=0.001, pixelTolerance=0.01):
        """
        Take an afw Detector and approximate its pixel-to-(Ra,Dec) transformation
        with a TAN-SIP WCs.

        Definition of the TAN-SIP WCS can be found in Shupe and Hook (2008)
        http://fits.gsfc.nasa.gov/registry/sip/SIP_distortion_v1_0.pdf

        @param order                The order of the SIP polynomials to be fit to the
                                    optical distortions [default: 3]
        @param skyToleranceArcSec   The maximum allowed error in the fitted world coordinates (in
                                    arcseconds).  [default: 0.001]
        @param pixelTolerance       The maximum allowed error in the fitted pixel coordinates.
                                    [default: 0.02]

        @returns tanSipWcs, an instantiation of lsst.afw.image's TanWcs class representing the WCS
                 of the detector with optical distortions parametrized by the SIP polynomials.
        """

        bbox = self._detector.getBBox()

        tanWcs = self.getTanWcs()

        mockExposure = afwImage.ExposureF(bbox.getMaxX(), bbox.getMaxY())
        mockExposure.setWcs(tanWcs)
        mockExposure.setDetector(self._detector)

        distortedWcs = afwImageUtils.getDistortedWcs(mockExposure.getInfo())

        tanSipWcs = measAstrom.approximateWcs(
                distortedWcs, bbox, order=order,
                skyTolerance=skyToleranceArcSec*afwGeom.arcseconds,
                pixelTolerance=pixelTolerance)

        return tanSipWcs
Пример #5
0
def tanSipWcsFromDetector(afwDetector, afwCamera, obs_metadata, epoch,
                          order=3,
                          skyToleranceArcSec=0.001,
                          pixelTolerance=0.01):
    """
    Take an afw Detector and approximate its pixel-to-(Ra,Dec) transformation
    with a TAN-SIP WCs.

    Definition of the TAN-SIP WCS can be found in Shupe and Hook (2008)
    http://fits.gsfc.nasa.gov/registry/sip/SIP_distortion_v1_0.pdf

    @param [in] afwDetector is an instantiation of afw.cameraGeom's Detector
    class which characterizes the detector for which you wish to return th
    WCS

    @param [in] afwCamera is an instantiation of afw.cameraGeom's Camera
    class which characterizes the camera containing afwDetector

    @param [in] obs_metadata is an instantiation of ObservationMetaData
    characterizing the telescope's current pointing

    @param [in] epoch is the epoch in Julian years of the equinox against
    which RA and Dec are measured

    @param [in] order is the order of the SIP polynomials to be fit to the
    optical distortions (default 3)

    @param [in] skyToleranceArcSec is the maximum allowed error in the fitted
    world coordinates (in arcseconds).  Default 0.001

    @param [in] pixelTolerance is the maximum allowed error in the fitted
    pixel coordinates.  Default 0.02

    @param [out] tanSipWcs is an instantiation of afw.image's TanWcs class
    representing the WCS of the detector with optical distortions parametrized
    by the SIP polynomials.
    """

    bbox = afwDetector.getBBox()

    tanWcs = tanWcsFromDetector(afwDetector, afwCamera, obs_metadata, epoch)

    mockExposure = afwImage.ExposureF(bbox.getMaxX(), bbox.getMaxY())
    mockExposure.setWcs(tanWcs)
    mockExposure.setDetector(afwDetector)

    distortedWcs = afwImageUtils.getDistortedWcs(mockExposure.getInfo())
    tanSipWcs = measAstrom.approximateWcs(distortedWcs, bbox,
                                          order=order,
                                          skyTolerance=skyToleranceArcSec*afwGeom.arcseconds,
                                          pixelTolerance=pixelTolerance)

    return tanSipWcs
    def doTest(self, name, xyTransform, order=3, doPlot=False):
        """Create a DistortedTanWcs from the specified transform and fit it
        """
        wcs = afwImage.DistortedTanWcs(self.tanWcs, xyTransform)

        fitWcs = approximateWcs(
            wcs = wcs,
            bbox = self.bbox,
            order=order,
        )

        if doPlot:
            self.plotWcs(wcs, fitWcs, self.bbox, xyTransform)

        msg = "ERROR: %s failed with order %s" % (name, order)
        self.assertWcsNearlyEqualOverBBox(wcs, fitWcs, self.bbox,
            maxDiffSky=0.001*afwGeom.arcseconds, maxDiffPix=0.02, msg=msg)
Пример #7
0
    def getTanSipWcs(self,
                     order=3,
                     skyToleranceArcSec=0.001,
                     pixelTolerance=0.01):
        """
        Take an afw Detector and approximate its pixel-to-(Ra,Dec) transformation
        with a TAN-SIP WCs.

        Definition of the TAN-SIP WCS can be found in Shupe and Hook (2008)
        http://fits.gsfc.nasa.gov/registry/sip/SIP_distortion_v1_0.pdf

        @param order                The order of the SIP polynomials to be fit to the
                                    optical distortions [default: 3]
        @param skyToleranceArcSec   The maximum allowed error in the fitted world coordinates (in
                                    arcseconds).  [default: 0.001]
        @param pixelTolerance       The maximum allowed error in the fitted pixel coordinates.
                                    [default: 0.02]

        @returns tanSipWcs, an instantiation of lsst.afw.image's TanWcs class representing the WCS
                 of the detector with optical distortions parametrized by the SIP polynomials.
        """

        bbox = self._detector.getBBox()

        tanWcs = self.getTanWcs()

        mockExposure = afwImage.ExposureF(bbox.getMaxX(), bbox.getMaxY())
        mockExposure.setWcs(tanWcs)
        mockExposure.setDetector(self._detector)

        distortedWcs = afwImageUtils.getDistortedWcs(mockExposure.getInfo())

        tanSipWcs = measAstrom.approximateWcs(distortedWcs,
                                              bbox,
                                              order=order,
                                              skyTolerance=skyToleranceArcSec *
                                              afwGeom.arcseconds,
                                              pixelTolerance=pixelTolerance)

        return tanSipWcs
Пример #8
0
    def doTest(self, name, xyTransform, order=3, doPlot=False):
        """Create a DistortedTanWcs from the specified transform and fit it
        """
        wcs = afwImage.DistortedTanWcs(self.tanWcs, xyTransform)

        fitWcs = approximateWcs(
            wcs=wcs,
            bbox=self.bbox,
            order=order,
        )

        if doPlot:
            self.plotWcs(wcs, fitWcs, self.bbox, xyTransform)

        msg = "ERROR: %s failed with order %s" % (name, order)
        self.assertWcsAlmostEqualOverBBox(wcs,
                                          fitWcs,
                                          self.bbox,
                                          maxDiffSky=0.001 *
                                          afwGeom.arcseconds,
                                          maxDiffPix=0.02,
                                          msg=msg)
    def doTest(self, name, transform, order=3, doPlot=False):
        """Add the specified distorting transform to a TAN WCS and fit it

        The resulting WCS pixelToSky method acts as follows:
            pixelToSky(transform.applyForward(pixels))
        """
        wcs = afwGeom.makeModifiedWcs(pixelTransform=transform,
                                      wcs=self.tanWcs,
                                      modifyActualPixels=False)

        fitWcs = approximateWcs(
            wcs=wcs,
            bbox=self.bbox,
            order=order,
        )

        if doPlot:
            self.plotWcs(wcs, fitWcs, self.bbox, transform)

        msg = "ERROR: %s failed with order %s" % (name, order)
        self.assertWcsAlmostEqualOverBBox(wcs, fitWcs, self.bbox,
                                          maxDiffSky=0.001*lsst.geom.arcseconds, maxDiffPix=0.02, msg=msg)
Пример #10
0
 def testWarnings(self):
     """Test that approximateWcs raises a UserWarning when it cannot achieve desired tolerance"""
     radialTransform = afwGeom.RadialXYTransform([0, 2.0, 3.0])
     wcs = afwImage.DistortedTanWcs(self.tanWcs, radialTransform)
     with self.assertRaises(UserWarning):
         approximateWcs(wcs=wcs, bbox=self.bbox, order=2)