def testPersistence(self):
     im = ExposureF(10, 10)
     im.setPsf(self.psf)
     self.assertEqual(im.getPsf(), self.psf)
     with lsst.utils.tests.getTempFilePath(".fits") as tmpFile:
         im.writeFits(tmpFile)
         newIm = ExposureF(tmpFile)
         self.assertEqual(newIm.getPsf(), im.getPsf())
Пример #2
0
 def testPersistence(self):
     for pgp in self.pgps:
         assert cppLib.isPersistable(pgp)
         im = ExposureF(10, 10)
         im.setPsf(pgp)
         self.assertEqual(im.getPsf(), pgp)
         with lsst.utils.tests.getTempFilePath(".fits") as tmpFile:
             im.writeFits(tmpFile)
             newIm = ExposureF(tmpFile)
             self.assertEqual(newIm.getPsf(), im.getPsf())
Пример #3
0
    def testPersistence(self):
        """Test persisting an exposure with an attached Blob.
        """
        im = ExposureF(10, 10)
        # Extra components must be ALL CAPS for fits storage.
        im.getInfo().setComponent("BLOB", self.blob)
        with lsst.utils.tests.getTempFilePath(".fits") as tmpFile:
            im.writeFits(tmpFile)

            newIm = ExposureF(tmpFile)
            self.assertEqual(newIm.getInfo().getComponent("BLOB"), self.blob)

            reader = ExposureFitsReader(tmpFile)
            newBlob = reader.readComponent("BLOB")
            self.assertEqual(newBlob, self.blob)
Пример #4
0
    def test31035(self):
        """Test that illegal values in the header can be round-tripped."""
        with lsst.utils.tests.getTempFilePath(".fits") as fileName:
            exp = ExposureF(width=100, height=100)
            md = exp.getMetadata()
            md['BORE-RA'] = 'NaN'
            md['BORE-DEC'] = 'NaN'
            md['BORE-AZ'] = 'NaN'
            md['BORE-ALT'] = 'NaN'
            md['BORE-AIRMASS'] = 'NaN'
            md['BORE-ROTANG'] = 'NaN'
            md['OBS-LONG'] = 'NaN'
            md['OBS-LAT'] = 'NaN'
            md['OBS-ELEV'] = 'NaN'
            md['AIRTEMP'] = 'NaN'
            md['AIRPRESS'] = 'NaN'
            md['HUMIDITY'] = 'NaN'

            exp.writeFits(fileName)

            _ = ExposureF.readFits(fileName)
Пример #5
0
    def checkPersistence(self, skyWcs, bbox):
        """Check persistence of a SkyWcs
        """
        className = "SkyWcs"

        # check writeString and readString
        skyWcsStr = skyWcs.writeString()
        serialVersion, serialClassName, serialRest = skyWcsStr.split(" ", 2)
        self.assertEqual(int(serialVersion), 1)
        self.assertEqual(serialClassName, className)
        badStr1 = " ".join(["2", serialClassName, serialRest])
        with self.assertRaises(lsst.pex.exceptions.TypeError):
            skyWcs.readString(badStr1)
        badClassName = "x" + serialClassName
        badStr2 = " ".join(["1", badClassName, serialRest])
        with self.assertRaises(lsst.pex.exceptions.TypeError):
            skyWcs.readString(badStr2)
        skyWcsFromStr1 = skyWcs.readString(skyWcsStr)
        self.assertEqual(skyWcs, skyWcsFromStr1)
        self.assertEqual(type(skyWcs), type(skyWcsFromStr1))
        self.assertEqual(skyWcs.getFrameDict(), skyWcsFromStr1.getFrameDict())

        pixelPoints = [
            Point2D(0, 0),
            Point2D(1000, 0),
            Point2D(0, 1000),
            Point2D(-50, -50),
        ]
        skyPoints = skyWcs.pixelToSky(pixelPoints)
        pixelPoints2 = skyWcs.skyToPixel(skyPoints)
        assert_allclose(pixelPoints, pixelPoints2, atol=1e-7)

        # check that WCS is properly saved as part of an exposure FITS file
        exposure = ExposureF(100, 100, skyWcs)
        with lsst.utils.tests.getTempFilePath(".fits") as outFile:
            exposure.writeFits(outFile)
            exposureRoundTrip = ExposureF(outFile)
        wcsFromExposure = exposureRoundTrip.getWcs()
        self.assertWcsAlmostEqualOverBBox(skyWcs, wcsFromExposure, bbox)