SourceXtractorPlusPlus  0.8
Please provide a description of the project.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
AutoPhotometryTask.cpp
Go to the documentation of this file.
1 
17 /*
18  * AutoPhotometryTask.cpp
19  *
20  * Created on: Jul 18, 2016
21  * Author: mkuemmel@usm.lmu.de
22  */
23 
41 
42 
43 namespace SourceXtractor {
44 
46 
49 
50  // get the measurement frame
51  const auto& measurement_frame = source.getProperty<MeasurementFrame>(m_instance).getFrame();
52 
53  // get the images and image information from the frame
54  const auto& measurement_image = measurement_frame->getSubtractedImage();
55  const auto& variance_map = measurement_frame->getVarianceMap();
56  const auto& variance_threshold = measurement_frame->getVarianceThreshold();
57  SeFloat gain = measurement_frame->getGain();
58 
59  // get the object center
60  const auto& centroid_x = source.getProperty<MeasurementFramePixelCentroid>(m_instance).getCentroidX();
61  const auto& centroid_y = source.getProperty<MeasurementFramePixelCentroid>(m_instance).getCentroidY();
62 
63  // get the shape parameters
64  const auto& cxx = source.getProperty<ShapeParameters>().getEllipseCxx();
65  const auto& cyy = source.getProperty<ShapeParameters>().getEllipseCyy();
66  const auto& cxy = source.getProperty<ShapeParameters>().getEllipseCxy();
67 
68  // get the jacobian
69  const auto& jacobian = source.getProperty<JacobianSource>(m_instance);
70 
71  // get the kron-radius
72  SeFloat kron_radius_auto = m_kron_factor * source.getProperty<KronRadius>().getKronRadius();
73  if (kron_radius_auto < m_kron_minrad)
74  kron_radius_auto = m_kron_minrad;
75 
76  // create the elliptical aperture
77  auto ell_aper = std::make_shared<TransformedAperture>(
78  std::make_shared<EllipticalAperture>(cxx, cyy, cxy, kron_radius_auto),
79  jacobian.asTuple());
80 
81  auto measurement = measureFlux(ell_aper, centroid_x, centroid_y, measurement_image, variance_map, variance_threshold,
83 
84  // compute the derived quantities
85  auto flux_error = sqrt(measurement.m_variance + measurement.m_flux / gain);
86  auto mag = measurement.m_flux > 0.0 ? -2.5 * log10(measurement.m_flux) + m_magnitude_zero_point : std::numeric_limits<SeFloat>::quiet_NaN();
87  auto mag_error = 1.0857 * flux_error / measurement.m_flux;
88 
89  // Add the flags from the detection image and from the saturated and blended plugins
90  measurement.m_flags |= source.getProperty<AutoPhotometryFlag>().getFlags();
91  measurement.m_flags |= Flags::SATURATED * source.getProperty<SaturateFlag>(m_instance).getSaturateFlag();
92  measurement.m_flags |= Flags::BLENDED * source.getProperty<BlendedFlag>().getBlendedFlag();
93 
94  // set the source properties
95  source.setIndexedProperty<AutoPhotometry>(m_instance, measurement.m_flux, flux_error, mag, mag_error, measurement.m_flags);
96 
97  // Draw the aperture
98  auto coord_system = measurement_frame->getCoordinateSystem();
99  auto aperture_check_img = CheckImages::getInstance().getAutoApertureImage(measurement_frame);
100  if (aperture_check_img) {
101  auto src_id = source.getProperty<SourceID>().getId();
102 
103  fillAperture(ell_aper, centroid_x, centroid_y, aperture_check_img, static_cast<unsigned>(src_id));
104  }
105 }
106 
107 }
std::shared_ptr< WriteableImage< unsigned int > > getAutoApertureImage() const
Definition: CheckImages.h:64
const PropertyType & getProperty(unsigned int index=0) const
Convenience template method to call getProperty() with a more user-friendly syntax.
void setIndexedProperty(std::size_t index, Args...args)
Convenience template method to call setProperty() with a more user-friendly syntax.
SeFloat32 SeFloat
Definition: Types.h:32
Auto photometry flux and magnitude.
T log10(T...args)
static CheckImages & getInstance()
Definition: CheckImages.h:114
T lock(T...args)
At least one pixel of the object is saturated.
virtual void computeProperties(SourceInterface &source) const override
Computes one or more properties for the Source.
The object was originally blended with another one.
T quiet_NaN(T...args)
T sqrt(T...args)
The SourceInterface is an abstract &quot;source&quot; that has properties attached to it.
void fillAperture(const std::shared_ptr< Aperture > &aperture, SeFloat centroid_x, SeFloat centroid_y, const std::shared_ptr< WriteableImage< T >> &img, T value)
FluxMeasurement measureFlux(const std::shared_ptr< Aperture > &aperture, SeFloat centroid_x, SeFloat centroid_y, const std::shared_ptr< Image< SeFloat >> &img, const std::shared_ptr< Image< SeFloat >> &variance_map, SeFloat variance_threshold, bool use_symmetry)