lsst.ip.diffim g180d380827+7a4e862ed4
Loading...
Searching...
No Matches
DipoleAlgorithms.h
Go to the documentation of this file.
1// -*- LSST-C++ -*-
2
3/*
4 * LSST Data Management System
5 * Copyright 2008-2015 AURA/LSST
6 *
7 * This product includes software developed by the
8 * LSST Project (http://www.lsst.org/).
9 *
10 * This program is free software: you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation, either version 3 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the LSST License Statement and
21 * the GNU General Public License along with this program. If not,
22 * see <http://www.lsstcorp.org/LegalNotices/>.
23 */
24
25#ifndef LSST_IP_DIFFIM_DIPOLEALGORITHMS_H
26#define LSST_IP_DIFFIM_DIPOLEALGORITHMS_H
28// Control/algorithm hierarchy for dipole measurement.
29//
30
31#include <stdio.h>
32#include <execinfo.h>
33#include <signal.h>
34#include <stdlib.h>
35#include <unistd.h>
36#include <array>
37
38#include "lsst/base.h"
39#include "lsst/pex/config.h"
40#include "ndarray/eigen.h"
47
48namespace lsst {
49namespace ip {
50namespace diffim {
51
53public:
54
56};
57
59public:
60
61 explicit DipoleFluxControl() {}
62};
63
68public:
69 LSST_CONTROL_FIELD(stepSizeCoord, float, "Default initial step size for coordinates in non-linear fitter");
70 LSST_CONTROL_FIELD(stepSizeFlux, float, "Default initial step size for flux in non-linear fitter");
71 LSST_CONTROL_FIELD(errorDef, double, "How many sigma the error bars of the non-linear fitter represent");
72 LSST_CONTROL_FIELD(maxFnCalls, int, "Maximum function calls for non-linear fitter; 0 = unlimited");
75};
76
111
116public:
117
122
126
127 DipoleFluxAlgorithm(Control const & ctrl, std::string const & name, afw::table::Schema & schema,
128 std::string const & doc);
129
130 // A typedef for the FunctorKey which returns the result of this algorithm
133 ResultKey const & getPositiveKeys() const { return _positiveKeys; }
134 ResultKey const & getNegativeKeys() const { return _negativeKeys; }
135
136protected:
137
139 DipoleFluxAlgorithm(Control const & ctrl, std::string const & name,
140 afw::table::Schema & schema, std::string const & doc,
142
146
149};
150
164
180
193
195 Control const & ctrl, std::string const & name, afw::table::Schema & schema,
196 std::string const & doc
197 ) :
198 _ctrl(ctrl)
199{
201 meas::base::FluxResultKey::addFields(schema, name+"_pos", doc+": positive lobe");
202 meas::base::FluxResultKey::addFields(schema, name+"_neg", doc+": negative lobe");
205}
206
207/*
208class that knows how to calculate centroids as a simple unweighted first
209 * moment of the 3x3 region around the peaks
210 */
212 "This algorithm is deprecated and will be removed after v28.")]]
214public:
215
217
218 NaiveDipoleFlux(Control const & ctrl, std::string const & name, afw::table::Schema & schema) :
219 DipoleFluxAlgorithm(ctrl, name, schema, "raw flux counts"),
220 _numPositiveKey(schema.addField<int>(name+"_npos", "number of positive pixels", "count")),
221 _numNegativeKey(schema.addField<int>(name+"_nneg", "number of negative pixels", "count"))
222 {
223 }
224
225 void measure(
227 afw::image::Exposure<float> const & exposure
228 ) const;
229
230 void fail(
233 ) const;
234
235private:
236
237 Control _ctrl;
238 afw::table::Key<int> _numPositiveKey;
239 afw::table::Key<int> _numNegativeKey;
240};
241
246 "This algorithm is deprecated and will be removed after v28.")]]
248public:
249
257
259 ResultKey const & getCenterKeys() const { return _centerKeys; }
260 ResultKey const & getPositiveKeys() const { return _positiveKeys; }
261 ResultKey const & getNegativeKeys() const { return _negativeKeys; }
262
263 void measure(
265 afw::image::Exposure<float> const & exposure
266 ) const;
267
268 void mergeCentroids(afw::table::SourceRecord & source, double posValue, double negValue) const;
269
270 void fail(
273 ) const;
274
275protected:
279
280private:
281
282 Control _ctrl;
283 meas::base::FluxResultKey _fluxResultKey;
284 meas::base::FlagHandler _flagHandler;
285};
286
287
288
289
294public:
295
297
299 DipoleFluxAlgorithm(ctrl, name, schema, "jointly fitted psf flux counts"),
300 _ctrl(ctrl),
301 _chi2dofKey(schema.addField<float>(name+"_chi2dof",
302 "chi2 per degree of freedom of fit"))
303 {
304 meas::base::CentroidResultKey::addFields(schema, name+"_pos_centroid", "psf fitted center of positive lobe", meas::base::SIGMA_ONLY);
305 meas::base::CentroidResultKey::addFields(schema, name+"_neg_centroid", "psf fitted center of negative lobe", meas::base::SIGMA_ONLY);
306 meas::base::CentroidResultKey::addFields(schema, name, "average of negative and positive lobe positions", meas::base::SIGMA_ONLY);
307 _posCentroid = meas::base::CentroidResultKey(schema[name+"_pos_centroid"]);
308 _negCentroid = meas::base::CentroidResultKey(schema[name+"_neg_centroid"]);
310 }
312 afw::image::Exposure<float> const & exposure,
313 double negCenterX, double negCenterY, double negFlux,
314 double posCenterX, double poCenterY, double posFlux
315 ) const;
316
317 void measure(
319 afw::image::Exposure<float> const & exposure
320 ) const;
321
322 void fail(
325 ) const;
326
327private:
328
329 Control _ctrl;
330 afw::table::Key<float> _chi2dofKey;
334
335};
336
337}}}// namespace lsst::ip::diffim
338
339#endif // !LSST_IP_DIFFIM_DIPOLEALGORITHMS_H
table::Key< std::string > name
Intermediate base class for algorithms that compute a centroid.
ResultKey const & getPositiveKeys() const
Return the standard centroid keys registered by this algorithm.
static meas::base::FlagDefinition const FAILURE
meas::base::CentroidResultKey ResultKey
static meas::base::FlagDefinition const POS_FLAG
static meas::base::FlagDefinition const NEG_FLAG
static meas::base::FlagDefinitionList const & getFlagDefinitions()
DipoleCentroidAlgorithm(Control const &ctrl, std::string const &name, afw::table::Schema &schema, std::string const &doc)
Intermediate base class for algorithms that compute a flux.
static meas::base::FlagDefinitionList const & getFlagDefinitions()
DipoleFluxControl Control
A typedef to the Control object for this algorithm, defined above.
ResultKey const & getPositiveKeys() const
Return the standard flux keys registered by this algorithm.
static meas::base::FlagDefinition const POS_FLAG
static meas::base::FlagDefinition const NEG_FLAG
ResultKey const & getNegativeKeys() const
meas::base::FluxResultKey _fluxResultKey
DipoleFluxAlgorithm(Control const &ctrl, std::string const &name, afw::table::Schema &schema, std::string const &doc)
static meas::base::FlagDefinition const FAILURE
Intermediate base class for algorithms that compute a centroid.
ResultKey const & getPositiveKeys() const
ResultKey const & getNegativeKeys() const
meas::base::CentroidResultKey ResultKey
Tuple type that holds the keys that define a standard centroid algorithm.
NaiveDipoleCentroid(Control const &ctrl, std::string const &name, afw::table::Schema &schema, ResultKey const &positiveKeys, ResultKey const &negativeKeys)
Initialize with a manually-constructed key tuple.
ResultKey const & getCenterKeys() const
Return the standard centroid keys registered by this algorithm.
NaiveDipoleFlux(Control const &ctrl, std::string const &name, afw::table::Schema &schema)
C++ control object for PSF dipole fluxes.
float stepSizeCoord
"Default initial step size for coordinates in non-linear fitter" ;
double errorDef
"How many sigma the error bars of the non-linear fitter represent" ;
float stepSizeFlux
"Default initial step size for flux in non-linear fitter" ;
int maxFnCalls
"Maximum function calls for non-linear fitter; 0 = unlimited" ;
Implementation of Psf dipole flux.
std::pair< double, int > chi2(afw::table::SourceRecord &source, afw::image::Exposure< float > const &exposure, double negCenterX, double negCenterY, double negFlux, double posCenterX, double poCenterY, double posFlux) const
void measure(afw::table::SourceRecord &measRecord, afw::image::Exposure< float > const &exposure) const
PsfDipoleFlux(PsfDipoleFluxControl const &ctrl, std::string const &name, afw::table::Schema &schema)
void fail(afw::table::SourceRecord &measRecord, meas::base::MeasurementError *error=NULL) const
Asseses the quality of a candidate given a spatial kernel and background model.
static CentroidResultKey addFields(afw::table::Schema &schema, std::string const &name, std::string const &doc, UncertaintyEnum uncertainty)
static FlagHandler addFields(afw::table::Schema &schema, std::string const &prefix, FlagDefinitionList const &flagDefs, FlagDefinitionList const &exclDefs=FlagDefinitionList::getEmptyList())
static FluxResultKey addFields(afw::table::Schema &schema, std::string const &name, std::string const &doc)
table::Schema schema