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-24703: Make linearity a subclass of lsst.ip.isr.IsrCalib #154

Merged
merged 4 commits into from Sep 9, 2020

Conversation

czwa
Copy link
Contributor

@czwa czwa commented Aug 26, 2020

This makes the linearity dataset a subclass of IsrCalib, which hopefully gives better code reuse and consistency between datasets.

@czwa czwa requested a review from plazas August 26, 2020 23:58

import lsst.afw.table as afwTable
from lsst.daf.base import PropertyList
from astropy.table import Table
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 moving away from afwTable in favor of astropy.Table?

Copy link
Member

Choose a reason for hiding this comment

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

Yes for tables that are all in python and not needed to be in C++. Astropy table is faster than afw table for this use case.

Copy link
Contributor

Choose a reason for hiding this comment

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

@timj, @ktlim — if that's official Architecture Team policy, can you please make sure it's captured in the Developer Guide? In particular, I think it directly contradicts the statement at https://developer.lsst.io/python/astropy.html that

If the code is already using afw it is strongly preferred that afw equivalents be used until such time as specific afw interfaces are deprecated

Copy link
Member

Choose a reason for hiding this comment

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

It was more a discovery by @czwa that he learned when he was writing these calibration tasks (which means Defects is slow at the moment and can be improved when it becomes a subclass of the new calibration base class). We haven't formally written that discovery down anywhere.

Copy link
Contributor

Choose a reason for hiding this comment

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

That's fine, but I think we do need to make sure that this is captured as part of appropriate policy. “Performance concerns” alone are not an adequate reason to ignore the Dev Guide.

Copy link
Member

Choose a reason for hiding this comment

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

I very much endorse the idea of making an exception to this rule for afw.table. But I think this is an easy case to make that call on, and writing a policy to cover all cases (including the role of pandas vs. afw.table for Source/Object catalogs) is a lot harder. I hope we can capture that action without blocking this ticket on it.

Copy link
Member

Choose a reason for hiding this comment

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

I hope we aren't considering blocking this ticket. The performance hit was pretty bad if I recall correctly.

Copy link
Contributor

Choose a reason for hiding this comment

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

This ticket doesn't seem to have anything to do with mitigating a performance hit; I don't really understand why that's coming up here.

However, I don't see any need to block this work, as long as the Architecture Team can reassure us that a) it doesn't actually contravene the Developer Guide, and b) they'll be updating the Developer Guide to provide appropriate guidance in future.

Copy link
Member

Choose a reason for hiding this comment

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

This code is bringing this class into compliance with the pre-existing IsrCalib which is the thing that required astropy tables for performance.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah; it's a shame we didn't take that opportunity to update the Dev Guide; good thing we caught it now! :-)

Coefficients to use in correction. Indexed by amplifier
names. The format of the array depends on the type of
correction to apply.
linearityType : `dict` [`str`, `str`]
Copy link
Contributor

Choose a reason for hiding this comment

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

Having this as a dictionary would imply that, in principle, each amp would have a different linearity type. But i don't think that's currently the case, correct?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Each amp can have a different linearity type, and the correction will apply whatever is defined. We currently don't have a way to measure different linearity types simultaneously in cp_pipe, but such a calibration could be constructed if necessary. This is largely a carryover from the cameraGeom defined linearity parameters, which were amplifier based.

correction to apply.
linearityType : `dict` [`str`, `str`]
Type of correction to use, indexed by amplifier names.
linearityBBox : `dict` [`str`, `lsst.geom.Box2I`]
Copy link
Contributor

Choose a reason for hiding this comment

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

What is the exact meaning of this bounding box? what are the regions where the correction is valid and where it is not? I'm a bit confused by the explanation n the docstring (sorry!)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Again, carryover from the cameraGeom definitions. The individual amplifiers have been assembled and trimmed so this is used to define the region to apply that amplifier's correction. This means that the correction can be run without passing a detector (which also defines the BBox). The alternative is to make linearizer.applyLinearity() require the detector argument.

Add detectorId as a valid parameter to IsrCalib.
The calibration fields used for equivalence were not set well.
Instead of passing text strings around, we should use a
camera/detector objects and grab the fields we care about in a single
way.  These are now parameters of the updateMetadata method, which
should now force all calibrations to have consistent field usage.

This also defines the CALIB_ID.
@czwa czwa merged commit 35c973c into master Sep 9, 2020
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

5 participants