LSST Applications g0f08755f38+82efc23009,g12f32b3c4e+e7bdf1200e,g1653933729+a8ce1bb630,g1a0ca8cf93+50eff2b06f,g28da252d5a+52db39f6a5,g2bbee38e9b+37c5a29d61,g2bc492864f+37c5a29d61,g2cdde0e794+c05ff076ad,g3156d2b45e+41e33cbcdc,g347aa1857d+37c5a29d61,g35bb328faa+a8ce1bb630,g3a166c0a6a+37c5a29d61,g3e281a1b8c+fb992f5633,g414038480c+7f03dfc1b0,g41af890bb2+11b950c980,g5fbc88fb19+17cd334064,g6b1c1869cb+12dd639c9a,g781aacb6e4+a8ce1bb630,g80478fca09+72e9651da0,g82479be7b0+04c31367b4,g858d7b2824+82efc23009,g9125e01d80+a8ce1bb630,g9726552aa6+8047e3811d,ga5288a1d22+e532dc0a0b,gae0086650b+a8ce1bb630,gb58c049af0+d64f4d3760,gc28159a63d+37c5a29d61,gcf0d15dbbd+2acd6d4d48,gd7358e8bfb+778a810b6e,gda3e153d99+82efc23009,gda6a2b7d83+2acd6d4d48,gdaeeff99f8+1711a396fd,ge2409df99d+6b12de1076,ge79ae78c31+37c5a29d61,gf0baf85859+d0a5978c5a,gf3967379c6+4954f8c433,gfb92a5be7c+82efc23009,gfec2e1e490+2aaed99252,w.2024.46
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