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-11268: Detector: add crosstalk matrix #264

Merged
merged 1 commit into from Sep 6, 2017
Merged

Conversation

PaulPrice
Copy link
Contributor

Contains coefficients for intra-CCD crosstalk correction.

Copy link
Contributor

@parejkoj parejkoj left a comment

Choose a reason for hiding this comment

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

Primary comment is that there is no test for a non-bad crosstalk matrix.

@@ -45,6 +46,19 @@ class DetectorConfig(pexConfig.Config):
transposeDetector = pexConfig.Field(
"Transpose the pixel grid before orienting in focal plane?", bool)

crosstalk = pexConfig.ListField(
dtype=float,
doc=("Flattened crosstalk coefficient matrix; should have nAmps x nAmps entries. "
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't like that it has to be provided in flattened form. Is that really necessary?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes. We don't have a MatrixField in pex_config.

"""Return a 2-D numpy array of crosstalk coefficients of the proper shape"""
if not self.crosstalk:
return None
return np.array(self.crosstalk, dtype=np.float32).reshape((numAmps, numAmps))
Copy link
Contributor

Choose a reason for hiding this comment

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

Should you have a try:except here for if the user requests the wrong numAmps (wrong defined as "cannot be reshaped to that square")?

@@ -104,6 +106,9 @@ def __init__(self,
CameraSys(TAN_PIXELS, self.name): pixelToTanPixel,
CameraSys(ACTUAL_PIXELS, self.name): afwGeom.RadialXYTransform([0, 0.95, 0.01]),
}
if crosstalk is None:
crosstalk = [[0.0 for _ in range(numAmps)] for _ in range(numAmps)]
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't this be [0,0] (or maybe []) based on the logic in afw/cameraGeom/Detector.h:136? Otherwise, it looks like there is a crosstalk matrix that just happens to be all zero.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is a crosstalk matrix that is all zero. I could put other dummy values instead of zeros, but it wouldn't add anything to the test.

if (hasCrosstalk()) {
auto shape = _crosstalk.getShape();
assert(shape.size() == 2); // we've declared this as a 2D array
if (shape[0] != shape[1]) {
Copy link
Contributor

Choose a reason for hiding this comment

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

These all seem like good tests. 👍

@@ -91,6 +93,16 @@ def addBadCameraSys(dw):
with self.assertRaises(lsst.pex.exceptions.Exception):
DetectorWrapper(modFunc=addBadCameraSys)

# These break in the pybind layer
for crosstalk in ([1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0], # 1D and not numpy
Copy link
Contributor

Choose a reason for hiding this comment

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

You have failed crosstalk matrices, but are there tests for ok ones?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, the default in testUtils.py:110.

):
self.assertRaises(TypeError, DetectorWrapper, crosstalk=crosstalk)
# This breaks in the Detector ctor: wrong shape
self.assertRaises(lsst.pex.exceptions.InvalidParameterError,
Copy link
Contributor

Choose a reason for hiding this comment

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

Since there are two different throws in detector.cc, you should probably have one test for each of those conditions.

@PaulPrice
Copy link
Contributor Author

Changes made in response to review are on the fixup commit.

Contains coefficients for intra-CCD crosstalk correction.
@PaulPrice PaulPrice merged commit 492486d into master Sep 6, 2017
@ktlim ktlim deleted the tickets/DM-11268 branch August 25, 2018 06:43
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