LSSTApplications  8.0.0.0+107,8.0.0.1+13,9.1+18,9.2,master-g084aeec0a4,master-g0aced2eed8+6,master-g15627eb03c,master-g28afc54ef9,master-g3391ba5ea0,master-g3d0fb8ae5f,master-g4432ae2e89+36,master-g5c3c32f3ec+17,master-g60f1e072bb+1,master-g6a3ac32d1b,master-g76a88a4307+1,master-g7bce1f4e06+57,master-g8ff4092549+31,master-g98e65bf68e,master-ga6b77976b1+53,master-gae20e2b580+3,master-gb584cd3397+53,master-gc5448b162b+1,master-gc54cf9771d,master-gc69578ece6+1,master-gcbf758c456+22,master-gcec1da163f+63,master-gcf15f11bcc,master-gd167108223,master-gf44c96c709
LSSTDataManagementBasePackage
Classification.cc
Go to the documentation of this file.
1 // -*- lsst-c++ -*-
2 
3 #include "boost/make_shared.hpp"
4 
6 
7 namespace lsst { namespace meas { namespace algorithms {
8 
9 namespace {
10 
11 class ClassificationAlgorithm : public Algorithm {
12 public:
13 
14  ClassificationAlgorithm(ClassificationControl const & ctrl, afw::table::Schema & schema);
15 
16 public:
17 
18  template <typename PixelT>
19  void _apply(
20  afw::table::SourceRecord & source,
21  afw::image::Exposure<PixelT> const & exposure,
22  afw::geom::Point2D const & center
23  ) const;
24 
25 private:
26  LSST_MEAS_ALGORITHM_PRIVATE_INTERFACE(ClassificationAlgorithm);
27 
28  afw::table::Key<double> _key;
29 };
30 
31 ClassificationAlgorithm::ClassificationAlgorithm(
32  ClassificationControl const & ctrl, afw::table::Schema & schema
33 ) :
34  Algorithm(ctrl),
35  _key(schema.addField<double>(ctrl.name, "probability of being extended"))
36 {}
37 
38 template <typename PixelT>
39 void ClassificationAlgorithm::_apply(
40  afw::table::SourceRecord & source,
41  afw::image::Exposure<PixelT> const & exposure,
42  afw::geom::Point2D const & center
43 ) const {
44  ClassificationControl const & ctrl = static_cast<ClassificationControl const &>(getControl());
45  source[_key] = (ctrl.fluxRatio*source.getModelFlux() + ctrl.modelErrFactor*source.getModelFluxErr())
46  < (source.getPsfFlux() + ctrl.psfErrFactor*source.getPsfFluxErr()) ? 0.0 : 1.0;
47 }
48 
49 LSST_MEAS_ALGORITHM_PRIVATE_IMPLEMENTATION(ClassificationAlgorithm);
50 
51 } // anonymous
52 
54  return boost::make_shared<ClassificationControl>(*this);
55 }
56 
58  afw::table::Schema & schema,
59  PTR(daf::base::PropertyList) const & metadata
60 ) const {
61  return boost::make_shared<ClassificationAlgorithm>(*this, boost::ref(schema));
62 }
63 
64 }}} // namespace lsst::meas::algorithms
#define PTR(...)
Definition: base.h:41
#define LSST_MEAS_ALGORITHM_PRIVATE_INTERFACE(CLASS)
Declare Algorithm::_applyT virtual function overloads with the correct types.
Definition: Algorithm.h:60
Class for storing ordered metadata with comments.
Definition: PropertyList.h:81
Point< double, 2 > Point2D
Definition: Point.h:277
Base class for source measurement algorithms.
Definition: Algorithm.h:106
Base class for measurement algorithm control objects.
Definition: Algorithm.h:168
tbl::Schema schema
Definition: CoaddPsf.cc:324
#define LSST_MEAS_ALGORITHM_PRIVATE_IMPLEMENTATION(CLASS)
Implement Algorithm::_applyT virtual function overloads with the correct types.
Definition: Algorithm.h:71
afw::table::Key< afw::table::Point< double > > _key
Control/factory for the algorithm that does star/galaxy classification.