SourceXtractorPlusPlus  0.11
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 
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 total_variance = measurement.m_variance;
86  if (gain >0.0)
87  total_variance += measurement.m_flux / gain;
88  auto flux_error = sqrt(total_variance);
89  auto mag = measurement.m_flux > 0.0 ? -2.5 * log10(measurement.m_flux) + m_magnitude_zero_point : std::numeric_limits<SeFloat>::quiet_NaN();
90  auto mag_error = 1.0857 * flux_error / measurement.m_flux;
91 
92  // Add the flags from the detection image and from the saturated and blended plugins
93  measurement.m_flags |= source.getProperty<AutoPhotometryFlag>().getFlags();
94  measurement.m_flags |= Flags::SATURATED * source.getProperty<SaturateFlag>(m_instance).getSaturateFlag();
95  measurement.m_flags |= Flags::BLENDED * source.getProperty<BlendedFlag>().getBlendedFlag();
96 
97  // set the source properties
98  source.setIndexedProperty<AutoPhotometry>(m_instance, measurement.m_flux, flux_error, mag, mag_error, measurement.m_flags);
99 
100  // Draw the aperture
101  auto coord_system = measurement_frame->getCoordinateSystem();
102  auto aperture_check_img = CheckImages::getInstance().getAutoApertureImage(measurement_frame);
103  if (aperture_check_img) {
104  auto src_id = source.getProperty<SourceID>().getId();
105 
106  fillAperture(ell_aper, centroid_x, centroid_y, aperture_check_img, static_cast<unsigned>(src_id));
107  }
108 }
109 
110 }
SourceXtractor::AutoPhotometryFlag
Definition: AutoPhotometryFlag.h:34
MeasurementFrame.h
std::lock
T lock(T... args)
Jacobian.h
FluxMeasurement.h
CheckImages.h
SourceXtractor::BlendedFlag
Definition: BlendedFlag.h:31
SourceXtractor::AutoPhotometryTask::m_magnitude_zero_point
SeFloat m_magnitude_zero_point
Definition: AutoPhotometryTask.h:49
MeasurementFramePixelCentroid.h
SourceXtractor::MeasurementFramePixelCentroid
Definition: MeasurementFramePixelCentroid.h:31
SourceXtractor::AutoPhotometry
Auto photometry flux and magnitude.
Definition: AutoPhotometry.h:37
std::numeric_limits::quiet_NaN
T quiet_NaN(T... args)
SourceXtractor::SeFloat
SeFloat32 SeFloat
Definition: Types.h:32
AutoPhotometryTask.h
SourceXtractor::AutoPhotometryTask::m_instance
unsigned m_instance
Definition: AutoPhotometryTask.h:48
SourceXtractor::KronRadius
Kron radius.
Definition: KronRadius.h:36
TransformedAperture.h
std::lock_guard
STL class.
SourceXtractor::AutoPhotometryTask::m_use_symmetry
bool m_use_symmetry
Definition: AutoPhotometryTask.h:52
SourceXtractor::MultithreadedMeasurement::g_global_mutex
static std::recursive_mutex g_global_mutex
Definition: MultithreadedMeasurement.h:54
SourceID.h
SourceFlags.h
SourceXtractor::SourceID
Definition: SourceID.h:33
std::sqrt
T sqrt(T... args)
EllipticalAperture.h
SourceXtractor::Flags::SATURATED
@ SATURATED
At least one pixel of the object is saturated.
SourceXtractor::CheckImages::getAutoApertureImage
std::shared_ptr< WriteableImage< unsigned int > > getAutoApertureImage() const
Definition: CheckImages.h:64
SourceXtractor::AutoPhotometryTask::m_kron_minrad
SeFloat m_kron_minrad
Definition: AutoPhotometryTask.h:51
SourceXtractor::CheckImages::getInstance
static CheckImages & getInstance()
Definition: CheckImages.h:114
SourceXtractor
Definition: Aperture.h:30
SourceXtractor::SourceInterface::setIndexedProperty
void setIndexedProperty(std::size_t index, Args... args)
Convenience template method to call setProperty() with a more user-friendly syntax.
Definition: SourceInterface.h:64
SourceXtractor::AutoPhotometryTask::m_kron_factor
SeFloat m_kron_factor
Definition: AutoPhotometryTask.h:50
SourceXtractor::MeasurementFrame
Definition: MeasurementFrame.h:36
SourceXtractor::JacobianSource
Definition: Jacobian.h:51
SourceXtractor::fillAperture
void fillAperture(const std::shared_ptr< Aperture > &aperture, SeFloat centroid_x, SeFloat centroid_y, const std::shared_ptr< WriteableImage< T >> &img, T value)
Definition: FluxMeasurement.h:81
SaturateFlag.h
SourceXtractor::SaturateFlag
Definition: SaturateFlag.h:46
MultithreadedMeasurement.h
std::log10
T log10(T... args)
SourceXtractor::SourceInterface::getProperty
const PropertyType & getProperty(unsigned int index=0) const
Convenience template method to call getProperty() with a more user-friendly syntax.
Definition: SourceInterface.h:57
BlendedFlag.h
ShapeParameters.h
AutoPhotometryFlag.h
SourceXtractor::SourceInterface
The SourceInterface is an abstract "source" that has properties attached to it.
Definition: SourceInterface.h:46
SourceXtractor::Flags::BLENDED
@ BLENDED
The object was originally blended with another one.
SourceXtractor::measureFlux
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)
Definition: FluxMeasurement.cpp:32
AutoPhotometry.h
SourceXtractor::ShapeParameters
Definition: ShapeParameters.h:32
SourceXtractor::AutoPhotometryTask::computeProperties
virtual void computeProperties(SourceInterface &source) const override
Computes one or more properties for the Source.
Definition: AutoPhotometryTask.cpp:47
KronRadius.h