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-37911: Add nData to measRecord #277

Merged
merged 1 commit into from
Sep 11, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions python/lsst/ip/diffim/dipoleFitTask.py
Original file line number Diff line number Diff line change
Expand Up @@ -860,7 +860,8 @@ def fitDipole(self, source, tol=1e-7, rel_weight=0.1,
negCentroidX=np.nan, negCentroidY=np.nan,
posFlux=np.nan, negFlux=np.nan, posFluxErr=np.nan, negFluxErr=np.nan,
centroidX=np.nan, centroidY=np.nan, orientation=np.nan,
signalToNoise=np.nan, chi2=np.nan, redChi2=np.nan)
signalToNoise=np.nan, chi2=np.nan, redChi2=np.nan,
nData=np.nan)
return out, fitResult

centroid = ((fitParams['xcenPos'] + fitParams['xcenNeg']) / 2.,
Expand Down Expand Up @@ -896,7 +897,8 @@ def computeSumVariance(exposure, footprint):
negCentroidX=fitParams['xcenNeg'], negCentroidY=fitParams['ycenNeg'],
posFlux=fluxVal, negFlux=-fluxValNeg, posFluxErr=fluxErr, negFluxErr=fluxErrNeg,
centroidX=centroid[0], centroidY=centroid[1], orientation=angle,
signalToNoise=signalToNoise, chi2=fitResult.chisqr, redChi2=fitResult.redchi)
signalToNoise=signalToNoise, chi2=fitResult.chisqr, redChi2=fitResult.redchi,
nData=fitResult.ndata)

# fitResult may be returned for debugging
return out, fitResult
Expand Down Expand Up @@ -1047,7 +1049,11 @@ def _setupSchema(self, config, name, schema, metadata):

self.chi2dofKey = schema.addField(
schema.join(name, "chi2dof"), type=float,
doc="Chi2 per degree of freedom of dipole fit")
doc="Chi2 per degree of freedom (chi2/(nData-nVariables)) of dipole fit")

self.nDataKey = schema.addField(
schema.join(name, "nData"), type=np.int64,
doc="Number of data points in the dipole fit")

self.signalToNoiseKey = schema.addField(
schema.join(name, "signalToNoise"), type=float,
Expand Down Expand Up @@ -1167,6 +1173,11 @@ def measure(self, measRecord, exposure, posExp=None, negExp=None):
measRecord[self.signalToNoiseKey] = result.signalToNoise
measRecord[self.chi2dofKey] = result.redChi2

if result.nData >= 1:
measRecord[self.nDataKey] = result.nData
else:
measRecord[self.nDataKey] = 0
bsmartradio marked this conversation as resolved.
Show resolved Hide resolved

self.doClassify(measRecord, result.chi2)

def doClassify(self, measRecord, chi2val):
Expand Down