lsst.meas.base  14.0-12-g233aa8e+5
GaussianFlux.cc
Go to the documentation of this file.
1 // -*- lsst-c++ -*-
2 /*
3  * LSST Data Management System
4  * Copyright 2008-2013 LSST Corporation.
5  *
6  * This product includes software developed by the
7  * LSST Project (http://www.lsst.org/).
8  *
9  * This program is free software: you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation, either version 3 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the LSST License Statement and
20  * the GNU General Public License along with this program. If not,
21  * see <http://www.lsstcorp.org/LegalNotices/>.
22  */
23 
24 #include "ndarray/eigen.h"
25 
26 #include "lsst/afw/detection/Psf.h"
27 #include "lsst/afw/geom/Box.h"
29 #include "lsst/afw/table/Source.h"
32 
33 namespace lsst { namespace meas { namespace base {
34 namespace {
35 FlagDefinitionList flagDefinitions;
36 } // end anonymous
37 
38 FlagDefinition const GaussianFluxAlgorithm::FAILURE = flagDefinitions.addFailureFlag();
39 
41  return flagDefinitions;
42 }
43 
44 
46  Control const & ctrl,
47  std::string const & name,
48  afw::table::Schema & schema
49 ) : _ctrl(ctrl),
50  _fluxResultKey(
51  FluxResultKey::addFields(schema, name, "flux from Gaussian Flux algorithm")
52  ),
53  _centroidExtractor(schema, name),
54  _shapeExtractor(schema, name)
55 {
56  _flagHandler = FlagHandler::addFields(schema, name, getFlagDefinitions());
57 }
58 
60  afw::table::SourceRecord & measRecord,
61  afw::image::Exposure<float> const & exposure
62 ) const {
63  afw::geom::Point2D centroid = _centroidExtractor(measRecord, _flagHandler);
64  afw::geom::ellipses::Quadrupole shape = _shapeExtractor(measRecord, _flagHandler);
65 
67  exposure.getMaskedImage(), shape, centroid
68  );
69 
70  measRecord.set(_fluxResultKey, result);
71  _flagHandler.setValue(measRecord, FAILURE.number, false);
72 }
73 
74 
76  _flagHandler.handleFailure(measRecord, error);
77 }
78 
79 }}} // namespace lsst::meas::base
A C++ control class to handle GaussianFluxAlgorithm&#39;s configuration.
Definition: GaussianFlux.h:41
static FluxResult computeFixedMomentsFlux(ImageT const &image, afw::geom::ellipses::Quadrupole const &shape, afw::geom::Point2D const &position)
Compute the flux within a fixed Gaussian aperture.
Definition: SdssShape.cc:874
GaussianFluxAlgorithm(Control const &ctrl, std::string const &name, afw::table::Schema &schema)
Definition: GaussianFlux.cc:45
void setValue(afw::table::BaseRecord &record, std::size_t i, bool value) const
Set the flag field corresponding to the given flag index.
Definition: FlagHandler.h:276
Exception to be thrown when a measurement algorithm experiences a known failure mode.
Definition: exceptions.h:48
STL class.
MaskedImageT getMaskedImage()
A FunctorKey for FluxResult.
Definition: FluxUtilities.h:56
static FlagDefinition const FAILURE
Definition: GaussianFlux.h:67
static FlagDefinitionList const & getFlagDefinitions()
Definition: GaussianFlux.cc:40
static FlagHandler addFields(afw::table::Schema &schema, std::string const &prefix, FlagDefinitionList const &flagDefs, FlagDefinitionList const &exclDefs=FlagDefinitionList::getEmptyList())
Add Flag fields to a schema, creating a FlagHandler object to manage them.
Definition: FlagHandler.cc:37
virtual void measure(afw::table::SourceRecord &measRecord, afw::image::Exposure< float > const &exposure) const
Called to measure a single child source in an image.
Definition: GaussianFlux.cc:59
void handleFailure(afw::table::BaseRecord &record, MeasurementError const *error=nullptr) const
Handle an expected or unexpected Exception thrown by a measurement algorithm.
Definition: FlagHandler.cc:93
virtual void fail(afw::table::SourceRecord &measRecord, MeasurementError *error=nullptr) const
Handle an exception thrown by the current algorithm by setting flags in the given record...
Definition: GaussianFlux.cc:75
void set(Key< T > const &key, U const &value)
vector-type utility class to build a collection of FlagDefinitions
Definition: FlagHandler.h:63
A reusable result struct for flux measurements.
Definition: FluxUtilities.h:37