SourceXtractorPlusPlus  0.10
Please provide a description of the project.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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 
39 
40 
41 namespace SourceXtractor {
42 
44 
47 
48  auto measurement_frame = source.getProperty<MeasurementFrame>(m_instance).getFrame();
49  auto measurement_image = measurement_frame->getSubtractedImage();
50  auto variance_map = measurement_frame->getVarianceMap();
51  auto variance_threshold = measurement_frame->getVarianceThreshold();
52  SeFloat gain = measurement_frame->getGain();
53  auto pixel_centroid = source.getProperty<MeasurementFramePixelCentroid>(m_instance);
54 
55  // get the object center
56  const auto& centroid_x = source.getProperty<MeasurementFramePixelCentroid>(m_instance).getCentroidX();
57  const auto& centroid_y = source.getProperty<MeasurementFramePixelCentroid>(m_instance).getCentroidY();
58 
59  // m_apertures is the aperture on the detection frame, so we have to wrap it
60  // to transform it to the measurement frame
61  auto jacobian = source.getProperty<JacobianSource>(m_instance);
62 
63  std::vector<SeFloat> fluxes, fluxes_error;
64  std::vector<SeFloat> mags, mags_error;
65  std::vector<Flags> flags;
66 
67  for (auto aperture_diameter : m_apertures) {
68  auto aperture = std::make_shared<TransformedAperture>(
69  std::make_shared<CircularAperture>(aperture_diameter / 2.),
70  jacobian.asTuple()
71  );
72 
73  auto measurement = measureFlux(aperture, centroid_x, centroid_y, measurement_image, variance_map,
74  variance_threshold, m_use_symmetry);
75  // compute the derived quantities
76  auto flux_error = sqrt(measurement.m_variance + measurement.m_flux / gain);
77  auto mag = measurement.m_flux > 0.0 ? -2.5 * log10(measurement.m_flux) + m_magnitude_zero_point : std::numeric_limits<SeFloat>::quiet_NaN();
78  auto mag_error = 1.0857 * flux_error / measurement.m_flux;
79 
80  fluxes.push_back(measurement.m_flux);
81  fluxes_error.push_back(flux_error);
82  mags.push_back(mag);
83  mags_error.push_back(mag_error);
84  flags.push_back(measurement.m_flags);
85  }
86 
87  // Merge flags with those set on the detection frame and from the saturate and blended plugins
88  Flags additional_flags(Flags::NONE);
89  additional_flags |= Flags::SATURATED * source.getProperty<SaturateFlag>(m_instance).getSaturateFlag();
90  additional_flags |= Flags::BLENDED * source.getProperty<BlendedFlag>().getBlendedFlag();
91 
92  auto aperture_flags = source.getProperty<ApertureFlag>().getFlags();
93  for (size_t i = 0; i < m_apertures.size(); ++i) {
94  auto det_flag = aperture_flags.at(m_apertures[i]);
95  flags[i] |= additional_flags | det_flag;
96  }
97 
98  // set the source properties
99  source.setIndexedProperty<AperturePhotometry>(m_instance, fluxes, fluxes_error, mags, mags_error, flags);
100 
101  // Draw the last aperture
102  auto aperture = std::make_shared<TransformedAperture>(std::make_shared<CircularAperture>(m_apertures[0] / 2.),
103  jacobian.asTuple());
104  auto coord_system = measurement_frame->getCoordinateSystem();
105  auto aperture_check_img = CheckImages::getInstance().getApertureImage(measurement_frame);
106  if (aperture_check_img) {
107  auto src_id = source.getProperty<SourceID>().getId();
108  fillAperture(aperture, centroid_x, centroid_y, aperture_check_img, static_cast<unsigned>(src_id));
109  }
110 }
111 
112 }
113 
const PropertyType & getProperty(unsigned int index=0) const
Convenience template method to call getProperty() with a more user-friendly syntax.
Aperture photometry fluxes and magnitudes.
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
T log10(T...args)
T push_back(T...args)
virtual void computeProperties(SourceInterface &source) const override
Computes one or more properties for the Source.
static CheckImages & getInstance()
Definition: CheckImages.h:114
T lock(T...args)
std::shared_ptr< WriteableImage< unsigned int > > getApertureImage() const
Definition: CheckImages.h:68
At least one pixel of the object is saturated.
Flags
Flagging of bad sources.
Definition: SourceFlags.h:34
Aperture photometry flag.
Definition: ApertureFlag.h:38
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)