LSST Applications g1653933729+34a971ddd9,g1a997c3884+34a971ddd9,g2160c40384+da0d0eec6b,g28da252d5a+1236b942f7,g2bbee38e9b+e5a1bc5b38,g2bc492864f+e5a1bc5b38,g2ca4be77d2+192fe503f0,g2cdde0e794+704103fe75,g3156d2b45e+6e87dc994a,g347aa1857d+e5a1bc5b38,g35bb328faa+34a971ddd9,g3a166c0a6a+e5a1bc5b38,g3e281a1b8c+8ec26ec694,g4005a62e65+ba0306790b,g414038480c+9f5be647b3,g41af890bb2+c3a10c924f,g5065538af8+e7237db731,g5a0bb5165c+eae055db26,g717e5f8c0f+b65b5c3ae4,g80478fca09+4ce5a07937,g82479be7b0+08790af60f,g858d7b2824+b65b5c3ae4,g9125e01d80+34a971ddd9,ga5288a1d22+5df949a35e,gae0086650b+34a971ddd9,gb58c049af0+ace264a4f2,gbd397ab92a+2141afb137,gc28159a63d+e5a1bc5b38,gc805d3fbd4+b65b5c3ae4,gcf0d15dbbd+97632ccc20,gd6b7c0dfd1+de826e8718,gda6a2b7d83+97632ccc20,gdaeeff99f8+7774323b41,ge2409df99d+e6cadbf968,ge33fd446bb+b65b5c3ae4,ge79ae78c31+e5a1bc5b38,gf0baf85859+890af219f9,gf5289d68f6+a27069ed62,w.2024.37
LSST Data Management Base Package
Loading...
Searching...
No Matches
linearsersicmixinterpolator.cc
Go to the documentation of this file.
1#include <algorithm>
2#include <stdexcept>
3#include <string>
4#include <vector>
5
8
10
11namespace lsst::gauss2d::fit {
12
14 : _order(order),
16 _sersicindex_min(_knots[0].sersicindex),
17 _sersicindex_max(_knots.back().sersicindex) {}
18
20
22 if (!((sersicindex >= _sersicindex_min) && (sersicindex <= _sersicindex_max))) {
23 throw std::invalid_argument("sersicindex=" + to_string_float(sersicindex)
24 + " !(>=" + to_string_float(_sersicindex_min)
25 + "&& <=" + to_string_float(_sersicindex_max));
26 }
27
28 if (sersicindex == _sersicindex_min)
29 return _knots[0].values;
30 else if (sersicindex == _sersicindex_max)
31 return _knots.back().values;
32
33 auto found = std::lower_bound(_knots.begin(), _knots.end(), sersicindex);
34 auto high = *found;
35 auto low = *(--found);
36
37 if (sersicindex == high.sersicindex) return high.values;
38 double frac_low = (high.sersicindex - sersicindex) / (high.sersicindex - low.sersicindex);
39 if (!((frac_low >= 0) && (frac_low <= 1))) {
40 throw std::logic_error("Got invalid frac_low=" + std::to_string(frac_low)
41 + " with n, lo, hi=" + to_string_float(sersicindex) + ","
42 + to_string_float(low.sersicindex) + "," + to_string_float(high.sersicindex));
43 }
44 double frac_high = 1 - frac_low;
45
47 result.reserve(_order);
48 for (size_t i = 0; i < _order; ++i) {
49 result.push_back(IntegralSize(frac_low * low.values[i].integral + frac_high * high.values[i].integral,
50 frac_low * low.values[i].sigma + frac_high * high.values[i].sigma));
51 }
52
53 return result;
54}
55
57 if (!((sersicindex >= _sersicindex_min) && (sersicindex <= _sersicindex_max))) {
58 throw std::invalid_argument("sersicindex=" + to_string_float(sersicindex)
59 + " !(>=" + to_string_float(_sersicindex_min)
60 + "&& <=" + to_string_float(_sersicindex_max));
61 }
62
63 auto found = sersicindex == _sersicindex_min
64 ? ++_knots.begin()
65 : ((sersicindex == _sersicindex_max)
66 ? --_knots.end()
67 : std::upper_bound(_knots.begin(), _knots.end(), sersicindex));
68 auto& high = *found;
69 auto& low = *(--found);
70
71 double dn_inv = 1. / (high.sersicindex - low.sersicindex);
72
74 result.reserve(_order);
75 for (size_t i = 0; i < _order; ++i) {
76 result.push_back(IntegralSize((high.values[i].integral - low.values[i].integral) * dn_inv,
77 (high.values[i].sigma - low.values[i].sigma) * dn_inv));
78 }
79
80 return result;
81}
82
84
86
87unsigned short LinearSersicMixInterpolator::get_order() const { return _order; }
88
89double LinearSersicMixInterpolator::get_sersicindex_min() const { return _sersicindex_min; }
90
91double LinearSersicMixInterpolator::get_sersicindex_max() const { return _sersicindex_max; }
92
94 std::string_view namespace_separator) const {
95 return type_name_str<LinearSersicMixInterpolator>(false, namespace_separator) + "("
96 + (name_keywords ? "order=" : "") + std::to_string(_order) + ")";
97}
98
100 return type_name_str<LinearSersicMixInterpolator>(true) + "(order=" + std::to_string(_order) + ")";
101}
102
103} // namespace lsst::gauss2d::fit
py::object result
Definition _schema.cc:429
A pair of integral - size values for a Gaussian (sub)Component.
Definition sersicmix.h:19
std::vector< IntegralSize > get_integralsizes(double sersicindex) const override
Get the vector of IntegralSize values for a given Sersic index.
LinearSersicMixInterpolator(unsigned short order=SERSICMIX_ORDER_DEFAULT)
const std::vector< SersicMixValues > & get_knots() const
The knot positions and values.
std::string str() const override
Return a brief, human-readable string representation of this.
std::string repr(bool name_keywords=false, std::string_view namespace_separator=Object::CC_NAMESPACE_SEPARATOR) const override
Return a full, callable string representation of this.
std::vector< IntegralSize > get_integralsizes_derivs(double sersicindex) const override
T lower_bound(T... args)
@ linear
Linear interpolation.
const std::vector< SersicMixValues > & get_sersic_mix_knots(unsigned short order)
Definition sersicmix.cc:50
std::string to_string_float(const T value, const int precision=6, const bool scientific=true)
Definition to_string.h:15
T reserve(T... args)
T to_string(T... args)
T upper_bound(T... args)
table::Key< int > order