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-26260: ExposureFitsReader should not read the mask/variance if they are missing #536

Merged
merged 3 commits into from Aug 6, 2020

Conversation

timj
Copy link
Member

@timj timj commented Aug 5, 2020

If a compressed single image FITS file is read an attempt is made to read the mask and variance because additional extensions can be present. This will fail because they aren't really masks but on failing an assumption is made that the file
was registered with the reader. This is not set because nextHdu can return a null pointer. Therefore add protections such that we do not attempt to read the mask/variance if the fits file attribute is null.

@timj timj requested a review from TallJimbo August 5, 2020 21:51
LSST_EXCEPT_ADD(e, "Reading Mask");
throw e;
}
LOGL_WARN(_log, "Mask unreadable (%s); using default", e.what());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking at this code in isolation, it seems like it'd be appropriate to emit this warning when _maskReader._fitsFile is null, too. But in the higher-level context of the ticket, it seems we load Exposure or MaskedImage objects from single-plane FITS files all the the time, and don't want warnings when we do that, so maybe the right fix is to remove the warning from both code paths?

In any case, we should probably obey the needAllHdus logic when _maskFitsReader._fitsFile is null, and throw an exception. I don't think that's used very often (if at all), but it'd certainly be confusing to pass needAllHdus=True and then silently only get the image plane loaded.

If a compressed single image FITS file is read an attempt is made
to read the mask and variance because additional extensions
can be present.   This will fail because they aren't really
masks but on failing an assumption is made that the file
was registered with the reader. This is not set because
nextHdu can return a null pointer.  Therefore add
protections such that we do not attempt to read the
mask/variance if the fits file attribute is null.
@timj timj merged commit ac0d578 into master Aug 6, 2020
@timj timj deleted the tickets/DM-26260 branch August 6, 2020 18:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants