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-25984: Investigate why the afw means of flat images are NANs for several amps of BOT data after DM-25934 #44

Merged
merged 7 commits into from Jul 22, 2020

Conversation

plazas
Copy link
Contributor

@plazas plazas commented Jul 20, 2020

No description provided.

Copy link
Collaborator

@mfisherlevine mfisherlevine left a comment

Choose a reason for hiding this comment

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

Looks good. More questions than requests for change, so take a look take a look and see what you think.

python/lsst/cp/pipe/ptc.py Show resolved Hide resolved
python/lsst/cp/pipe/ptc.py Show resolved Hide resolved
for ampNumber, amp in enumerate(detector):
ampName = amp.getName()
# covAstier: (i, j, var (cov[0,0]), cov, npix)
doRealSpace = self.config.covAstierRealSpace
muDiff, varDiff, covAstier = self.measureMeanVarCov(exp1, exp2, region=amp.getBBox(),
covAstierRealSpace=doRealSpace)
if np.isnan(muDiff) and np.isnan(varDiff) and np.isnan(covAstier):
Copy link
Collaborator

Choose a reason for hiding this comment

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

Are you OK with some but not all of these being NaN? Or do you want ors here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll put ors to report any NaN in the covariances too.

@RobertLuptonTheGood
Copy link
Member

Where are these NaNs coming from? There should be none in the input frames (because we interpolate them all), so it's because there are labelled as defects. We addressed this problem on PFS; please check with @PaulPrice

@craiglagegit
Copy link
Collaborator

craiglagegit commented Jul 21, 2020 via email

Comment on lines 286 to 287
self.flatExp1.image.array[20:30] = np.nan
self.flatExp2.image.array[20:30] = np.nan
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is weird, and perhaps not what you mean. This is a sensor-wide 10-pixel slice. Did you mean [20,30] instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed it to [20:30, :], thanks for the suggestion.

@@ -281,6 +281,44 @@ def test_meanVarMeasurement(self):
self.assertLess(self.flatWidth - np.sqrt(varDiff), 1)
self.assertLess(self.flatMean - mu, 1)

def test_meanVarMeasurementSomeNan(self):
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggest either test_meanVarMeasurementSomeNans or test_meanVarMeasurementWithNans

Copy link
Collaborator

Choose a reason for hiding this comment

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

(I prefer the latter)

Comment on lines 318 to 320
self.assertTrue(mu is np.nan)
self.assertTrue(varDiff is np.nan)
self.assertTrue(covDiff is np.nan)
Copy link
Collaborator

Choose a reason for hiding this comment

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

These lines don't actually work. You need self.assertTrue(np.isnan(mu)) etc here.

Comment on lines 291 to 309
expectedMu1 = np.nanmean(self.flatExp1.image.array)
expectedMu2 = np.nanmean(self.flatExp2.image.array)
expectedMu = 0.5*(expectedMu1 + expectedMu2)

# Now the variance of the difference. First, create the diff image.
im1 = self.flatExp1.maskedImage
im2 = self.flatExp2.maskedImage

temp = im2.clone()
temp *= expectedMu1
diffIm = im1.clone()
diffIm *= expectedMu2
diffIm -= temp
diffIm /= expectedMu

expectedVar = 0.5*np.nanvar(diffIm.image.array)

self.assertLess(np.sqrt(expectedVar) - np.sqrt(varDiff), 1)
self.assertLess(expectedMu - mu, 1)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could you just put a comment in the code for why these conditions are being tested for? Clearly it works, but would be nice to for the next person not to have to think it all through.

Comment on lines 318 to 320
self.assertTrue(mu is np.nan)
self.assertTrue(varDiff is np.nan)
self.assertTrue(covDiff is np.nan)
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think these should all be changed to self.assertTrue(np.isnan(mu)) etc because if those functions above returned float('nan') instead then this would fail, and that would be annoying and hard to debug.

@plazas plazas merged commit 5e0f401 into master Jul 22, 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

4 participants