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-39970: Set finite centroider maxDistToPeak defaults #255

Merged
merged 2 commits into from
Oct 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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