SourceXtractorPlusPlus
0.21
SourceXtractor++, the next generation SExtractor
Loading...
Searching...
No Matches
SEFramework
src
lib
Aperture
CircularAperture.cpp
Go to the documentation of this file.
1
17
/*
18
* CircularAperture.cpp
19
*
20
* Created on: Oct 08, 2018
21
* Author: Alejandro Alvarez
22
*/
23
#include <iostream>
24
#include "
SEFramework/Aperture/CircularAperture.h
"
25
26
namespace
SourceXtractor
{
27
28
// enhancing from 5 to 10 smoothens the photometry
29
const
int
SUPERSAMPLE_NB
= 10;
30
31
SeFloat
CircularAperture::getArea
(
SeFloat
center_x
,
SeFloat
center_y
,
SeFloat
pixel_x
,
SeFloat
pixel_y
)
const
{
32
auto
dx
=
pixel_x
-
center_x
;
33
auto
dy
=
pixel_y
-
center_y
;
34
SeFloat
min_supersampled_radius_squared
=
m_radius
> .75 ? (
m_radius
- .75) * (
m_radius
- .75) : 0;
35
SeFloat
max_supersampled_radius_squared
= (
m_radius
+ .75) * (
m_radius
+ .75);
36
37
auto
distance_squared
=
dx
*
dx
+
dy
*
dy
;
38
SeFloat
area
= 0.0;
39
if
(
distance_squared
<
min_supersampled_radius_squared
) {
40
area
= 1.0;
41
}
42
else
if
(
distance_squared
<=
max_supersampled_radius_squared
) {
43
for
(
int
sub_y
= 0;
sub_y
<
SUPERSAMPLE_NB
;
sub_y
++) {
44
for
(
int
sub_x
= 0;
sub_x
<
SUPERSAMPLE_NB
;
sub_x
++) {
45
auto
dx2
=
dx
+
SeFloat
(
sub_x
-
SUPERSAMPLE_NB
/ 2) /
SUPERSAMPLE_NB
;
46
auto
dy2
=
dy
+
SeFloat
(
sub_y
-
SUPERSAMPLE_NB
/ 2) /
SUPERSAMPLE_NB
;
47
auto
supersampled_distance_squared
=
dx2
*
dx2
+
dy2
*
dy2
;
48
if
(
supersampled_distance_squared
<=
m_radius
*
m_radius
) {
49
area
+= 1.0 / (
SUPERSAMPLE_NB
*
SUPERSAMPLE_NB
);
50
}
51
}
52
}
53
}
54
return
area
;
55
}
56
57
SeFloat
CircularAperture::drawArea
(
SeFloat
center_x
,
SeFloat
center_y
,
SeFloat
pixel_x
,
SeFloat
pixel_y
)
const
{
58
SeFloat
thickness
= 0.5;
59
60
// define an inner and an outer radius
61
SeFloat
min_radius_squared
=
m_radius
>
thickness
? (
m_radius
-
thickness
) * (
m_radius
-
thickness
) : 0;
62
SeFloat
max_radius_squared
= (
m_radius
+
thickness
) * (
m_radius
+
thickness
);
63
64
// compare the actual radius against the inner and outer radius
65
auto
distance_squared
=
getRadiusSquared
(
center_x
,
center_y
,
pixel_x
,
pixel_y
);
66
if
(
min_radius_squared
<
distance_squared
&&
distance_squared
<=
max_radius_squared
) {
67
return
1.0;
68
}
69
return
0.0;
70
}
71
72
SeFloat
CircularAperture::getRadiusSquared
(
SeFloat
center_x
,
SeFloat
center_y
,
SeFloat
pixel_x
,
SeFloat
pixel_y
)
const
{
73
auto
dist_x
=
SeFloat
(
pixel_x
) -
center_x
;
74
auto
dist_y
=
SeFloat
(
pixel_y
) -
center_y
;
75
76
return
dist_x
*
dist_x
+
dist_y
*
dist_y
;
77
}
78
79
PixelCoordinate
CircularAperture::getMinPixel
(
SeFloat
centroid_x
,
SeFloat
centroid_y
)
const
{
80
return
PixelCoordinate
(
centroid_x
-
m_radius
,
centroid_y
-
m_radius
);
81
}
82
83
PixelCoordinate
CircularAperture::getMaxPixel
(
SeFloat
centroid_x
,
SeFloat
centroid_y
)
const
{
84
return
PixelCoordinate
(
std::ceil
(
centroid_x
+
m_radius
),
std::ceil
(
centroid_y
+
m_radius
));
85
}
86
87
}
// end SourceXtractor
CircularAperture.h
dx
std::shared_ptr< EngineParameter > dx
Definition
MoffatModelFittingTask.cpp:93
dy
std::shared_ptr< EngineParameter > dy
Definition
MoffatModelFittingTask.cpp:93
std::ceil
T ceil(T... args)
SourceXtractor::CircularAperture::getMinPixel
PixelCoordinate getMinPixel(SeFloat centroid_x, SeFloat centroid_y) const override
Definition
CircularAperture.cpp:79
SourceXtractor::CircularAperture::drawArea
SeFloat drawArea(SeFloat center_x, SeFloat center_y, SeFloat pixel_x, SeFloat pixel_y) const override
Definition
CircularAperture.cpp:57
SourceXtractor::CircularAperture::getRadiusSquared
SeFloat getRadiusSquared(SeFloat center_x, SeFloat center_y, SeFloat pixel_x, SeFloat pixel_y) const override
Definition
CircularAperture.cpp:72
SourceXtractor::CircularAperture::getMaxPixel
PixelCoordinate getMaxPixel(SeFloat centroid_x, SeFloat centroid_y) const override
Definition
CircularAperture.cpp:83
SourceXtractor::CircularAperture::getArea
SeFloat getArea(SeFloat center_x, SeFloat center_y, SeFloat pixel_x, SeFloat pixel_y) const override
Definition
CircularAperture.cpp:31
SourceXtractor::CircularAperture::m_radius
SeFloat m_radius
Definition
CircularAperture.h:48
std::function
SourceXtractor
Definition
Aperture.h:30
SourceXtractor::SUPERSAMPLE_NB
const int SUPERSAMPLE_NB
Definition
CircularAperture.cpp:29
SourceXtractor::SeFloat
SeFloat32 SeFloat
Definition
Types.h:32
SourceXtractor::PixelCoordinate
A pixel coordinate made of two integers m_x and m_y.
Definition
PixelCoordinate.h:37
Generated by
1.10.0