SourceXtractorPlusPlus  0.12
Please provide a description of the project.
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 
28 
42 
43 
44 namespace SourceXtractor {
45 
47 
49  const auto& measurement_frame_info = source.getProperty<MeasurementFrameInfo>(m_instance);
50  const auto& measurement_frame_images = source.getProperty<MeasurementFrameImages>(m_instance);
51 
52  auto variance_threshold = measurement_frame_info.getVarianceThreshold();
53  auto gain = measurement_frame_info.getGain();
54 
55  const auto measurement_image = measurement_frame_images.getLockedImage(LayerSubtractedImage);
56  const auto variance_map = measurement_frame_images.getLockedImage(LayerVarianceMap);
57 
58  // get the object center
59  const auto& centroid_x = source.getProperty<MeasurementFramePixelCentroid>(m_instance).getCentroidX();
60  const auto& centroid_y = source.getProperty<MeasurementFramePixelCentroid>(m_instance).getCentroidY();
61 
62  // get the shape parameters
63  const auto& cxx = source.getProperty<ShapeParameters>().getEllipseCxx();
64  const auto& cyy = source.getProperty<ShapeParameters>().getEllipseCyy();
65  const auto& cxy = source.getProperty<ShapeParameters>().getEllipseCxy();
66 
67  // get the jacobian
68  const auto& jacobian = source.getProperty<JacobianSource>(m_instance);
69 
70  // get the kron-radius
71  SeFloat kron_radius_auto = m_kron_factor * source.getProperty<KronRadius>().getKronRadius();
72  if (kron_radius_auto < m_kron_minrad)
73  kron_radius_auto = m_kron_minrad;
74 
75  // create the elliptical aperture
76  auto ell_aper = std::make_shared<TransformedAperture>(
77  std::make_shared<EllipticalAperture>(cxx, cyy, cxy, kron_radius_auto),
78  jacobian.asTuple());
79 
80  auto measurement = measureFlux(ell_aper, centroid_x, centroid_y, measurement_image, variance_map, variance_threshold,
82 
83  // compute the derived quantities
84  auto total_variance = measurement.m_variance;
85  if (gain >0.0)
86  total_variance += measurement.m_flux / gain;
87  auto flux_error = sqrt(total_variance);
88  auto mag = measurement.m_flux > 0.0 ? -2.5 * log10(measurement.m_flux) + m_magnitude_zero_point : std::numeric_limits<SeFloat>::quiet_NaN();
89  auto mag_error = 1.0857 * flux_error / measurement.m_flux;
90 
91  // Add the flags from the detection image and from the saturated and blended plugins
92  measurement.m_flags |= source.getProperty<AutoPhotometryFlag>().getFlags();
93  measurement.m_flags |= Flags::SATURATED * source.getProperty<SaturateFlag>(m_instance).getSaturateFlag();
94  measurement.m_flags |= Flags::BLENDED * source.getProperty<BlendedFlag>().getBlendedFlag();
95 
96  // set the source properties
97  source.setIndexedProperty<AutoPhotometry>(m_instance, measurement.m_flux, flux_error, mag, mag_error, measurement.m_flags);
98 
99  // Draw the aperture
100  auto aperture_check_img = CheckImages::getInstance().getAutoApertureImage(m_instance);
101  if (aperture_check_img) {
102  auto src_id = source.getProperty<SourceID>().getId();
103 
104  fillAperture(ell_aper, centroid_x, centroid_y, aperture_check_img, static_cast<unsigned>(src_id));
105  }
106 }
107 
108 }
SeFloat32 SeFloat
Definition: Types.h:32
Auto photometry flux and magnitude.
std::shared_ptr< WriteableImage< unsigned int > > getAutoApertureImage() const
Definition: CheckImages.h:78
T log10(T... args)
static CheckImages & getInstance()
Definition: CheckImages.h:136
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.
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 "source" 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)