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
EllipticalApertureFlux.cc
Go to the documentation of this file.
1 // -*- LSST-C++ -*-
2 
3 /*
4  * LSST Data Management System
5  * Copyright 2008, 2009, 2010 LSST Corporation.
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 #include <cmath>
25 #include <limits>
26 #include <numeric>
27 #include "lsst/pex/exceptions.h"
28 #include "lsst/pex/logging/Trace.h"
29 #include "lsst/afw/image.h"
30 #include "lsst/afw/geom.h"
31 #include "lsst/afw/geom/ellipses.h"
32 #include "lsst/afw/detection/Psf.h"
36 
37 namespace lsst {
38 namespace meas {
39 namespace algorithms {
40 
46 public:
48  ApertureFlux(ctrl, schema)
49  {}
50 
51 private:
52 
53  template <typename PixelT>
54  void _apply(
55  afw::table::SourceRecord & source,
56  afw::image::Exposure<PixelT> const & exposure,
57  afw::geom::Point2D const & center
58  ) const;
59 
61 };
62 
63 /************************************************************************************************************/
67 template <typename PixelT>
69  afw::table::SourceRecord & source,
70  afw::image::Exposure<PixelT> const& exposure,
71  afw::geom::Point2D const & center
72 ) const {
73  source.set(_flagKey, true); // say we've failed so that's the result if we throw
74  source.set(_nProfileKey, 0); // no points measured
75 
76  if (source.getShapeFlag()) { // the shape's bad; give up now
77  return;
78  }
79  afw::geom::ellipses::Axes const shape = source.getShape();
80 
81  VectorD const & radii = static_cast<EllipticalApertureFluxControl const &>(getControl()).radii;
82  int const nradii = radii.size();
83 
84  typename afw::image::Exposure<PixelT>::MaskedImageT const& mimage = exposure.getMaskedImage();
85  double oradius = 0.0; // old size of shape
86  double const fac = 1.0/::sqrt(shape.getA()*shape.getB()); // conversion between radii and semi-major axis
87  for (int i = 0; i != nradii; ++i) {
88  afw::geom::ellipses::Axes outer(shape);
89  outer.scale(fac*radii[i]);
90 
91  std::pair<double, double> flux =
93  afw::geom::ellipses::Ellipse(outer, center),
94  oradius/outer.getA());
95  oradius = outer.getA();
96 
97  source.set(_fluxKey[i], flux.first);
98  source.set(_errKey[i], flux.second);
99  }
100  source.set(_nProfileKey, nradii);
101  source.set(_flagKey, false);
102 }
103 
105 
107  return boost::make_shared<EllipticalApertureFluxControl>(*this);
108 }
109 
111  afw::table::Schema & schema,
112  PTR(daf::base::PropertyList) const & metadata
113 ) const {
114  if (metadata) {
115  std::string key = this->name + ".radii";
116  std::replace(key.begin(), key.end(), '.', '_');
117  metadata->add(key, radii, "Radii for aperture flux measurement");
118  }
119  return boost::make_shared<EllipticalApertureFlux>(*this, boost::ref(schema));
120 }
121 
122 }}}
Defines the fields and offsets for a table.
Definition: Schema.h:46
An include file to include the header files for lsst::afw::geom.
#define PTR(...)
Definition: base.h:41
C++ control object for elliptical aperture fluxes.
Definition: FluxControl.h:134
Public header class for ellipse library.
double const getB() const
Definition: Axes.h:56
Class for storing ordered metadata with comments.
Definition: PropertyList.h:81
definition of the Trace messaging facilities
void _apply(afw::table::SourceRecord &source, afw::image::Exposure< PixelT > const &exposure, afw::geom::Point2D const &center) const
Given an image and a source position, calculate a set of fluxes in elliptical apertures.
ShapeSlotDefinition::MeasValue getShape() const
Get the value of the Shape slot measurement.
Definition: Source.h:821
A class that knows how to calculate fluxes as a simple sum over a Footprint.
AlgorithmControl const & getControl() const
Return a clone of the control object used to construct the algorithm.
Definition: Algorithm.h:120
std::pair< double, double > calculateSincApertureFlux(MaskedImageT const &mimage, afw::geom::ellipses::Ellipse const &ellipse, double const innerFactor)
Definition: SincFlux.cc:687
An include file to include the header files for lsst::afw::image.
Base class for source measurement algorithms.
Definition: Algorithm.h:106
Base class for measurement algorithm control objects.
Definition: Algorithm.h:168
double const getA() const
Definition: Axes.h:53
Include files required for standard LSST Exception handling.
MaskedImageT getMaskedImage()
Return the MaskedImage.
Definition: Exposure.h:150
tbl::Schema schema
Definition: CoaddPsf.cc:324
An ellipse defined by an arbitrary BaseCore and a center point.
Definition: Ellipse.h:50
void scale(double factor)
Scale the size of the ellipse core by the given factor.
EllipticalApertureFlux(EllipticalApertureFluxControl const &ctrl, afw::table::Schema &schema)
afw::table::Key< afw::table::Array< double > > _errKey
Definition: ApertureFlux.h:57
An ellipse core for the semimajor/semiminor axis and position angle parametrization (a...
Definition: Axes.h:45
afw::table::Key< afw::table::Flag > _flagKey
Definition: ApertureFlux.h:59
void set(Key< T > const &key, U const &value)
Set value of a field for the given key.
Definition: BaseRecord.h:136
A class that knows how to calculate fluxes as a simple sum over a Footprint.
Definition: ApertureFlux.h:39
Record class that contains measurements made on a single exposure.
Definition: Source.h:81
LSST_MEAS_ALGORITHM_PRIVATE_IMPLEMENTATION(ApertureFlux)
afw::table::Key< afw::table::Array< double > > _fluxKey
Definition: ApertureFlux.h:56
LSST_MEAS_ALGORITHM_PRIVATE_INTERFACE(EllipticalApertureFlux)
afw::table::Key< int > _nProfileKey
Definition: ApertureFlux.h:58
bool getShapeFlag() const
Return true if the measurement in the Shape slot failed.
Definition: Source.h:829