SourceXtractorPlusPlus
0.21
SourceXtractor++, the next generation SExtractor
Loading...
Searching...
No Matches
SEImplementation
src
lib
Plugin
AperturePhotometry
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
24
#include "
SEFramework/Aperture/CircularAperture.h
"
25
#include "
SEFramework/Aperture/FluxMeasurement.h
"
26
#include "
SEFramework/Aperture/TransformedAperture.h
"
27
#include "
SEFramework/Source/SourceFlags.h
"
28
29
#include "
SEImplementation/CheckImages/CheckImages.h
"
30
31
#include "
SEImplementation/Plugin/BlendedFlag/BlendedFlag.h
"
32
#include "
SEImplementation/Plugin/SaturateFlag/SaturateFlag.h
"
33
#include <
SEImplementation/Plugin/MeasurementFrameInfo/MeasurementFrameInfo.h
>
34
#include <
SEImplementation/Plugin/MeasurementFrameImages/MeasurementFrameImages.h
>
35
#include "
SEImplementation/Plugin/MeasurementFramePixelCentroid/MeasurementFramePixelCentroid.h
"
36
#include "
SEImplementation/Plugin/Jacobian/Jacobian.h
"
37
#include "
SEImplementation/Plugin/SourceIDs/SourceID.h
"
38
39
#include "
SEImplementation/Plugin/AperturePhotometry/AperturePhotometry.h
"
40
#include "
SEImplementation/Plugin/AperturePhotometry/ApertureFlag.h
"
41
42
#include "
SEImplementation/Plugin/AperturePhotometry/AperturePhotometryTask.h
"
43
44
namespace
SourceXtractor
{
45
47
48
void
AperturePhotometryTask::computeProperties
(
SourceInterface
&
source
)
const
{
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
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
auto
aperture_flags
=
source
.getProperty<
ApertureFlag
>().getFlags();
101
for
(
size_t
i
= 0;
i
<
m_apertures
.
size
(); ++
i
) {
102
auto
det_flag
=
aperture_flags
.at(
m_apertures
[
i
]);
103
flags[
i
] |=
additional_flags
|
det_flag
;
104
}
105
106
// set the source properties
107
source
.setIndexedProperty<
AperturePhotometry
>(
m_instance
,
fluxes
,
fluxes_error
,
mags
,
mags_error
, flags);
108
109
// draw the apertures onto the checkimage
110
auto
aperture_check_img
=
CheckImages::getInstance
().getMeasurementApertureImage(
m_instance
);
111
if
(
aperture_check_img
) {
112
auto
src_id
=
source
.getProperty<
SourceID
>().getId();
113
for
(
auto
aperture_diameter
:
m_apertures
) {
114
auto
aperture
=
std::make_shared<TransformedAperture>
(
std::make_shared<CircularAperture>
(
aperture_diameter
/ 2.),
115
jacobian
.asTuple());
116
drawAperture<int>
(
aperture
,
centroid_x
,
centroid_y
,
aperture_check_img
,
static_cast<
unsigned
>
(
src_id
));
117
}
118
119
}
120
}
121
122
}
123
ApertureFlag.h
AperturePhotometryTask.h
AperturePhotometry.h
BlendedFlag.h
CheckImages.h
CircularAperture.h
FluxMeasurement.h
Jacobian.h
MeasurementFrameImages.h
MeasurementFrameInfo.h
MeasurementFramePixelCentroid.h
SourceFlags.h
SaturateFlag.h
SourceID.h
TransformedAperture.h
SourceXtractor::ApertureFlag
Aperture photometry flag.
Definition
ApertureFlag.h:38
SourceXtractor::AperturePhotometryTask::computeProperties
void computeProperties(SourceInterface &source) const override
Computes one or more properties for the Source.
Definition
AperturePhotometryTask.cpp:48
SourceXtractor::AperturePhotometryTask::m_instance
unsigned int m_instance
Definition
AperturePhotometryTask.h:48
SourceXtractor::AperturePhotometryTask::m_apertures
std::vector< SeFloat > m_apertures
Definition
AperturePhotometryTask.h:47
SourceXtractor::AperturePhotometryTask::m_magnitude_zero_point
SeFloat m_magnitude_zero_point
Definition
AperturePhotometryTask.h:49
SourceXtractor::AperturePhotometryTask::m_use_symmetry
bool m_use_symmetry
Definition
AperturePhotometryTask.h:50
SourceXtractor::AperturePhotometry
Aperture photometry fluxes and magnitudes.
Definition
AperturePhotometry.h:38
SourceXtractor::BlendedFlag
Definition
BlendedFlag.h:31
SourceXtractor::CheckImages::getInstance
static CheckImages & getInstance()
Definition
CheckImages.h:158
SourceXtractor::JacobianSource
Definition
Jacobian.h:51
SourceXtractor::MeasurementFrameImages
Definition
MeasurementFrameImages.h:31
SourceXtractor::MeasurementFrameInfo
Definition
MeasurementFrameInfo.h:28
SourceXtractor::MeasurementFramePixelCentroid
Definition
MeasurementFramePixelCentroid.h:31
SourceXtractor::SaturateFlag
Definition
SaturateFlag.h:46
SourceXtractor::SourceID
Definition
SourceID.h:33
SourceXtractor::SourceInterface
The SourceInterface is an abstract "source" that has properties attached to it.
Definition
SourceInterface.h:46
std::function
std::log10
T log10(T... args)
SourceXtractor
Definition
Aperture.h:30
SourceXtractor::Flags
Flags
Flagging of bad sources.
Definition
SourceFlags.h:37
SourceXtractor::Flags::BLENDED
@ BLENDED
The object was originally blended with another one.
SourceXtractor::Flags::SATURATED
@ SATURATED
At least one pixel of the object is saturated.
SourceXtractor::Flags::NONE
@ NONE
No flag is set.
SourceXtractor::LayerVarianceMap
@ LayerVarianceMap
Definition
Frame.h:45
SourceXtractor::LayerSubtractedImage
@ LayerSubtractedImage
Definition
Frame.h:39
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:51
std::numeric_limits::quiet_NaN
T quiet_NaN(T... args)
std::vector::size
T size(T... args)
std::sqrt
T sqrt(T... args)
Generated by
1.10.0