SourceXtractorPlusPlus  0.13
Please provide a description of the project.
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 
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  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;
70  std::vector<Flags> flags;
71 
72  for (auto aperture_diameter : m_apertures) {
73  auto aperture = std::make_shared<TransformedAperture>(
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  auto flux_error = sqrt(measurement.m_variance + measurement.m_flux / gain);
82  auto mag = measurement.m_flux > 0.0 ? -2.5 * log10(measurement.m_flux) + m_magnitude_zero_point : std::numeric_limits<SeFloat>::quiet_NaN();
83  auto mag_error = 1.0857 * flux_error / measurement.m_flux;
84 
85  fluxes.push_back(measurement.m_flux);
86  fluxes_error.push_back(flux_error);
87  mags.push_back(mag);
88  mags_error.push_back(mag_error);
89  flags.push_back(measurement.m_flags);
90  }
91 
92  // Merge flags with those set on the detection frame and from the saturate and blended plugins
93  Flags additional_flags(Flags::NONE);
94  additional_flags |= Flags::SATURATED * source.getProperty<SaturateFlag>(m_instance).getSaturateFlag();
95  additional_flags |= Flags::BLENDED * source.getProperty<BlendedFlag>().getBlendedFlag();
96 
97  auto aperture_flags = source.getProperty<ApertureFlag>().getFlags();
98  for (size_t i = 0; i < m_apertures.size(); ++i) {
99  auto det_flag = aperture_flags.at(m_apertures[i]);
100  flags[i] |= additional_flags | det_flag;
101  }
102 
103  // set the source properties
104  source.setIndexedProperty<AperturePhotometry>(m_instance, fluxes, fluxes_error, mags, mags_error, flags);
105 
106  // Draw the last aperture
107  auto aperture = std::make_shared<TransformedAperture>(std::make_shared<CircularAperture>(m_apertures[0] / 2.),
108  jacobian.asTuple());
109 
110  auto aperture_check_img = CheckImages::getInstance().getApertureImage(m_instance);
111  if (aperture_check_img) {
112  auto src_id = source.getProperty<SourceID>().getId();
113  fillAperture<int>(aperture, centroid_x, centroid_y, aperture_check_img, static_cast<unsigned>(src_id));
114  }
115 }
116 
117 }
118 
MeasurementFrameInfo.h
Jacobian.h
SourceXtractor::AperturePhotometryTask::m_use_symmetry
bool m_use_symmetry
Definition: AperturePhotometryTask.h:50
FluxMeasurement.h
CheckImages.h
SourceXtractor::BlendedFlag
Definition: BlendedFlag.h:31
MeasurementFramePixelCentroid.h
SourceXtractor::MeasurementFramePixelCentroid
Definition: MeasurementFramePixelCentroid.h:31
SourceXtractor::CheckImages::getApertureImage
std::shared_ptr< WriteableImage< int > > getApertureImage() const
Definition: CheckImages.h:86
std::numeric_limits::quiet_NaN
T quiet_NaN(T... args)
std::vector< SeFloat >
std::vector::size
T size(T... args)
TransformedAperture.h
SourceXtractor::Flags
Flags
Flagging of bad sources.
Definition: SourceFlags.h:34
SourceXtractor::LayerVarianceMap
@ LayerVarianceMap
Definition: Frame.h:44
SourceID.h
SourceFlags.h
SourceXtractor::SourceID
Definition: SourceID.h:33
SourceXtractor::MeasurementFrameImages
Definition: MeasurementFrameImages.h:31
std::sqrt
T sqrt(T... args)
std::vector::push_back
T push_back(T... args)
CircularAperture.h
SourceXtractor::CheckImages::getInstance
static CheckImages & getInstance()
Definition: CheckImages.h:136
SourceXtractor
Definition: Aperture.h:30
AperturePhotometryTask.h
SourceXtractor::MeasurementFrameInfo
Definition: MeasurementFrameInfo.h:28
SourceXtractor::AperturePhotometryTask::computeProperties
virtual void computeProperties(SourceInterface &source) const override
Computes one or more properties for the Source.
Definition: AperturePhotometryTask.cpp:48
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::AperturePhotometryTask::m_apertures
std::vector< SeFloat > m_apertures
Definition: AperturePhotometryTask.h:47
SourceXtractor::AperturePhotometry
Aperture photometry fluxes and magnitudes.
Definition: AperturePhotometry.h:38
SourceXtractor::AperturePhotometryTask::m_magnitude_zero_point
SeFloat m_magnitude_zero_point
Definition: AperturePhotometryTask.h:49
SourceXtractor::JacobianSource
Definition: Jacobian.h:51
AperturePhotometry.h
SaturateFlag.h
SourceXtractor::SaturateFlag
Definition: SaturateFlag.h:46
std::log10
T log10(T... args)
ApertureFlag.h
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
SourceXtractor::AperturePhotometryTask::m_instance
unsigned int m_instance
Definition: AperturePhotometryTask.h:48
BlendedFlag.h
SourceXtractor::LayerSubtractedImage
@ LayerSubtractedImage
Definition: Frame.h:38
SourceXtractor::SourceInterface
The SourceInterface is an abstract "source" that has properties attached to it.
Definition: SourceInterface.h:46
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:49
MeasurementFrameImages.h
SourceXtractor::ApertureFlag
Aperture photometry flag.
Definition: ApertureFlag.h:38