Skip to content

Commit

Permalink
Added test for round-tripping non-persistable (ZPN) WCS
Browse files Browse the repository at this point in the history
Also added an info-level message when we use the FITS header not the table

N.b. this code would be rewritten to check if wcsId == 0, but that would break
the symmetry with the way that Jim reads the other entries such as the Psf
  • Loading branch information
RobertLuptonTheGood committed Jun 23, 2015
1 parent d573fed commit 8cda15e
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/image/ExposureInfo.cc
Original file line number Diff line number Diff line change
Expand Up @@ -257,11 +257,16 @@ void ExposureInfo::_readFits(
auto archiveWcs = archive.get<Wcs>(wcsId);
if (archiveWcs) {
_wcs = archiveWcs;
} else {
pex::logging::Log::getDefaultLog().info("Empty WCS extension, using FITS header");
}
} catch (pex::exceptions::NotFoundError & err) {
pex::logging::Log::getDefaultLog().warn(
boost::format("Could not read WCS; setting to null: %s") % err.what()
);
auto msg = str(boost::format("Could not read WCS extension; setting to null: %s") % err.what());
if (_wcs) {
msg += " ; using WCS from FITS header";
}

pex::logging::Log::getDefaultLog().warn(msg);
}
int coaddInputsId = popInt(*metadata, "COADD_INPUTS_ID");
try {
Expand Down
Binary file added tests/data/ZPN.fits
Binary file not shown.
14 changes: 14 additions & 0 deletions tests/testWcsFitsTable.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,20 @@ def testExposure(self):
wcsOut = expOut.getWcs()
self.assertEqual(wcsIn, wcsOut)

def testWcsWhenNonPersistable(self):
"""Test that we can round-trip a WCS even when it is not persistable"""
import os

fileName = os.path.join(os.path.split(__file__)[0], "data", "ZPN.fits")
exp = lsst.afw.image.ExposureF(fileName)
del fileName

self.assertFalse(exp.getWcs().isPersistable(), "Test assumes that ZPN projections are not persistable")

with utilsTests.getTempFilePath(".fits") as fileName:
exp.writeFits(fileName)
exp2 = lsst.afw.image.ExposureF(fileName)
self.assertEqual(exp.getWcs(), exp2.getWcs())
#####

def suite():
Expand Down

0 comments on commit 8cda15e

Please sign in to comment.