Skip to content

Commit

Permalink
Merge branch 'tickets/DM-39970'
Browse files Browse the repository at this point in the history
  • Loading branch information
taranu committed Oct 18, 2023
2 parents 4fadbfc + 09548ac commit 45c73dd
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 10 deletions.
9 changes: 5 additions & 4 deletions include/lsst/meas/base/NaiveCentroid.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,17 @@ class NaiveCentroidControl {
public:
LSST_CONTROL_FIELD(background, double, "Value to subtract from the image pixel values");
LSST_CONTROL_FIELD(doFootprintCheck, bool, "Do check that the centroid is contained in footprint.");
LSST_CONTROL_FIELD(maxDistToPeak, double,
"If >0; maximum distance in pixels between the footprint peak and centroid allowed before "
"resetToPeak flag is set.");
LSST_CONTROL_FIELD(
maxDistToPeak, double,
"If >0; maximum distance in pixels between the footprint peak and centroid allowed before "
"resetToPeak flag is set.");

/**
* @brief Default constructor
*
* All control classes should define a default constructor that sets all fields to their default values.
*/
NaiveCentroidControl() : background(0.0), doFootprintCheck(true), maxDistToPeak(-1.0) {}
NaiveCentroidControl() : background(0.0), doFootprintCheck(true), maxDistToPeak(5.) {}
};

/**
Expand Down
9 changes: 5 additions & 4 deletions include/lsst/meas/base/SdssCentroid.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,17 +51,18 @@ class SdssCentroidControl {
LSST_CONTROL_FIELD(peakMin, double, "if the peak's less than this insist on binning at least once");
LSST_CONTROL_FIELD(wfac, double, "fiddle factor for adjusting the binning");
LSST_CONTROL_FIELD(doFootprintCheck, bool, "Do check that the centroid is contained in footprint.");
LSST_CONTROL_FIELD(maxDistToPeak, double,
"If >0; maximum distance in pixels between the footprint peak and centroid allowed before "
"resetToPeak flag is set.");
LSST_CONTROL_FIELD(
maxDistToPeak, double,
"If >0; maximum distance in pixels between the footprint peak and centroid allowed before "
"resetToPeak flag is set.");
/**
* @brief Default constructor
*
* All control classes should define a default constructor that sets all fields to their default values.
*/

SdssCentroidControl()
: binmax(16), peakMin(-1.0), wfac(1.5), doFootprintCheck(true), maxDistToPeak(-1.0) {}
: binmax(16), peakMin(-1.0), wfac(1.5), doFootprintCheck(true), maxDistToPeak(1.) {}
};

/**
Expand Down
4 changes: 2 additions & 2 deletions tests/test_NaiveCentroid.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ def testSingleFramePlugin(self):
x = record.get("base_NaiveCentroid_x")
y = record.get("base_NaiveCentroid_y")
self.assertFalse(record.get("base_NaiveCentroid_flag"))
self.assertFloatsAlmostEqual(x, self.center.getX(), atol=None, rtol=.02)
self.assertFloatsAlmostEqual(y, self.center.getY(), atol=None, rtol=.02)
self.assertFloatsAlmostEqual(x, self.center.getX(), atol=2.)
self.assertFloatsAlmostEqual(y, self.center.getY(), atol=2.)


class NaiveCentroidTransformTestCase(CentroidTransformTestCase,
Expand Down
4 changes: 4 additions & 0 deletions tests/test_centroid.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,12 +110,16 @@ def testNaiveMeasureCentroid(self):
control = measBase.NaiveCentroidControl()
control.background = bkgd
control.doFootprintCheck = False
# Test fails even with the default of 5
control.maxDistToPeak = -1.0
self.do_testAstrometry(measBase.NaiveCentroidAlgorithm, bkgd, control)

def testSdssMeasureCentroid(self):
"""Test that we can instantiate and play with SDSS centroids"""
control = measBase.SdssCentroidControl()
control.doFootprintCheck = False
# Test fails with the default of 1, and even 5
control.maxDistToPeak = -1.0
self.do_testAstrometry(measBase.SdssCentroidAlgorithm, 10.0, control)


Expand Down

0 comments on commit 45c73dd

Please sign in to comment.