LSST Applications 27.0.0,g0265f82a02+469cd937ee,g02d81e74bb+21ad69e7e1,g1470d8bcf6+cbe83ee85a,g2079a07aa2+e67c6346a6,g212a7c68fe+04a9158687,g2305ad1205+94392ce272,g295015adf3+81dd352a9d,g2bbee38e9b+469cd937ee,g337abbeb29+469cd937ee,g3939d97d7f+72a9f7b576,g487adcacf7+71499e7cba,g50ff169b8f+5929b3527e,g52b1c1532d+a6fc98d2e7,g591dd9f2cf+df404f777f,g5a732f18d5+be83d3ecdb,g64a986408d+21ad69e7e1,g858d7b2824+21ad69e7e1,g8a8a8dda67+a6fc98d2e7,g99cad8db69+f62e5b0af5,g9ddcbc5298+d4bad12328,ga1e77700b3+9c366c4306,ga8c6da7877+71e4819109,gb0e22166c9+25ba2f69a1,gb6a65358fc+469cd937ee,gbb8dafda3b+69d3c0e320,gc07e1c2157+a98bf949bb,gc120e1dc64+615ec43309,gc28159a63d+469cd937ee,gcf0d15dbbd+72a9f7b576,gdaeeff99f8+a38ce5ea23,ge6526c86ff+3a7c1ac5f1,ge79ae78c31+469cd937ee,gee10cc3b42+a6fc98d2e7,gf1cff7945b+21ad69e7e1,gfbcc870c63+9a11dc8c8f
LSST Data Management Base Package
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,
141 ResultKey const & positiveKeys, ResultKey const & negativeKeys);
142
146
149};
150
152 Control const & ctrl, std::string const & name, afw::table::Schema & schema, std::string const & doc
153 ) :
154 _ctrl(ctrl)
155{
157 meas::base::CentroidResultKey::addFields(schema, name, doc+": overall centroid", meas::base::SIGMA_ONLY);
158 meas::base::CentroidResultKey::addFields(schema, name+"_pos", doc+": positive lobe", meas::base::SIGMA_ONLY);
159 meas::base::CentroidResultKey::addFields(schema, name+"_neg", doc+": negative lobe", meas::base::SIGMA_ONLY);
160 _centerKeys = ResultKey(schema[name]);
161 _positiveKeys = ResultKey(schema[name+"_pos"]);
162 _negativeKeys = ResultKey(schema[name+"_neg"]);
163}
164
166 Control const & ctrl, std::string const & name, afw::table::Schema & schema, std::string const & doc,
167 ResultKey const & positiveKeys, ResultKey const & negativeKeys
168 ) :
169 _ctrl(ctrl)
170{
172 meas::base::CentroidResultKey::addFields(schema, name, doc+": overall centroid", meas::base::SIGMA_ONLY);
173 meas::base::CentroidResultKey::addFields(schema, name+"_pos", doc + ": positive lobe", meas::base::SIGMA_ONLY);
174 meas::base::CentroidResultKey::addFields(schema, name+"_neg", doc + ": negative lobe", meas::base::SIGMA_ONLY);
175 _centerKeys = ResultKey(schema[name]);
176
177 _positiveKeys = ResultKey(schema[name+"_pos"]);
178 _negativeKeys = ResultKey(schema[name+"_neg"]);
179}
180
182 Control const & ctrl, std::string const & name, afw::table::Schema & schema,
183 std::string const & doc, ResultKey const & positiveKeys, ResultKey const & negativeKeys
184 ) :
185 _ctrl(ctrl)
186{
188 meas::base::FluxResultKey::addFields(schema, name+"_pos", doc+": positive lobe");
189 meas::base::FluxResultKey::addFields(schema, name+"_neg", doc+": negative lobe");
190 _positiveKeys = ResultKey(positiveKeys);
191 _negativeKeys = ResultKey(negativeKeys);
192}
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");
203 _positiveKeys = ResultKey(schema[name+"_pos"]);
204 _negativeKeys = ResultKey(schema[name+"_neg"]);
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 */
212public:
213
215
216 NaiveDipoleFlux(Control const & ctrl, std::string const & name, afw::table::Schema & schema) :
217 DipoleFluxAlgorithm(ctrl, name, schema, "raw flux counts"),
218 _numPositiveKey(schema.addField<int>(name+"_npos", "number of positive pixels", "count")),
219 _numNegativeKey(schema.addField<int>(name+"_nneg", "number of negative pixels", "count"))
220 {
221 }
222
223 void measure(
224 afw::table::SourceRecord & measRecord,
225 afw::image::Exposure<float> const & exposure
226 ) const;
227
228 void fail(
229 afw::table::SourceRecord & measRecord,
231 ) const;
232
233private:
234
235 Control _ctrl;
236 afw::table::Key<int> _numPositiveKey;
237 afw::table::Key<int> _numNegativeKey;
238};
239
244public:
245
246 NaiveDipoleCentroid(Control const & ctrl, std::string const & name, afw::table::Schema & schema);
253
255 ResultKey const & getCenterKeys() const { return _centerKeys; }
256 ResultKey const & getPositiveKeys() const { return _positiveKeys; }
257 ResultKey const & getNegativeKeys() const { return _negativeKeys; }
258
259 void measure(
260 afw::table::SourceRecord & measRecord,
261 afw::image::Exposure<float> const & exposure
262 ) const;
263
264 void mergeCentroids(afw::table::SourceRecord & source, double posValue, double negValue) const;
265
266 void fail(
267 afw::table::SourceRecord & measRecord,
269 ) const;
270
271protected:
273 NaiveDipoleCentroid(Control const & ctrl, std::string const & name, afw::table::Schema & schema,
274 ResultKey const & positiveKeys, ResultKey const & negativeKeys);
275
276private:
277
278 Control _ctrl;
279 meas::base::FluxResultKey _fluxResultKey;
280 meas::base::FlagHandler _flagHandler;
281};
282
283
284
285
290public:
291
293
294 PsfDipoleFlux(PsfDipoleFluxControl const & ctrl, std::string const & name, afw::table::Schema & schema) :
295 DipoleFluxAlgorithm(ctrl, name, schema, "jointly fitted psf flux counts"),
296 _ctrl(ctrl),
297 _chi2dofKey(schema.addField<float>(name+"_chi2dof",
298 "chi2 per degree of freedom of fit"))
299 {
300 meas::base::CentroidResultKey::addFields(schema, name+"_pos_centroid", "psf fitted center of positive lobe", meas::base::SIGMA_ONLY);
301 meas::base::CentroidResultKey::addFields(schema, name+"_neg_centroid", "psf fitted center of negative lobe", meas::base::SIGMA_ONLY);
302 meas::base::CentroidResultKey::addFields(schema, name+"_centroid", "average of negative and positive lobe positions", meas::base::SIGMA_ONLY);
303 _posCentroid = meas::base::CentroidResultKey(schema[name+"_pos_centroid"]);
304 _negCentroid = meas::base::CentroidResultKey(schema[name+"_neg_centroid"]);
305 _avgCentroid = meas::base::CentroidResultKey(schema[name+"_centroid"]);
306 }
308 afw::image::Exposure<float> const & exposure,
309 double negCenterX, double negCenterY, double negFlux,
310 double posCenterX, double poCenterY, double posFlux
311 ) const;
312
313 void measure(
314 afw::table::SourceRecord & measRecord,
315 afw::image::Exposure<float> const & exposure
316 ) const;
317
318 void fail(
319 afw::table::SourceRecord & measRecord,
321 ) const;
322
323private:
324
325 Control _ctrl;
326 afw::table::Key<float> _chi2dofKey;
330
331};
332
333}}}// namespace lsst::ip::diffim
334
335#endif // !LSST_IP_DIFFIM_DIPOLEALGORITHMS_H
Basic LSST definitions.
A class to contain the data, WCS, and other information needed to describe an image of the sky.
Definition Exposure.h:72
Tag types used to declare specialized field types.
Definition misc.h:31
Defines the fields and offsets for a table.
Definition Schema.h:51
Record class that contains measurements made on a single exposure.
Definition Source.h:78
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.
void measure(afw::table::SourceRecord &measRecord, afw::image::Exposure< float > const &exposure) const
Given an image and a pixel position, return a Centroid using a naive 3x3 weighted moment.
void mergeCentroids(afw::table::SourceRecord &source, double posValue, double negValue) const
void fail(afw::table::SourceRecord &measRecord, meas::base::MeasurementError *error=NULL) const
Handle an exception thrown by the current algorithm by setting flags in the given record.
ResultKey const & getCenterKeys() const
Return the standard centroid keys registered by this algorithm.
void measure(afw::table::SourceRecord &measRecord, afw::image::Exposure< float > const &exposure) const
Given an image and a pixel position, return a Centroid using a naive 3x3 weighted moment.
void fail(afw::table::SourceRecord &measRecord, meas::base::MeasurementError *error=NULL) const
Handle an exception thrown by the current algorithm by setting flags in the given record.
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
Called to measure a single child source in an image.
PsfDipoleFlux(PsfDipoleFluxControl const &ctrl, std::string const &name, afw::table::Schema &schema)
void fail(afw::table::SourceRecord &measRecord, meas::base::MeasurementError *error=NULL) const
Handle an exception thrown by the current algorithm by setting flags in the given record.
A FunctorKey for CentroidResult.
static CentroidResultKey addFields(afw::table::Schema &schema, std::string const &name, std::string const &doc, UncertaintyEnum uncertainty)
Add the appropriate fields to a Schema, and return a CentroidResultKey that manages them.
vector-type utility class to build a collection of FlagDefinitions
Definition FlagHandler.h:60
Utility class for handling flag fields that indicate the failure modes of an algorithm.
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.
A FunctorKey for FluxResult.
static FluxResultKey addFields(afw::table::Schema &schema, std::string const &name, std::string const &doc)
Add a pair of _instFlux, _instFluxErr fields to a Schema, and return a FluxResultKey that points to t...
Exception to be thrown when a measurement algorithm experiences a known failure mode.
Definition exceptions.h:48
An abstract base classes for which the same implementation can be used for both SingleFrameAlgorithm ...
Definition Algorithm.h:170
#define LSST_CONTROL_FIELD(NAME, TYPE, DOC)
A preprocessor macro used to define fields in C++ "control object" structs.
Definition config.h:43
@ SIGMA_ONLY
Only the diagonal elements of the covariance matrix are provided.
Definition constants.h:45
Simple class used to define and document flags The name and doc constitute the identity of the FlagDe...
Definition FlagHandler.h:40