Loading [MathJax]/extensions/tex2jax.js
LSST Applications g04a91732dc+cc8870d3f5,g07dc498a13+5aa0b8792f,g0fba68d861+488cddfaa9,g1409bbee79+5aa0b8792f,g1a7e361dbc+5aa0b8792f,g1fd858c14a+f64bc332a9,g35bb328faa+fcb1d3bbc8,g4d2262a081+b1c1982739,g4d39ba7253+9633a327c1,g4e0f332c67+5d362be553,g53246c7159+fcb1d3bbc8,g60b5630c4e+9633a327c1,g668ecb457e+25d63fd678,g78460c75b0+2f9a1b4bcd,g786e29fd12+cf7ec2a62a,g7b71ed6315+fcb1d3bbc8,g8852436030+8b64ca622a,g89139ef638+5aa0b8792f,g89e1512fd8+37f975783e,g8d6b6b353c+9633a327c1,g9125e01d80+fcb1d3bbc8,g989de1cb63+5aa0b8792f,g9f33ca652e+b196626af7,ga9baa6287d+9633a327c1,gaaedd4e678+5aa0b8792f,gabe3b4be73+1e0a283bba,gb1101e3267+71e32094df,gb58c049af0+f03b321e39,gb90eeb9370+2807b1ad02,gc741bbaa4f+1ae86710ed,gcf25f946ba+8b64ca622a,gd315a588df+a39986a76f,gd6cbbdb0b4+c8606af20c,gd9a9a58781+fcb1d3bbc8,gde0f65d7ad+94dfc458f4,ge278dab8ac+932305ba37,ge82c20c137+76d20ab76d,gfe73954cf8+a1301e4c20,w.2025.11
LSST Data Management Base Package
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
ellipse.cc File Reference
#include <pybind11/pybind11.h>
#include <pybind11/operators.h>
#include <pybind11/stl.h>
#include <memory>
#include <stdexcept>
#include "pybind11.h"
#include "lsst/gauss2d/ellipse.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 40 of file ellipse.cc.

40 {
41 py::class_<gauss2d::Covariance, std::shared_ptr<gauss2d::Covariance>>(m, "Covariance")
42 .def(py::init<double, double, double>(), "sigma_x_sq"_a = 0, "sigma_y_sq"_a = 0, "cov_xy"_a = 0)
43 .def(py::init<gauss2d::Ellipse &>())
44 .def("convolve", &gauss2d::Covariance::convolve)
45 .def("make_convolution", &gauss2d::Covariance::make_convolution)
46 .def("set",
47 static_cast<void (gauss2d::Covariance::*)(double, double, double)>(
49 "sigma_x_sq"_a = 0, "sigma_y_sq"_a = 0, "cov_xy"_a = 0)
50 .def("set", static_cast<void (gauss2d::Covariance::*)(const gauss2d::Ellipse &)>(
52 .def_property("sigma_x_sq", &gauss2d::Covariance::get_sigma_x_sq,
54 .def_property("sigma_y_sq", &gauss2d::Covariance::get_sigma_y_sq,
58 .def(py::self == py::self)
59 .def(py::self != py::self)
60 .def("__repr__",
61 [](const gauss2d::Covariance &self) { return self.repr(true, self.PY_NAMESPACE_SEPARATOR); })
62 .def("__str__", &gauss2d::Covariance::str);
63 auto _e = py::class_<gauss2d::EllipseData, std::shared_ptr<gauss2d::EllipseData>>(m, "EllipseData");
64 py::class_<gauss2d::EllipseValues, std::shared_ptr<gauss2d::EllipseValues>, gauss2d::EllipseData>(
65 m, "EllipseValues")
66 .def(py::init<double, double, double>(), "sigma_x"_a = 0, "sigma_y"_a = 0, "rho"_a = 0)
67 .def("set", &gauss2d::EllipseValues::set, "sigma_x"_a, "sigma_y"_a, "rho"_a)
68 .def("set_h", &gauss2d::EllipseValues::set_h, "hwhm_x"_a, "hwhm_y"_a, "rho"_a)
72 .def_property("sigma_x", &gauss2d::EllipseValues::get_sigma_x,
74 .def_property("sigma_y", &gauss2d::EllipseValues::get_sigma_y,
78 .def(py::self == py::self)
79 .def(py::self != py::self)
80 .def("__repr__",
81 [](const gauss2d::EllipseValues &self) {
82 return self.repr(true, self.PY_NAMESPACE_SEPARATOR);
83 })
84 .def("__str__", &gauss2d::EllipseValues::str);
85 py::class_<gauss2d::Ellipse, std::shared_ptr<gauss2d::Ellipse>>(m, "Ellipse")
86 .def(py::init<std::shared_ptr<gauss2d::EllipseData>>(), "data"_a)
87 .def(py::init<gauss2d::Covariance &>())
88 .def(py::init<gauss2d::EllipseMajor &>())
89 .def(py::init<double, double, double>(), "sigma_x"_a = 0, "sigma_y"_a = 0, "rho"_a = 0)
90 .def_static("check", &gauss2d::Ellipse::check)
91 .def("convolve", &gauss2d::Ellipse::convolve)
92 .def("get_cov_xy", &gauss2d::Ellipse::get_cov_xy)
93 .def("get_radius_trace", &gauss2d::Ellipse::get_radius_trace)
94 .def("make_convolution", &gauss2d::Ellipse::make_convolution)
95 .def("set",
96 static_cast<void (gauss2d::Ellipse::*)(double, double, double)>(&gauss2d::Ellipse::set),
97 "sigma_x"_a, "sigma_y"_a, "rho"_a)
98 .def("set",
99 static_cast<void (gauss2d::Ellipse::*)(const gauss2d::Covariance &)>(&gauss2d::Ellipse::set),
100 "ellipse"_a)
101 .def("set",
102 static_cast<void (gauss2d::Ellipse::*)(const gauss2d::EllipseMajor &)>(
104 "ellipse_major"_a)
105 .def("set_h", &gauss2d::Ellipse::set_h, "hwhm_x"_a = 0, "hwhm_y"_a = 0, "rho"_a = 0)
113 .def(py::self == py::self)
114 .def(py::self != py::self)
115 .def("__repr__",
116 [](const gauss2d::Ellipse &self) { return self.repr(true, self.PY_NAMESPACE_SEPARATOR); })
117 .def("__str__", &gauss2d::Ellipse::str);
118 py::class_<gauss2d::EllipseMajor, std::shared_ptr<gauss2d::EllipseMajor>>(m, "EllipseMajor")
119 .def(py::init<gauss2d::Covariance &, bool>(), "covariance"_a, "degrees"_a = false)
120 .def(py::init<gauss2d::Ellipse &, bool>(), "ellipse"_a, "degrees"_a = false)
121 .def(py::init<double, double, double, bool>(), "r_major"_a = 0, "axrat"_a = 1, "angle"_a = 0,
122 "degrees"_a = false)
123 .def_static("check", &gauss2d::EllipseMajor::check)
124 .def("get_angle_degrees", &gauss2d::EllipseMajor::get_angle_degrees)
125 .def("get_angle_radians", &gauss2d::EllipseMajor::get_angle_radians)
131 .def(py::self == py::self)
132 .def(py::self != py::self)
133 .def("__repr__",
134 [](const gauss2d::EllipseMajor &self) {
135 return self.repr(true, self.PY_NAMESPACE_SEPARATOR);
136 })
137 .def("__str__", &gauss2d::EllipseMajor::str);
138}
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
Interface for an object storing Ellipse data.
Definition ellipse.h:132
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