Skip to content

Commit

Permalink
Merge pull request #362 from lsst/tickets/DM-41701
Browse files Browse the repository at this point in the history
DM-41701: Remove deprecated code
  • Loading branch information
isullivan authored Nov 27, 2024
2 parents 77b3bfb + 2169487 commit 63c0c3c
Show file tree
Hide file tree
Showing 7 changed files with 3 additions and 383 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,9 @@ Their respective algorithm control classes are defined in
DipoleCentroidControl and DipoleFluxControl. Each centroid and flux
measurement will have _neg (negative) and _pos (positive lobe) fields.

The first set of measurements uses a "naive" algorithm for centroid and flux
measurements, implemented in NaiveDipoleCentroidControl and
NaiveDipoleFluxControl. The algorithm uses a naive 3x3 weighted moment around
the nominal centroids of each peak in the Source Footprint. These algorithms
fill the table fields ip_diffim_NaiveDipoleCentroid* and
ip_diffim_NaiveDipoleFlux*
The first set of measurements uses the SDSS algorithm for centroid and flux
measurements.
This centroid will be used as a fallback, if the below dipole fit fails or if the source does not have a positive and negative peak to attempt a dipole fit to.

The second set of measurements undertakes a joint-Psf model on the negative and
positive lobe simultaneously. This fit simultaneously solves for the negative
Expand Down
82 changes: 0 additions & 82 deletions include/lsst/ip/diffim/DipoleAlgorithms.h
Original file line number Diff line number Diff line change
Expand Up @@ -204,88 +204,6 @@ inline DipoleFluxAlgorithm::DipoleFluxAlgorithm(
_negativeKeys = ResultKey(schema[name+"_neg"]);
}

/*
class that knows how to calculate centroids as a simple unweighted first
* moment of the 3x3 region around the peaks
*/
class [[deprecated(
"This algorithm is deprecated and will be removed after v28.")]]
NaiveDipoleFlux : public DipoleFluxAlgorithm {
public:

typedef DipoleFluxControl Control;

NaiveDipoleFlux(Control const & ctrl, std::string const & name, afw::table::Schema & schema) :
DipoleFluxAlgorithm(ctrl, name, schema, "raw flux counts"),
_numPositiveKey(schema.addField<int>(name+"_npos", "number of positive pixels", "count")),
_numNegativeKey(schema.addField<int>(name+"_nneg", "number of negative pixels", "count"))
{
}

void measure(
afw::table::SourceRecord & measRecord,
afw::image::Exposure<float> const & exposure
) const;

void fail(
afw::table::SourceRecord & measRecord,
meas::base::MeasurementError * error=NULL
) const;

private:

Control _ctrl;
afw::table::Key<int> _numPositiveKey;
afw::table::Key<int> _numNegativeKey;
};

/**
* @brief Intermediate base class for algorithms that compute a centroid.
*/
class [[deprecated(
"This algorithm is deprecated and will be removed after v28.")]]
NaiveDipoleCentroid : public DipoleCentroidAlgorithm {
public:

NaiveDipoleCentroid(Control const & ctrl, std::string const & name, afw::table::Schema & schema);
/**
* @brief Tuple type that holds the keys that define a standard centroid algorithm.
*
* Algorithms are encouraged to add additional flags as appropriate, but these are required.
*/
typedef meas::base::CentroidResultKey ResultKey;

/// @brief Return the standard centroid keys registered by this algorithm.
ResultKey const & getCenterKeys() const { return _centerKeys; }
ResultKey const & getPositiveKeys() const { return _positiveKeys; }
ResultKey const & getNegativeKeys() const { return _negativeKeys; }

void measure(
afw::table::SourceRecord & measRecord,
afw::image::Exposure<float> const & exposure
) const;

void mergeCentroids(afw::table::SourceRecord & source, double posValue, double negValue) const;

void fail(
afw::table::SourceRecord & measRecord,
meas::base::MeasurementError * error=NULL
) const;

protected:
/// @brief Initialize with a manually-constructed key tuple.
NaiveDipoleCentroid(Control const & ctrl, std::string const & name, afw::table::Schema & schema,
ResultKey const & positiveKeys, ResultKey const & negativeKeys);

private:

Control _ctrl;
meas::base::FluxResultKey _fluxResultKey;
meas::base::FlagHandler _flagHandler;
};




/**
* Implementation of Psf dipole flux
Expand Down
5 changes: 0 additions & 5 deletions python/lsst/ip/diffim/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,4 @@
# automatically register ip_diffim Algorithms;
# CENTROID_ORDER=0.0, FLUX_ORDER==2.0
from lsst.meas.base import wrapSimpleAlgorithm
wrapSimpleAlgorithm(NaiveDipoleCentroid, Control=DipoleCentroidControl, executionOrder=0.0,
deprecated="Plugin 'NaiveDipoleCentroid' is deprecated and will be removed after v28.0")
wrapSimpleAlgorithm(NaiveDipoleFlux, Control=DipoleFluxControl, executionOrder=2.0,
deprecated="Plugin 'NaiveDipoleFlux' is deprecated and will be removed after v28.0")
wrapSimpleAlgorithm(PsfDipoleFlux, Control=PsfDipoleFluxControl, executionOrder=2.0)

39 changes: 0 additions & 39 deletions python/lsst/ip/diffim/dipoleAlgorithms.cc
Original file line number Diff line number Diff line change
Expand Up @@ -102,39 +102,6 @@ void declareDipoleFluxAlgorithm(lsst::cpputils::python::WrapperCollection &wrapp
});
}

// Hide deprecation warnings when building pybind11.
// Remove these pragmas on DM-44030
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated"
void declareNaiveDipoleFlux(lsst::cpputils::python::WrapperCollection &wrappers) {
using PyNaiveDipoleFlux = py::class_<NaiveDipoleFlux, std::shared_ptr<NaiveDipoleFlux>, DipoleFluxAlgorithm>;

wrappers.wrapType(PyNaiveDipoleFlux(wrappers.module, "NaiveDipoleFlux"), [](auto &mod, auto &cls) {
cls.def(py::init<NaiveDipoleFlux::Control const &, std::string const &, afw::table::Schema &>(), "ctrl"_a,
"name"_a, "schema"_a);

cls.def("measure", &NaiveDipoleFlux::measure, "measRecord"_a, "exposure"_a);
cls.def("fail", &NaiveDipoleFlux::fail, "measRecord"_a, "error"_a = nullptr);
});
}

void declareNaiveDipoleCentroid(lsst::cpputils::python::WrapperCollection &wrappers) {
using PyNaiveDipoleCentroid =
py::class_<NaiveDipoleCentroid, std::shared_ptr<NaiveDipoleCentroid>, DipoleCentroidAlgorithm>;
wrappers.wrapType(PyNaiveDipoleCentroid(wrappers.module, "NaiveDipoleCentroid"), [](auto &mod, auto &cls) {
cls.def(py::init<NaiveDipoleCentroid::Control const &, std::string const &, afw::table::Schema &>(),
"ctrl"_a, "name"_a, "schema"_a);

cls.def("getCenterKeys", &NaiveDipoleCentroid::getCenterKeys);
cls.def("getPositiveKeys", &NaiveDipoleCentroid::getPositiveKeys);
cls.def("getNegativeKeys", &NaiveDipoleCentroid::getNegativeKeys);

cls.def("measure", &NaiveDipoleCentroid::measure, "measRecord"_a, "exposure"_a);
cls.def("mergeCentroids", &NaiveDipoleCentroid::mergeCentroids, "source"_a, "posValue"_a, "negValue"_a);
cls.def("fail", &NaiveDipoleCentroid::fail, "measRecord"_a, "error"_a = nullptr);
});
}

void declarePsfDipoleFlux(lsst::cpputils::python::WrapperCollection &wrappers) {
using PyPsfDipoleFlux = py::class_<PsfDipoleFlux, std::shared_ptr<PsfDipoleFlux>, DipoleFluxAlgorithm>;

Expand All @@ -157,15 +124,9 @@ void wrapDipoleAlgorithms(lsst::cpputils::python::WrapperCollection &wrappers) {
declareDipolePsfFluxControl(wrappers);
declareDipoleCentroidAlgorithm(wrappers);
declareDipoleFluxAlgorithm(wrappers);
declareNaiveDipoleFlux(wrappers);
declareNaiveDipoleCentroid(wrappers);
declarePsfDipoleFlux(wrappers);
}

// Stop hiding deprecation warnings when building pybind11.
// Remove these pragmas on DM-44030
#pragma GCC diagnostic pop

} // diffim
} // ip
} // lsst
13 changes: 0 additions & 13 deletions python/lsst/ip/diffim/subtractImages.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,19 +212,6 @@ class AlardLuptonSubtractBaseConfig(lsst.pex.config.Config):
default=3,
doc="Minimum number of sources needed for calculating the PSF matching kernel."
)
badSourceFlags = lsst.pex.config.ListField(
dtype=str,
doc="Flags that, if set, the associated source should not "
"be used to determine the PSF matching kernel.",
default=("sky_source", "slot_Centroid_flag",
"slot_ApFlux_flag", "slot_PsfFlux_flag",
"base_PixelFlags_flag_interpolated",
"base_PixelFlags_flag_saturated",
"base_PixelFlags_flag_bad",
),
deprecated="This field is no longer used and will be removed after v28."
"Set the equivalent field for the sourceSelector subtask instead.",
)
excludeMaskPlanes = lsst.pex.config.ListField(
dtype=str,
default=("NO_DATA", "BAD", "SAT", "EDGE", "FAKE"),
Expand Down
Loading

0 comments on commit 63c0c3c

Please sign in to comment.