Loading [MathJax]/extensions/tex2jax.js
LSST Applications 28.0.0,g1653933729+a8ce1bb630,g1a997c3884+a8ce1bb630,g28da252d5a+5bd70b7e6d,g2bbee38e9b+638fca75ac,g2bc492864f+638fca75ac,g3156d2b45e+07302053f8,g347aa1857d+638fca75ac,g35bb328faa+a8ce1bb630,g3a166c0a6a+638fca75ac,g3e281a1b8c+7bbb0b2507,g4005a62e65+17cd334064,g414038480c+5b5cd4fff3,g41af890bb2+4ffae9de63,g4e1a3235cc+0f1912dca3,g6249c6f860+3c3976f90c,g80478fca09+46aba80bd6,g82479be7b0+77990446f6,g858d7b2824+78ba4d1ce1,g89c8672015+f667a5183b,g9125e01d80+a8ce1bb630,ga5288a1d22+2a6264e9ca,gae0086650b+a8ce1bb630,gb58c049af0+d64f4d3760,gc22bb204ba+78ba4d1ce1,gc28159a63d+638fca75ac,gcf0d15dbbd+32ddb6096f,gd6b7c0dfd1+3e339405e9,gda3e153d99+78ba4d1ce1,gda6a2b7d83+32ddb6096f,gdaeeff99f8+1711a396fd,gdd5a9049c5+b18c39e5e3,ge2409df99d+a5e4577cdc,ge33fd446bb+78ba4d1ce1,ge79ae78c31+638fca75ac,gf0baf85859+64e8883e75,gf5289d68f6+e1b046a8d7,gfa443fc69c+91d9ed1ecf,gfda6b12a05+8419469a56
LSST Data Management Base Package
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
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
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 type_name_str(bool strip_namespace=false, std::string_view namespace_str=detail::NAMESPACE_SEPARATOR)
Get a string representation of an arbitrary C++ type, potentially modifying its namespace prefix.
Definition type_name.h:104
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