LSST Applications g063fba187b+cac8b7c890,g0f08755f38+6aee506743,g1653933729+a8ce1bb630,g168dd56ebc+a8ce1bb630,g1a2382251a+b4475c5878,g1dcb35cd9c+8f9bc1652e,g20f6ffc8e0+6aee506743,g217e2c1bcf+73dee94bd0,g28da252d5a+1f19c529b9,g2bbee38e9b+3f2625acfc,g2bc492864f+3f2625acfc,g3156d2b45e+6e55a43351,g32e5bea42b+1bb94961c2,g347aa1857d+3f2625acfc,g35bb328faa+a8ce1bb630,g3a166c0a6a+3f2625acfc,g3e281a1b8c+c5dd892a6c,g3e8969e208+a8ce1bb630,g414038480c+5927e1bc1e,g41af890bb2+8a9e676b2a,g7af13505b9+809c143d88,g80478fca09+6ef8b1810f,g82479be7b0+f568feb641,g858d7b2824+6aee506743,g89c8672015+f4add4ffd5,g9125e01d80+a8ce1bb630,ga5288a1d22+2903d499ea,gb58c049af0+d64f4d3760,gc28159a63d+3f2625acfc,gcab2d0539d+b12535109e,gcf0d15dbbd+46a3f46ba9,gda6a2b7d83+46a3f46ba9,gdaeeff99f8+1711a396fd,ge79ae78c31+3f2625acfc,gef2f8181fd+0a71e47438,gf0baf85859+c1f95f4921,gfa517265be+6aee506743,gfa999e8aa5+17cd334064,w.2024.51
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