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-25711: Compare the gains produced by FULLCOVARIANCE in the PTC task (DM-20070) and with the pre-existing options EXPAPPROXIMATION and POLYNOMIAL #43

Merged
merged 15 commits into from Aug 18, 2020

Conversation

plazas
Copy link
Contributor

@plazas plazas commented Jul 15, 2020

No description provided.

@plazas plazas requested a review from czwa July 15, 2020 13:22
Copy link
Contributor

@czwa czwa left a comment

Choose a reason for hiding this comment

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

Typos and variable name clarification.

@@ -543,9 +542,12 @@ def fitFullModel(self, pInit=None, nSigma=5):
covariances calculation, and the extra "1" is the gain.
If "b" is 0, then "c" is 0, and len(pInit) will have r^2 fewer entries.

nSigma : `int`
nSigma : `int`, optional
Copy link
Contributor

Choose a reason for hiding this comment

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

This should be float, I think.

covariance /= mu
model /= mu
weights *= mu

return mu, covariance, model, weights
return mu, covariance, model, weights, mask
Copy link
Contributor

Choose a reason for hiding this comment

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

The mask isn't in the "Returns" docstring block.

meanVecFinal, varVecFinal, varVecModel, wc = fit.getNormalizedFitData(0, 0)
meanVecFinalCov01, varVecFinalCov01, varVecModelCov01, wcCov01 = fit.getNormalizedFitData(0, 1)
meanVecFinalCov10, varVecFinalCov10, varVecModelCov10, wcCov10 = fit.getNormalizedFitData(1, 0)
meanVecOriginal, varVecOriginal, varVecModelOriginal, wc, varMask = fit.getFitData(0, 0)
Copy link
Contributor

Choose a reason for hiding this comment

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

Can wc be renamed something more descriptive? And below in ptc.py.

I'm also not clear what the difference between Original and Final is. Original is the raw measured mean/variances, and Final is the same thing, but masked based on the weights? If I'm following the code correctly, the only time the weight is non-zero is when the mean*g > maxElectrons? No, that's not true, because setMaxMuElectrons is never called. It's the points excluded via the tophat iteratively-reweighted least squares in fitFullModel.

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, "original" is "unmasked". The mask is based on the weights in getFitData , which in turn come from self.sqrtW. And this one is set in fitFullModel as you say.

Copy link
Contributor

@czwa czwa left a comment

Choose a reason for hiding this comment

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

This task will still likely need future refactoring to make it more direct, but that's probably a general case of cp_pipe code.

def getNormalizedFitData(self, i, j, divideByMu=False):
"""Get measured signal and covariance, cov model and wigths
def getFitData(self, i, j, divideByMu=False, unitsElectrons=False, returnMasked=False):
"""Get measured signal and covariance, cov model, weigths, and mask.
Copy link
Contributor

Choose a reason for hiding this comment

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

Typo weights

for amp in self.ampNames:
self.assertAlmostEqual(localDataset.gain[amp], 0.75, places=2)
for v1, v2 in zip(varStandard[amp], localDataset.finalVars[amp][0]):
self.assertAlmostEqual(v1/v2, 1.0, places=4)
v2 *= (0.75**2) # convert to electrons
self.assertAlmostEqual(v1/v2, 1.0, places=1)
Copy link
Contributor

Choose a reason for hiding this comment

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

One digit isn't a very strong test. We'll probably want to revisit that in the future to see if there's an underlying difference to be concerned about.

@plazas plazas merged commit ea2affd into master Aug 18, 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

2 participants