Skip to content

Commit

Permalink
Merge pull request #307 from lsst/tickets/DM-43571
Browse files Browse the repository at this point in the history
DM-43571: Fix handling of bad dipole fits
  • Loading branch information
parejkoj authored Mar 29, 2024
2 parents eb961e4 + 736037b commit 36da64c
Showing 1 changed file with 4 additions and 12 deletions.
16 changes: 4 additions & 12 deletions python/lsst/ip/diffim/dipoleFitTask.py
Original file line number Diff line number Diff line change
Expand Up @@ -860,13 +860,7 @@ def fitDipole(self, source, tol=1e-7, rel_weight=0.1,

fitParams = fitResult.best_values
if fitParams['flux'] <= 1.: # usually around 0.1 -- the minimum flux allowed -- i.e. bad fit.
out = Struct(posCentroidX=np.nan, posCentroidY=np.nan,
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,
nData=np.nan)
return out, fitResult
return None, fitResult

centroid = ((fitParams['xcenPos'] + fitParams['xcenNeg']) / 2.,
(fitParams['ycenPos'] + fitParams['ycenNeg']) / 2.)
Expand Down Expand Up @@ -1127,13 +1121,11 @@ def measureDipoles(self, measRecord, exposure, posExp=None, negExp=None):
errorMessage = f"Exception in dipole fit. {e.__class__.__name__}: {e}"
self.fail(measRecord, measBase.MeasurementError(errorMessage, self.FAILURE_FIT))

if result is None:
return

self.log.debug("Dipole fit result: %d %s", measRecord.getId(), str(result))

if result.posFlux <= 1.: # usually around 0.1 -- the minimum flux allowed -- i.e. bad fit.
self.fail(measRecord, measBase.MeasurementError('dipole fit failure', self.FAILURE_FIT))
if result is None:
self.fail(measRecord, measBase.MeasurementError("bad dipole fit", self.FAILURE_FIT))
return

# add chi2, coord/flux uncertainties (TBD), dipole classification
# Add the relevant values to the measRecord
Expand Down

0 comments on commit 36da64c

Please sign in to comment.