SourceXtractorPlusPlus
0.21
SourceXtractor++, the next generation SExtractor
Loading...
Searching...
No Matches
ModelFitting
src
lib
Models
AutoSharp.cpp
Go to the documentation of this file.
1
23
#include <cmath>
// For std::abs, std::ceil
24
#include <algorithm>
// For std::min, std::max
25
#include "
ModelFitting/Models/AutoSharp.h
"
26
27
namespace
ModelFitting
{
28
29
AutoSharp::AutoSharp
(
double
log_incr
,
double
first_r
,
double
tolerance
,
double
min_sampling_factor
)
30
: m_log_incr {
log_incr
}, m_first_r{
first_r
}, m_tolerance{
tolerance
},
31
m_min_sampling_factor{
min_sampling_factor
} {
32
}
33
34
AutoSharp::~AutoSharp
() =
default
;
35
36
void
AutoSharp::updateRasterizationInfo
(
double
scale,
double
r_max
,
Profile
profile
) {
37
m_r_sharp
= 0.;
38
double
err
=
m_tolerance
;
39
while
(
m_r_sharp < r_max && err >
=
m_tolerance
) {
40
double
v1
=
profile
(
m_r_sharp
);
41
double
v2
=
profile
(
m_r_sharp
+ scale / 2.);
42
double
v3
=
profile
(
m_r_sharp
+ scale);
43
err
=
std::abs
((
v2
- (
v3
+
v1
) / 2) /
v2
);
44
m_r_sharp
+= scale;
45
}
46
m_r_sharp
=
std::min
(
m_r_sharp
,
r_max
);
47
m_r_sharp
=
std::max
(
m_r_sharp
, 4 * scale);
48
m_max_step
= scale /
m_min_sampling_factor
;
49
m_first_pix_r
= scale / 2.;
50
}
51
52
bool
AutoSharp::insideSharpRegion
(
double
r
) {
53
return
r
<
m_r_sharp
;
54
}
55
56
std::pair<double, int>
AutoSharp::nextRadiusAndAngleNo
(
double
prev_r
) {
57
double
next_r
=
prev_r
> 0
58
?
std::min
(
prev_r
*
m_log_incr
,
prev_r
+
m_max_step
)
59
:
m_first_r
;
60
int
angle_no
=
next_r
>
m_first_pix_r
61
?
std::ceil
(2. *
M_PI
*
prev_r
/
m_max_step
)
62
: 1;
63
return
std::make_pair
(
next_r
,
angle_no
);
64
}
65
66
}
// end of namespace ModelFitting
AutoSharp.h
std::ceil
T ceil(T... args)
ModelFitting::AutoSharp::m_log_incr
double m_log_incr
Definition
AutoSharp.h:73
ModelFitting::AutoSharp::m_max_step
double m_max_step
Definition
AutoSharp.h:71
ModelFitting::AutoSharp::updateRasterizationInfo
void updateRasterizationInfo(double scale, double r_max, Profile profile) override
Definition
AutoSharp.cpp:36
ModelFitting::AutoSharp::m_tolerance
double m_tolerance
Definition
AutoSharp.h:75
ModelFitting::AutoSharp::m_min_sampling_factor
double m_min_sampling_factor
Definition
AutoSharp.h:76
ModelFitting::AutoSharp::insideSharpRegion
bool insideSharpRegion(double r) override
Definition
AutoSharp.cpp:52
ModelFitting::AutoSharp::nextRadiusAndAngleNo
std::pair< double, int > nextRadiusAndAngleNo(double prev_r) override
Definition
AutoSharp.cpp:56
ModelFitting::AutoSharp::m_first_r
double m_first_r
Definition
AutoSharp.h:74
ModelFitting::AutoSharp::~AutoSharp
virtual ~AutoSharp()
ModelFitting::AutoSharp::AutoSharp
AutoSharp(double log_incr=1.122, double first_r=1E-4, double tolerance=0.05, double min_sampling_factor=5.)
Definition
AutoSharp.cpp:29
ModelFitting::AutoSharp::m_first_pix_r
double m_first_pix_r
Definition
AutoSharp.h:72
ModelFitting::AutoSharp::m_r_sharp
double m_r_sharp
Definition
AutoSharp.h:70
std::function
std::make_pair
T make_pair(T... args)
std::max
T max(T... args)
std::min
T min(T... args)
ModelFitting
Definition
AsinhChiSquareComparator.h:30
Generated by
1.10.0