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-17956: Add option to output chi2 files at each outer fit iteration #127

Merged
merged 6 commits into from Apr 2, 2019

Conversation

parejkoj
Copy link
Collaborator

No description provided.

Copy link
Member

@TallJimbo TallJimbo left a comment

Choose a reason for hiding this comment

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

Sorry for the delay on the review. Only minor comments here, but after looking at this I do think the code would benefit overall from writing these out via afw.table (but not on this ticket). You'd have to rewrite the core C++ code that dumps the results, but then you could write them with the butler quite easily (I imagine you'd have a data ID with tract, filter, and iteration data ID keys, with the latter whatever it needs to be to disambiguate). You'd then be able to drop all of the custom code here to generate filenames and probably save a lot on storage.

FloatingPointError
Raised if chi2 is infinite or NaN.
ValueError
Raised if the model is not valid.
Copy link
Member

Choose a reason for hiding this comment

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

Seems like it'd be desirable to write the diagnostics even (especially) when one of these errors occurs.

@@ -182,6 +188,49 @@ def test_load_reference_catalog(self):
self.assertEqual(refCat, fakeRefCat)


class TestJointcalFitModel(JointcalTestBase, lsst.utils.tests.TestCase):
def test_fit_photometry_writeChi2(self):
Copy link
Member

Choose a reason for hiding this comment

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

Hate to pick on this, but this should be camelCase, right?

@@ -723,6 +723,7 @@ def _logChi2AndValidate(self, associations, fit, model, chi2Label="Model",
raise ValueError("Model is not valid: check log messages for warnings.")
if writeChi2Name is not None:
fit.saveChi2Contributions(writeChi2Name+"{type}")
self.log.info("Wrote chi2 contributions files: %s"%writeChi2Name)
Copy link
Member

Choose a reason for hiding this comment

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

If you use a comma instead of %, I think the logger will only do the string interpolation if the appropriate log level is enabled. Doesn't matter for this case, but it's a good habit to get into.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Thanks for the reminder. I'd forgotten about that.

Add logging of written chi2 filename, and log before exceptions are raised to
aid debugging.7
These are only called by the public `saveChi2Contributions`, which manages
the filenames appropriately.
No outliers are rejected in these steps, but they move very far in chi2-space
because they are purely linear (or very nearly so) in the fitted parameters.

Added some tests (using mocks) to check that the filename prefixes are
reasonable.
@parejkoj parejkoj merged commit 5a10bbc into master Apr 2, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants