SourceXtractorPlusPlus  0.11
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 
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 
MeasurementFrame.h
SourceXtractor::CheckImages::getApertureImage
std::shared_ptr< WriteableImage< unsigned int > > getApertureImage() const
Definition: CheckImages.h:68
std::lock
T lock(T... args)
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
std::numeric_limits::quiet_NaN
T quiet_NaN(T... args)
SourceXtractor::SeFloat
SeFloat32 SeFloat
Definition: Types.h:32
std::vector< SeFloat >
std::vector::size
T size(T... args)
TransformedAperture.h
std::lock_guard
STL class.
SourceXtractor::Flags
Flags
Flagging of bad sources.
Definition: SourceFlags.h:34
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)
std::vector::push_back
T push_back(T... args)
CircularAperture.h
SourceXtractor::Flags::SATURATED
@ SATURATED
At least one pixel of the object is saturated.
SourceXtractor::CheckImages::getInstance
static CheckImages & getInstance()
Definition: CheckImages.h:114
SourceXtractor
Definition: Aperture.h:30
AperturePhotometryTask.h
SourceXtractor::AperturePhotometryTask::computeProperties
virtual void computeProperties(SourceInterface &source) const override
Computes one or more properties for the Source.
Definition: AperturePhotometryTask.cpp:45
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::MeasurementFrame
Definition: MeasurementFrame.h:36
SourceXtractor::AperturePhotometryTask::m_magnitude_zero_point
SeFloat m_magnitude_zero_point
Definition: AperturePhotometryTask.h:49
SourceXtractor::JacobianSource
Definition: Jacobian.h:51
AperturePhotometry.h
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::Flags::NONE
@ NONE
No flag is set.
SourceXtractor::SaturateFlag
Definition: SaturateFlag.h:46
MultithreadedMeasurement.h
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::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
SourceXtractor::ApertureFlag
Aperture photometry flag.
Definition: ApertureFlag.h:38