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-22803: Only make a plot if there are data to plot #112

Merged
merged 1 commit into from
Jan 8, 2020
Merged
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
14 changes: 8 additions & 6 deletions python/lsst/validate/drp/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,9 @@ def plotAstrometryErrorModel(dataset, astromModel, outputPrefix=''):

ax[0].hist(dist, bins=100, color=color['all'],
Copy link
Contributor

Choose a reason for hiding this comment

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

Are we confident that dist will always be non-zero length, or is the statement that if dist is zero length we better except because we have bigger problems?

Copy link
Member Author

Choose a reason for hiding this comment

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

I hadn't really thought about the general case of someone passing in an empty dataset for plotting. Maybe it should raise a ValueError as soon as numMatched is calculated?

Copy link
Member Author

Choose a reason for hiding this comment

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

Or maybe you expect an empty plot? I'll merge this as is and worry about the other problem later.

histtype='stepfilled', orientation='horizontal')
ax[0].hist(dist[bright], bins=100, color=color['bright'],
histtype='stepfilled', orientation='horizontal')
if len(dist[bright]):
ax[0].hist(dist[bright], bins=100, color=color['bright'],
histtype='stepfilled', orientation='horizontal')

ax[0].set_ylim([0., 500.])
ax[0].set_ylabel("Distance [{unit:latex}]".format(unit=dist.unit))
Expand Down Expand Up @@ -307,10 +308,11 @@ def plotPhotometryErrorModel(dataset, photomModel,
ax[0][0].hist(mmagRms,
bins=100, range=(0, 500), color=color['all'],
histtype='stepfilled', orientation='horizontal')
ax[0][0].hist(mmagRmsHighSnr,
bins=100, range=(0, 500),
color=color['bright'],
histtype='stepfilled', orientation='horizontal')
if len(mmagRmsHighSnr):
ax[0][0].hist(mmagRmsHighSnr,
bins=100, range=(0, 500),
color=color['bright'],
histtype='stepfilled', orientation='horizontal')
plotOutlinedAxline(
ax[0][0].axhline,
mmagrms_median.value,
Expand Down