LSSTApplications
21.0.0+75b29a8a7f,21.0.0+e70536a077,21.0.0-1-ga51b5d4+62c747d40b,21.0.0-11-ga6ea59e8e+47cba9fc36,21.0.0-2-g103fe59+914993bf7c,21.0.0-2-g1367e85+e2614ded12,21.0.0-2-g45278ab+e70536a077,21.0.0-2-g4bc9b9f+7b2b5f8678,21.0.0-2-g5242d73+e2614ded12,21.0.0-2-g54e2caa+6403186824,21.0.0-2-g7f82c8f+3ac4acbffc,21.0.0-2-g8dde007+04a6aea1af,21.0.0-2-g8f08a60+9402881886,21.0.0-2-ga326454+3ac4acbffc,21.0.0-2-ga63a54e+81dd751046,21.0.0-2-gc738bc1+5f65c6e7a9,21.0.0-2-gde069b7+26c92b3210,21.0.0-2-gecfae73+0993ddc9bd,21.0.0-2-gfc62afb+e2614ded12,21.0.0-21-gba890a8+5a4f502a26,21.0.0-23-g9966ff26+03098d1af8,21.0.0-3-g357aad2+8ad216c477,21.0.0-3-g4be5c26+e2614ded12,21.0.0-3-g6d51c4a+4d2fe0280d,21.0.0-3-g7d9da8d+75b29a8a7f,21.0.0-3-gaa929c8+522e0f12c2,21.0.0-3-ge02ed75+4d2fe0280d,21.0.0-4-g3300ddd+e70536a077,21.0.0-4-gc004bbf+eac6615e82,21.0.0-4-gccdca77+f94adcd104,21.0.0-4-gd1c1571+18b81799f9,21.0.0-5-g7b47fff+4d2fe0280d,21.0.0-5-gb155db7+d2632f662b,21.0.0-5-gdf36809+637e4641ee,21.0.0-6-g722ad07+28c848f42a,21.0.0-7-g959bb79+522e0f12c2,21.0.0-7-gfd72ab2+cf01990774,21.0.0-9-g87fb7b8d+e2ab11cdd6,w.2021.04
LSSTDataManagementBasePackage
|
Go to the documentation of this file.
27 #include "boost/math/constants/constants.hpp"
40 FlagDefinitionList flagDefinitions;
45 flagDefinitions.add(
"flag_noCentroid",
"Object has no centroid");
47 flagDefinitions.add(
"flag_noShape",
"Object has no shape");
55 if (!childFootprint) {
60 childHeavy = std::dynamic_pointer_cast<afw::detection::HeavyFootprint<float>
const>(childFootprint);
75 auto spanIter = childHeavy->getSpans()->begin();
76 auto const spanEnd = childHeavy->getSpans()->end();
77 ChildPixIter childPixIter = childHeavy->getImageArray().begin();
80 while (spanIter != spanEnd) {
81 afw::geom::Span
const& span = *spanIter;
82 ParentPixIter parentPixIter =
83 parentImage.
x_at(span.getBeginX() - parentImage.
getX0(), span.getY() - parentImage.
getY0());
84 int const width = span.getWidth();
86 for (
int x = 0;
x < width; ++parentPixIter, ++childPixIter, ++
x) {
87 cp += (*childPixIter) * ((*parentPixIter) - (*childPixIter));
88 cc += (*childPixIter) * (*childPixIter);
98 class FluxAccumulator {
100 FluxAccumulator() :
_w(0.0),
_ww(0.0),
_wd(0.0) {}
102 void operator()(
double,
double,
float weight,
float data) {
108 double getFlux()
const {
return _w *
_wd /
_ww; }
116 class ShapeAccumulator :
public FluxAccumulator {
118 ShapeAccumulator() : FluxAccumulator(), _wdxx(0.0), _wdyy(0.0), _wdxy(0.0) {}
120 void operator()(
double x,
double y,
float weight,
float data) {
127 ShapeResult getShape()
const {
143 template <
typename Accumulator>
145 afw::geom::ellipses::Quadrupole
const& shape,
double nSigmaWeightMax,
146 Accumulator& accumulatorRaw, Accumulator& accumulatorAbs) {
149 afw::geom::ellipses::Ellipse ellipse(shape,
centroid);
150 ellipse.getCore().scale(nSigmaWeightMax);
161 afw::geom::ellipses::PixelRegion region(ellipse);
162 bool isContained =
bbox.contains(region.getBBox());
163 SpanIter
const spanEnd = region.end();
164 for (SpanIter spanIter = region.begin(); spanIter != spanEnd; ++spanIter) {
165 afw::geom::Span span = *spanIter;
167 if (span.getY() <
bbox.getMinY() || span.getY() >
bbox.getMaxY()) {
170 span = afw::geom::Span(span.getY(),
std::max(span.getMinX(),
bbox.getMinX()),
172 if (span.getMinX() > span.getMaxX()) {
176 PixelIter pixelIter =
image.x_at(span.getBeginX() -
image.getX0(), span.getY() -
image.getY0());
177 PointIter
const pointEnd = span.end();
178 for (PointIter pointIter = span.begin(); pointIter != pointEnd; ++pointIter, ++pixelIter) {
183 float data = pixelIter.image();
184 accumulatorRaw(d.getX(), d.getY(),
weight,
data);
185 float variance = pixelIter.variance();
199 _old =
schema.addField<
double>(
201 "Blendedness from dot products: (child.dot(parent)/child.dot(child) - 1)");
204 _raw =
schema.addField<
double>(
206 "Measure of how much the flux is affected by neighbors: "
207 "(1 - child_instFlux/parent_instFlux). Operates on the \"raw\" pixel values.");
208 _instFluxChildRaw =
schema.addField<
double>(
210 "Instrumental flux of the child, measured with a Gaussian weight matched to the child. "
211 "Operates on the \"raw\" pixel values.",
"count");
212 _instFluxParentRaw =
schema.addField<
double>(
214 "Instrumental flux of the parent, measured with a Gaussian weight matched to the child. "
215 "Operates on the \"raw\" pixel values.",
"count");
216 _abs =
schema.addField<
double>(
218 "Measure of how much the flux is affected by neighbors: "
219 "(1 - child_instFlux/parent_instFlux). "
220 "Operates on the absolute value of the pixels to try to obtain a \"de-noised\" value. "
221 "See section 4.9.11 of Bosch et al. 2018, PASJ, 70, S5 for details.");
222 _instFluxChildAbs =
schema.addField<
double>(
224 "Instrumental flux of the child, measured with a Gaussian weight matched to the child. "
225 "Operates on the absolute value of the pixels to try to obtain a \"de-noised\" value. "
226 "See section 4.9.11 of Bosch et al. 2018, PASJ, 70, S5 for details.",
"count");
227 _instFluxParentAbs =
schema.addField<
double>(
229 "Instrumental flux of the parent, measured with a Gaussian weight matched to the child. "
230 "Operates on the absolute value of the pixels to try to obtain a \"de-noised\" value. "
231 "See section 4.9.11 of Bosch et al. 2018, PASJ, 70, S5 for details.",
"count");
236 "Shape of the child, measured with a Gaussian weight matched to the child. "
240 "Shape of the parent, measured with a Gaussian weight matched to the child. "
244 "Shape of the child, measured with a Gaussian weight matched to the child. "
245 "Operates on the absolute value of the pixels to try to obtain a \"de-noised\" value. "
246 "See section 4.9.11 of Bosch et al. 2018, PASJ, 70, S5 for details.",
250 "Shape of the parent, measured with a Gaussian weight matched to the child. "
251 "Operates on the absolute value of the pixels to try to obtain a \"de-noised\" value. "
252 "See section 4.9.11 of Bosch et al. 2018, PASJ, 70, S5 for details.",
262 if (!(normalization > 0)) {
283 if (!child.
getTable()->getCentroidSlot().getMeasKey().isValid()) {
285 "Centroid Key must be defined to measure the blendedness instFlux");
289 if (!child.
getTable()->getCentroidSlot().getMeasKey().isValid()) {
291 "Shape Key must be defined to measure the blendedness shape");
296 if (child.
getTable()->getCentroidSlot().getFlagKey().isValid()) {
304 if (child.
getTable()->getShapeSlot().getFlagKey().isValid()) {
326 ShapeAccumulator accumulatorRaw;
327 ShapeAccumulator accumulatorAbs;
331 child.
set(instFluxRawKey, accumulatorRaw.getFlux());
332 child.
set(instFluxAbsKey,
std::max(accumulatorAbs.getFlux(), 0.0));
334 _shapeRawKey.
set(child, accumulatorRaw.getShape());
335 _shapeAbsKey.
set(child, accumulatorAbs.getShape());
336 }
else if (_ctrl.
doFlux) {
337 FluxAccumulator accumulatorRaw;
338 FluxAccumulator accumulatorAbs;
341 child.
set(instFluxRawKey, accumulatorRaw.getFlux());
342 child.
set(instFluxAbsKey,
std::max(accumulatorAbs.getFlux(), 0.0));
348 _measureMoments(
image, child, _instFluxChildRaw, _instFluxChildAbs, _shapeChildRaw, _shapeChildAbs);
356 _measureMoments(
image, child, _instFluxParentRaw, _instFluxParentAbs, _shapeParentRaw, _shapeParentAbs);
358 child.
set(_raw, 1.0 - child.
get(_instFluxChildRaw) / child.
get(_instFluxParentRaw));
359 child.
set(_abs, 1.0 - child.
get(_instFluxChildAbs) / child.
get(_instFluxParentAbs));
360 if (child.
get(_instFluxParentAbs) == 0.0) {
SpanPixelIterator Iterator
An iterator over points in the Span.
Backwards-compatibility support for depersisting the old Calib (FluxMag0/FluxMag0Err) objects.
static FlagDefinition const FAILURE
Record class that contains measurements made on a single exposure.
void measureChildPixels(afw::image::MaskedImage< float > const &image, afw::table::SourceRecord &child) const
Field< T >::Value get(Key< T > const &key) const
Return the value of a field for the given key.
@ NO_UNCERTAINTY
Algorithm provides no uncertainy information at all.
std::vector< Span >::const_iterator Iterator
Iterator type used by begin() and end().
CentroidSlotDefinition::MeasValue getCentroid() const
Get the value of the Centroid slot measurement.
Angle abs(Angle const &a)
Defines the fields and offsets for a table.
A FunctorKey for ShapeResult.
Point< double, 2 > Point2D
BlendednessAlgorithm(Control const &ctrl, std::string const &name, afw::table::Schema &schema)
bool doOld
"Whether to compute HeavyFootprint dot products (the old deblend.blendedness parameter)" ;
vector-type utility class to build a collection of FlagDefinitions
void measureParentPixels(afw::image::MaskedImage< float > const &image, afw::table::SourceRecord &child) const
std::shared_ptr< Footprint > getFootprint() const
x_iterator x_at(int x, int y) const
Return an x_iterator to the point (x, y) in the image.
static float computeAbsBias(float mu, float variance)
Compute the bias induced by using the absolute value of a pixel instead of its value.
static FlagDefinitionList const & getFlagDefinitions()
const_MaskedImageIterator< typename Image::x_iterator, typename Mask::x_iterator, typename Variance::x_iterator > const_x_iterator
A const_iterator to a row of a MaskedImage.
void setValue(afw::table::BaseRecord &record, std::size_t i, bool value) const
Set the flag field corresponding to the given flag index.
ShapeSlotDefinition::MeasValue getShape() const
Get the value of the Shape slot measurement.
T computeSquaredNorm() const
Return the squared L2 norm of the Extent (x^2 + y^2 + ...).
A class to manipulate images, masks, and variance as a single object.
UnitVector3d centroid(VertexIterator const begin, VertexIterator const end)
bool doFlux
"Whether to compute quantities related to the Gaussian-weighted flux" ;
static ShapeResultKey addFields(afw::table::Schema &schema, std::string const &name, std::string const &doc, UncertaintyEnum uncertainty, afw::table::CoordinateType coordType=afw::table::CoordinateType::PIXEL)
Add the appropriate fields to a Schema, and return a ShapeResultKey that manages them.
double getX() const
Return the centroid slot x coordinate.
bool contains(Point2I const &point) const noexcept
Return true if the box contains the point.
FastFinder::Iterator Iterator
Reports errors in the logical structure of the program.
afw::table::Key< double > weight
bool getCentroidFlag() const
Return true if the measurement in the Centroid slot failed.
A base class for image defects.
#define LSST_EXCEPT(type,...)
Create an exception with a given type.
double getY() const
Return the centroid slot y coordinate.
std::shared_ptr< SourceTable const > getTable() const
int getX0() const
Return the image's column-origin.
static FlagDefinition const NO_CENTROID
double getDeterminant() const
Return the determinant of the matrix representation.
An integer coordinate rectangle.
int getY0() const
Return the image's row-origin.
bool getShapeFlag() const
Return true if the measurement in the Shape slot failed.
void set(Key< T > const &key, U const &value)
Set value of a field for the given key.
lsst::geom::Box2I getBBox(ImageOrigin origin=PARENT) const
virtual void set(afw::table::BaseRecord &record, ShapeResult const &value) const
Set a ShapeResult in the given record.
_const_view_t::x_iterator const_x_iterator
A const iterator for traversing the pixels in a row.
double nSigmaWeightMax
"Radius factor that sets the maximum extent of the weight function (and hence the " "flux measurement...
bool doShape
"Whether to compute quantities related to the Gaussian-weighted shape" ;
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.
static FlagDefinition const NO_SHAPE
static float computeAbsExpectation(float data, float variance)
Compute the posterior expectation value of the true instrumental flux in a pixel from its (Gaussian) ...