Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DM-28583: Add method to get serialization version from on-disk Exposures. #566

Merged
merged 1 commit into from
Feb 18, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 6 additions & 0 deletions include/lsst/afw/image/ExposureFitsReader.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,12 @@ class ExposureFitsReader {
lsst::geom::Point2I readXY0(lsst::geom::Box2I const &bbox = lsst::geom::Box2I(),
ImageOrigin origin = PARENT);


/**
* Read the serialization version number from the header.
*/
int readSerializationVersion();

/**
* Read the flexible metadata associated with the Exposure.
*
Expand Down
1 change: 1 addition & 0 deletions python/lsst/afw/image/readers.cc
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,7 @@ void declareExposureFitsReader(lsst::utils::python::WrapperCollection &wrappers)
cls.def(py::init<fits::MemFileManager &>(), "manager"_a);
declareCommonMethods(cls);
declareMultiPlaneMethods(cls);
cls.def("readSerializationVersion", &ExposureFitsReader::readSerializationVersion);
cls.def("readMetadata", &ExposureFitsReader::readMetadata);
cls.def("readWcs", &ExposureFitsReader::readWcs);
cls.def("readFilter", &ExposureFitsReader::readFilter);
Expand Down
5 changes: 5 additions & 0 deletions src/image/ExposureFitsReader.cc
Original file line number Diff line number Diff line change
Expand Up @@ -493,6 +493,11 @@ lsst::geom::Point2I ExposureFitsReader::readXY0(lsst::geom::Box2I const& bbox, I
return _maskedImageReader.readXY0(bbox, origin);
}

int ExposureFitsReader::readSerializationVersion() {
_ensureReaders();
return _metadataReader->version;
}

std::string ExposureFitsReader::readImageDType() const { return _maskedImageReader.readImageDType(); }

std::string ExposureFitsReader::readMaskDType() const { return _maskedImageReader.readMaskDType(); }
Expand Down
1 change: 1 addition & 0 deletions tests/test_readers.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ def checkExposureFitsReader(self, exposureIn, fileName, dtypesOut):
reader = ExposureFitsReader(fileName)
self.assertIn('EXPINFO_V', reader.readMetadata().toDict(), "metadata is automatically versioned")
reader.readMetadata().remove('EXPINFO_V')
self.assertGreaterEqual(reader.readSerializationVersion(), 0)
self.assertEqual(exposureIn.getMetadata().toDict(), reader.readMetadata().toDict())
self.assertWcsAlmostEqualOverBBox(exposureIn.getWcs(), reader.readWcs(), self.bbox,
maxDiffPix=0, maxDiffSky=0*degrees)
Expand Down