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-13096: Add method to check whether values read from metadata are valid. #78

Merged
merged 2 commits into from
Dec 28, 2017
Merged
Changes from 1 commit
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
20 changes: 20 additions & 0 deletions python/lsst/obs/base/makeRawVisitInfo.py
Expand Up @@ -306,3 +306,23 @@ def pascalFromTorr(torr):
"""Convert pressure from torr to Pascals
"""
return torr*PascalPerTorr

@staticmethod
def defaultMetadata(value, defaultValue, minimum=None, maximum=None):
"""Check metadata for valid values against defaults.

@param[in] value metadata value returned by popItem, popFloat, or popAngle
@param[in] defaultValue default value to use if the metadata value is invalid
@param[in] minimum Minimum possible valid value, optional
@param[in] maximum Maximum possible valid value, optional
"""
if np.isnan(value):
retVal = defaultValue
else:
if minimum is not None:
if value < minimum:
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggest combining two if statements into a single one joined by and.

retVal = defaultValue
if maximum is not None:
if value > maximum:
retVal = defaultValue
return retVal