Skip to content

Commit

Permalink
Add nData to dipole measRecord
Browse files Browse the repository at this point in the history
  • Loading branch information
bsmartradio committed Sep 11, 2023
1 parent b1c1672 commit 1aefdd1
Showing 1 changed file with 14 additions and 3 deletions.
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

self.doClassify(measRecord, result.chi2)

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

0 comments on commit 1aefdd1

Please sign in to comment.