LSST Applications g04e9c324dd+8c5ae1fdc5,g134cb467dc+b203dec576,g18429d2f64+358861cd2c,g199a45376c+0ba108daf9,g1fd858c14a+dd066899e3,g262e1987ae+ebfced1d55,g29ae962dfc+72fd90588e,g2cef7863aa+aef1011c0b,g35bb328faa+8c5ae1fdc5,g3fd5ace14f+b668f15bc5,g4595892280+3897dae354,g47891489e3+abcf9c3559,g4d44eb3520+fb4ddce128,g53246c7159+8c5ae1fdc5,g67b6fd64d1+abcf9c3559,g67fd3c3899+1f72b5a9f7,g74acd417e5+cb6b47f07b,g786e29fd12+668abc6043,g87389fa792+8856018cbb,g89139ef638+abcf9c3559,g8d7436a09f+bcf525d20c,g8ea07a8fe4+9f5ccc88ac,g90f42f885a+6054cc57f1,g97be763408+06f794da49,g9dd6db0277+1f72b5a9f7,ga681d05dcb+7e36ad54cd,gabf8522325+735880ea63,gac2eed3f23+abcf9c3559,gb89ab40317+abcf9c3559,gbf99507273+8c5ae1fdc5,gd8ff7fe66e+1f72b5a9f7,gdab6d2f7ff+cb6b47f07b,gdc713202bf+1f72b5a9f7,gdfd2d52018+8225f2b331,ge365c994fd+375fc21c71,ge410e46f29+abcf9c3559,geaed405ab2+562b3308c0,gf9a733ac38+8c5ae1fdc5,w.2025.35
LSST Data Management Base Package
Loading...
Searching...
No Matches
ellipse.cc File Reference
#include <memory>
#include <pybind11/pybind11.h>
#include <pybind11/operators.h>
#include <pybind11/stl.h>
#include "lsst/gauss2d/ellipse.h"
#include "pybind11.h"

Go to the source code of this file.

Functions

void bind_ellipse (py::module &m)
 

Function Documentation

◆ bind_ellipse()

void bind_ellipse ( py::module & m)

Definition at line 39 of file ellipse.cc.

39 {
40 py::classh<gauss2d::Covariance>(m, "Covariance")
41 .def(py::init<double, double, double>(), "sigma_x_sq"_a = 0, "sigma_y_sq"_a = 0, "cov_xy"_a = 0)
42 .def(py::init<gauss2d::Ellipse &>())
43 .def("convolve", &gauss2d::Covariance::convolve)
44 .def("make_convolution", &gauss2d::Covariance::make_convolution)
45 .def("set",
46 static_cast<void (gauss2d::Covariance::*)(double, double, double)>(
48 "sigma_x_sq"_a = 0, "sigma_y_sq"_a = 0, "cov_xy"_a = 0)
49 .def("set", static_cast<void (gauss2d::Covariance::*)(const gauss2d::Ellipse &)>(
51 .def_property("sigma_x_sq", &gauss2d::Covariance::get_sigma_x_sq,
53 .def_property("sigma_y_sq", &gauss2d::Covariance::get_sigma_y_sq,
57 .def(py::self == py::self)
58 .def(py::self != py::self)
59 .def("__repr__",
60 [](const gauss2d::Covariance &self) { return self.repr(true, self.PY_NAMESPACE_SEPARATOR); })
61 .def("__str__", &gauss2d::Covariance::str);
62 auto _e = py::classh<gauss2d::EllipseData>(m, "EllipseData");
63 py::classh<gauss2d::EllipseValues, gauss2d::EllipseData>(m, "EllipseValues")
64 .def(py::init<double, double, double>(), "sigma_x"_a = 0, "sigma_y"_a = 0, "rho"_a = 0)
65 .def("set", &gauss2d::EllipseValues::set, "sigma_x"_a, "sigma_y"_a, "rho"_a)
66 .def("set_h", &gauss2d::EllipseValues::set_h, "hwhm_x"_a, "hwhm_y"_a, "rho"_a)
70 .def_property("sigma_x", &gauss2d::EllipseValues::get_sigma_x,
72 .def_property("sigma_y", &gauss2d::EllipseValues::get_sigma_y,
76 .def(py::self == py::self)
77 .def(py::self != py::self)
78 .def("__repr__",
79 [](const gauss2d::EllipseValues &self) {
80 return self.repr(true, self.PY_NAMESPACE_SEPARATOR);
81 })
82 .def("__str__", &gauss2d::EllipseValues::str);
83 py::classh<gauss2d::Ellipse>(m, "Ellipse")
84 .def(py::init<std::shared_ptr<gauss2d::EllipseData>>(), "data"_a)
85 .def(py::init<gauss2d::Covariance &>())
86 .def(py::init<gauss2d::EllipseMajor &>())
87 .def(py::init<double, double, double>(), "sigma_x"_a = 0, "sigma_y"_a = 0, "rho"_a = 0)
88 .def_static("check", &gauss2d::Ellipse::check)
89 .def("convolve", &gauss2d::Ellipse::convolve)
90 .def("get_cov_xy", &gauss2d::Ellipse::get_cov_xy)
91 .def("get_radius_trace", &gauss2d::Ellipse::get_radius_trace)
92 .def("make_convolution", &gauss2d::Ellipse::make_convolution)
93 .def("set",
94 static_cast<void (gauss2d::Ellipse::*)(double, double, double)>(&gauss2d::Ellipse::set),
95 "sigma_x"_a, "sigma_y"_a, "rho"_a)
96 .def("set",
97 static_cast<void (gauss2d::Ellipse::*)(const gauss2d::Covariance &)>(&gauss2d::Ellipse::set),
98 "ellipse"_a)
99 .def("set",
100 static_cast<void (gauss2d::Ellipse::*)(const gauss2d::EllipseMajor &)>(
102 "ellipse_major"_a)
103 .def("set_h", &gauss2d::Ellipse::set_h, "hwhm_x"_a = 0, "hwhm_y"_a = 0, "rho"_a = 0)
111 .def(py::self == py::self)
112 .def(py::self != py::self)
113 .def("__repr__",
114 [](const gauss2d::Ellipse &self) { return self.repr(true, self.PY_NAMESPACE_SEPARATOR); })
115 .def("__str__", &gauss2d::Ellipse::str);
116 py::classh<gauss2d::EllipseMajor>(m, "EllipseMajor")
117 .def(py::init<gauss2d::Covariance &, bool>(), "covariance"_a, "degrees"_a = false)
118 .def(py::init<gauss2d::Ellipse &, bool>(), "ellipse"_a, "degrees"_a = false)
119 .def(py::init<double, double, double, bool>(), "r_major"_a = 0, "axrat"_a = 1, "angle"_a = 0,
120 "degrees"_a = false)
121 .def_static("check", &gauss2d::EllipseMajor::check)
122 .def("get_angle_degrees", &gauss2d::EllipseMajor::get_angle_degrees)
123 .def("get_angle_radians", &gauss2d::EllipseMajor::get_angle_radians)
129 .def(py::self == py::self)
130 .def(py::self != py::self)
131 .def("__repr__",
132 [](const gauss2d::EllipseMajor &self) {
133 return self.repr(true, self.PY_NAMESPACE_SEPARATOR);
134 })
135 .def("__str__", &gauss2d::EllipseMajor::str);
136}
A representation of a 2D Gaussian with x and y standard deviations and a covariance value.
Definition ellipse.h:57
std::shared_ptr< Covariance > make_convolution(const Covariance &cov) const
Return the convolution of this with another covariance.
Definition ellipse.cc:66
double get_cov_xy() const
Get the covariance.
Definition ellipse.h:79
double get_sigma_x_sq() const
Get the square of sigma_x.
Definition ellipse.h:75
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.
Definition ellipse.cc:122
void set_sigma_y_sq(double sigma_y_sq)
Set the square of sigma_y.
Definition ellipse.cc:97
void set_sigma_x_sq(double sigma_x_sq)
Set the square of sigma_x.
Definition ellipse.cc:89
void set_xyc(const std::array< double, 3 > &xyc)
Set sigma_x_sq, sigma_y_sq and cov_xy from an array ref.
Definition ellipse.cc:120
std::array< double, 3 > get_xyc() const
Get the array of sigma_x^2, sigma_y^2, covariance.
Definition ellipse.h:81
std::string str() const override
Return a brief, human-readable string representation of this.
Definition ellipse.cc:129
double get_sigma_y_sq() const
Get the square of sigma_y.
Definition ellipse.h:77
void convolve(const Covariance &cov)
Convolve with another covariance, adding the values of each parameter to this.
Definition ellipse.cc:59
void set_cov_xy(double cov_xy)
Set the off-diagonal (covariance) term.
Definition ellipse.cc:105
void set(const Ellipse &ellipse)
Set values from an ellipse instance.
Definition ellipse.cc:73
virtual void set_hwhm_y(double hwhm_y)
Set the y-axis half-width at half-max (FWHM/2)
Definition ellipse.cc:304
virtual void set(double sigma_x, double sigma_y, double rho)
Set sigma_x, sigma_y, rho.
Definition ellipse.cc:256
virtual void set_h(double hwhm_x, double hwhm_y, double rho)
Set hwhm_x, hwhm_y, rho (half-width at half-max)
Definition ellipse.cc:297
virtual void convolve(const Ellipse &ell)
Convolve this ellipse with another.
Definition ellipse.cc:149
virtual void set_hwhm_x(double hwhm_x)
Set the x-axis half-width at half-max (FWHM/2)
Definition ellipse.cc:303
virtual void set_xyr(const std::array< double, 3 > &xyr)
Set sigma_x, sigma_y, rho from an array.
Definition ellipse.cc:306
virtual std::array< double, 3 > get_hxyr() const
Get hwhm_x, hwhm_y, rho.
Definition ellipse.cc:166
virtual double get_cov_xy() const
Return the covariance, equal to sigma_x*sigma_y*rho.
Definition ellipse.cc:160
static void check(double size_x, double size_y, double rho, std::string_view error_suffix="")
Check whether Ellipse parameter values are valid, throwing if not.
Definition ellipse.h:137
virtual double get_radius_trace() const
Return the trace radius, equal to sqrt(sigma_x^2 + sigma_y^2)
Definition ellipse.cc:173
virtual void set_hxyr(const std::array< double, 3 > &hxyr)
Set hwhm_x, hwhm_y, rho from an array.
Definition ellipse.cc:305
virtual double get_hwhm_y() const
Get the y-axis half-width at half-maximum.
Definition ellipse.cc:164
virtual std::array< double, 3 > get_xyr() const
Get sigma_x, sigma_y, rho.
Definition ellipse.cc:169
virtual double get_hwhm_x() const
Get the x-axis half-width at half-maximum.
Definition ellipse.cc:162
An Ellipse with sigma_x, sigma_y, and rho values.
Definition ellipse.h:283
std::shared_ptr< Ellipse > make_convolution(const Ellipse &ell) const
Return the convolution of this with another ellipse.
Definition ellipse.cc:245
double get_rho() const override
Get rho.
Definition ellipse.cc:319
void set_rho(double rho) override
Set the correlation parameter (rho)
Definition ellipse.cc:323
void set_sigma_y(double sigma_y) override
Set the y-axis dispersion (sigma)
Definition ellipse.cc:325
void set_sigma_x(double sigma_x) override
Set the x-axis dispersion (sigma)
Definition ellipse.cc:324
double get_sigma_x() const override
Get sigma_x.
Definition ellipse.cc:320
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.
Definition ellipse.cc:308
std::string str() const override
Return a brief, human-readable string representation of this.
Definition ellipse.cc:313
double get_sigma_y() const override
Get sigma_y.
Definition ellipse.cc:321
An Ellipse with r_major, axrat and angle values.
Definition ellipse.h:337
void set_degrees(bool degrees)
Definition ellipse.cc:399
double get_axrat() const
Get the axis ratio.
Definition ellipse.h:364
double get_r_major() const
Get the major axis length.
Definition ellipse.h:362
double get_angle_radians() const
Get the position angle in radians.
Definition ellipse.h:370
bool is_degrees() const
Return if the units are degrees (true) or radians (false)
Definition ellipse.h:374
static void check(double r_major, double axrat, double angle)
Check whether the supplied values are valid, throwing if not.
Definition ellipse.h:352
void set_angle(double angle)
Definition ellipse.cc:397
void set_rqa(const std::array< double, 3 > &rqa)
Definition ellipse.cc:409
void set_r_major(double r_major)
Definition ellipse.cc:381
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.
Definition ellipse.cc:411
void set_axrat(double axrat)
Definition ellipse.cc:389
std::array< double, 3 > get_rqa() const
Get the array of r_major, axrat, angle.
Definition ellipse.h:372
double get_angle() const
Get the position angle in the configured units.
Definition ellipse.h:366
double get_angle_degrees() const
Get the position angle in degrees.
Definition ellipse.h:368
std::string str() const override
Return a brief, human-readable string representation of this.
Definition ellipse.cc:418
An EllipseData storing sigma_x, sigma_y, rho values as shared_ptrs.
Definition ellipse.h:232
void set_rho(double rho) override
Set the correlation parameter (rho)
Definition ellipse.cc:200
void set_h(double hwhm_x, double hwhm_y, double rho) override
Set hwhm_x, hwhm_y, rho (half-width at half-max)
Definition ellipse.cc:212
double get_rho() const override
Get rho.
Definition ellipse.cc:187
std::string str() const override
Return a brief, human-readable string representation of this.
Definition ellipse.cc:226
std::array< double, 3 > get_xyr() const override
Get sigma_x, sigma_y, rho.
Definition ellipse.cc:188
void set(double sigma_x, double sigma_y, double rho) override
Set sigma_x, sigma_y, rho.
Definition ellipse.cc:205
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.
Definition ellipse.cc:219
void set_sigma_x(double sigma_x) override
Set the x-axis dispersion (sigma)
Definition ellipse.cc:190
double get_sigma_y() const override
Get sigma_y.
Definition ellipse.cc:186
void set_sigma_y(double sigma_y) override
Set the y-axis dispersion (sigma)
Definition ellipse.cc:195
double get_sigma_x() const override
Get sigma_x.
Definition ellipse.cc:185
static constexpr std::string_view PY_NAMESPACE_SEPARATOR
Definition object.h:47