SourceXtractorPlusPlus 1.0.3
SourceXtractor++, the next generation SExtractor
Loading...
Searching...
No Matches
AperturePhotometryTask.cpp
Go to the documentation of this file.
1
17/*
18 * AperturePhotometryTask.cpp
19 *
20 * Created on: Sep 22, 2016
21 * Author: mschefer
22 */
23
28
30
38
41
43
44namespace 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 auto pixel_centroid = source.getProperty<MeasurementFramePixelCentroid>(m_instance);
59
60 // get the object center
61 const auto& centroid_x = source.getProperty<MeasurementFramePixelCentroid>(m_instance).getCentroidX();
62 const auto& centroid_y = source.getProperty<MeasurementFramePixelCentroid>(m_instance).getCentroidY();
63
64 // m_apertures is the aperture on the detection frame, so we have to wrap it
65 // to transform it to the measurement frame
66 auto jacobian = source.getProperty<JacobianSource>(m_instance);
67
68 std::vector<SeFloat> fluxes, fluxes_error;
69 std::vector<SeFloat> mags, mags_error;
71
72 for (auto aperture_diameter : m_apertures) {
74 std::make_shared<CircularAperture>(aperture_diameter / 2.),
75 jacobian.asTuple()
76 );
77
78 auto measurement = measureFlux(aperture, centroid_x, centroid_y, measurement_image, variance_map,
79 variance_threshold, m_use_symmetry);
80 // compute the derived quantities
81 if (gain > 0) {
82 measurement.m_variance += measurement.m_flux / gain;
83 }
84 auto flux_error = sqrt(measurement.m_variance);
85 auto mag = measurement.m_flux > 0.0 ? -2.5 * log10(measurement.m_flux) + m_magnitude_zero_point : std::numeric_limits<SeFloat>::quiet_NaN();
86 auto mag_error = 1.0857 * flux_error / measurement.m_flux;
87
88 fluxes.push_back(measurement.m_flux);
89 fluxes_error.push_back(flux_error);
90 mags.push_back(mag);
91 mags_error.push_back(mag_error);
92 flags.push_back(measurement.m_flags);
93 }
94
95 // Merge flags with those set on the detection frame and from the saturate and blended plugins
96 Flags additional_flags(Flags::NONE);
97 additional_flags |= Flags::SATURATED * source.getProperty<SaturateFlag>(m_instance).getSaturateFlag();
98 additional_flags |= Flags::BLENDED * source.getProperty<BlendedFlag>().getBlendedFlag();
99
100 try {
101 auto aperture_flags = source.getProperty<ApertureFlag>().getFlags();
102 for (size_t i = 0; i < m_apertures.size(); ++i) {
103 auto det_flag = aperture_flags.at(m_apertures[i]);
104 flags[i] |= additional_flags | det_flag;
105 }
106 } catch (PropertyNotFoundException& e) {
107 // In no detection image mode we can't get flags from the detection image
108 for (size_t i = 0; i < m_apertures.size(); ++i) {
109 flags[i] |= additional_flags;
110 }
111 }
112
113 // set the source properties
114 source.setIndexedProperty<AperturePhotometry>(m_instance, fluxes, fluxes_error, mags, mags_error, flags);
115
116 // draw the apertures onto the checkimage
118 if (aperture_check_img) {
119 auto src_id = source.getProperty<SourceID>().getId();
120 for (auto aperture_diameter : m_apertures) {
122 jacobian.asTuple());
123 drawAperture<int>(aperture, centroid_x, centroid_y, aperture_check_img, static_cast<unsigned>(src_id));
124 }
125
126 }
127}
128
129}
130
Aperture photometry flag.
void computeProperties(SourceInterface &source) const override
Computes one or more properties for the Source.
Aperture photometry fluxes and magnitudes.
std::shared_ptr< WriteableImage< int > > getMeasurementApertureImage(unsigned int frame_number)
static CheckImages & getInstance()
An exception indicating that a Property was not available and could not be computed on demand.
The SourceInterface is an abstract "source" that has properties attached to it.
void setIndexedProperty(std::size_t index, Args... args)
Convenience template method to call setProperty() with a more user-friendly syntax.
const PropertyType & getProperty(unsigned int index=0) const
Convenience template method to call getProperty() with a more user-friendly syntax.
T log10(T... args)
T make_shared(T... args)
Flags
Flagging of bad sources.
Definition SourceFlags.h:37
@ BLENDED
The object was originally blended with another one.
Definition SourceFlags.h:40
@ SATURATED
At least one pixel of the object is saturated.
Definition SourceFlags.h:41
@ NONE
No flag is set.
Definition SourceFlags.h:38
@ LayerVarianceMap
Definition Frame.h:45
@ LayerSubtractedImage
Definition Frame.h:39
void drawAperture(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)
T push_back(T... args)
T quiet_NaN(T... args)
T sqrt(T... args)