LSST Applications 24.1.6,g063fba187b+56b85ce14a,g0f08755f38+df8a265115,g12f32b3c4e+891a09f10d,g1524ad2192+7a5d7b3fbd,g1653933729+a8ce1bb630,g168dd56ebc+a8ce1bb630,g28da252d5a+07cb1400be,g2bbee38e9b+ae03bbfc84,g2bc492864f+ae03bbfc84,g3156d2b45e+6e55a43351,g347aa1857d+ae03bbfc84,g35bb328faa+a8ce1bb630,g3a166c0a6a+ae03bbfc84,g3e281a1b8c+c5dd892a6c,g414038480c+6b9177ef31,g41af890bb2+8f257c4c0b,g781aacb6e4+a8ce1bb630,g7af13505b9+7137b3b17d,g80478fca09+6df6903293,g82479be7b0+091ce1d07f,g858d7b2824+df8a265115,g89c8672015+f4add4ffd5,g9125e01d80+a8ce1bb630,g9726552aa6+414189b318,ga5288a1d22+4a2bca08d7,gacef1a1666+c9a8ff65f4,gb58c049af0+d64f4d3760,gbcfae0f0a0+de1d42d831,gc28159a63d+ae03bbfc84,gcf0d15dbbd+72117bf34e,gda6a2b7d83+72117bf34e,gdaeeff99f8+1711a396fd,ge500cccec5+c8c9c9af63,ge79ae78c31+ae03bbfc84,gf0baf85859+c1f95f4921,gfa517265be+df8a265115,gfa999e8aa5+17cd334064,gfb92a5be7c+df8a265115
LSST Data Management Base Package
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Protected Types | Static Protected Member Functions | Related Symbols | List of all members
lsst::meas::algorithms::ImagePsfTrampoline< Base > Class Template Reference

"Trampoline" for ImagePsf to let it be used as a base class in Python. More...

#include <python.h>

Inheritance diagram for lsst::meas::algorithms::ImagePsfTrampoline< Base >:
lsst::afw::detection::PsfTrampoline< Base > lsst::afw::typehandling::StorableHelper< Base > lsst::afw::typehandling::Storable lsst::afw::table::io::Persistable

Public Types

using Image = typename Base::Image
 

Public Member Functions

template<typename... Args>
 ImagePsfTrampoline (Args &&... args)
 Delegating constructor for wrapped class.
 
double doComputeApertureFlux (double radius, geom::Point2D const &position, afw::image::Color const &color) const override
 
afw::geom::ellipses::Quadrupole doComputeShape (geom::Point2D const &position, afw::image::Color const &color) const override
 
std::shared_ptr< Psf > clone () const override
 
std::shared_ptr< Psf > resized (int width, int height) const override
 
lsst::geom::Point2D getAveragePosition () const override
 
std::shared_ptr< ImagedoComputeImage (lsst::geom::Point2D const &position, image::Color const &color) const override
 
lsst::geom::Box2I doComputeImageBBox (lsst::geom::Point2D const &position, image::Color const &color) const override
 
std::shared_ptr< ImagedoComputeKernelImage (lsst::geom::Point2D const &position, image::Color const &color) const override
 
lsst::geom::Box2I doComputeBBox (lsst::geom::Point2D const &position, image::Color const &color) const override
 
std::shared_ptr< Storable > cloneStorable () const override
 Create a new object that is a copy of this one (optional operation).
 
std::string toString () const override
 Create a string representation of this object (optional operation).
 
std::size_t hash_value () const override
 Return a hash of this object (optional operation).
 
bool equals (Storable const &other) const noexcept override
 Compare this object to another Storable.
 
bool isPersistable () const noexcept override
 Return true if this particular object can be persisted using afw::table::io.
 
std::string getPersistenceName () const override
 Return the unique name used to persist this object and look up its factory.
 
std::string getPythonModule () const override
 Return the fully-qualified Python module that should be imported to guarantee that its factory is registered.
 
void write (table::io::OutputArchiveHandle &handle) const override
 Write the object to one or more catalogs.
 
void writeFits (std::string const &fileName, std::string const &mode="w") const
 Write the object to a regular FITS file.
 
void writeFits (fits::MemFileManager &manager, std::string const &mode="w") const
 Write the object to a FITS image in memory.
 
void writeFits (fits::Fits &fitsfile) const
 Write the object to an already-open FITS object.
 

Protected Types

using OutputArchiveHandle = io::OutputArchiveHandle
 

Static Protected Member Functions

template<class T >
static bool singleClassEquals (T const &lhs, Storable const &rhs)
 Test if a Storable is of a particular class and equal to another object.
 

Related Symbols

(Note that these are not member symbols.)

std::ostreamoperator<< (std::ostream &os, Storable const &storable)
 Output operator for Storable.
 

Detailed Description

template<typename Base = ImagePsf>
class lsst::meas::algorithms::ImagePsfTrampoline< Base >

"Trampoline" for ImagePsf to let it be used as a base class in Python.

Subclasses of ImagePsf that are wrapped in pybind11 should have a similar helper that subclasses ImagePsfTrampoline<subclass>. This helper can be skipped if the subclass neither adds any virtual methods nor implements any abstract methods.

Template Parameters
Basethe exact (most specific) class being wrapped
See also
pybind11 documentation

Definition at line 52 of file python.h.

Member Typedef Documentation

◆ Image

template<typename Base = Psf>
using lsst::afw::detection::PsfTrampoline< Base >::Image = typename Base::Image
inherited

Definition at line 52 of file python.h.

◆ OutputArchiveHandle

using lsst::afw::table::io::Persistable::OutputArchiveHandle = io::OutputArchiveHandle
protectedinherited

Definition at line 108 of file Persistable.h.

Constructor & Destructor Documentation

◆ ImagePsfTrampoline()

template<typename Base = ImagePsf>
template<typename... Args>
lsst::meas::algorithms::ImagePsfTrampoline< Base >::ImagePsfTrampoline ( Args &&... args)
inline

Delegating constructor for wrapped class.

While we would like to simply inherit base class constructors, when doing so, we cannot change their access specifiers. One consequence is that it's not possible to use inheritance to expose a protected constructor to python. The alternative, used here, is to create a new public constructor that delegates to the base class public or protected constructor with the same signature.

Template Parameters
ArgsVariadic type specification
Parameters
...argsArguments to forward to the Base class constructor.

Definition at line 67 of file python.h.

67: PsfTrampoline<Base>(std::forward<Args>(args)...) {}
"Trampoline" for Psf to let it be used as a base class in Python.
Definition python.h:50

Member Function Documentation

◆ clone()

template<typename Base = Psf>
std::shared_ptr< Psf > lsst::afw::detection::PsfTrampoline< Base >::clone ( ) const
inlineoverrideinherited

Definition at line 69 of file python.h.

69 {
70 /* __deepcopy__ takes an optional dict, but PYBIND11_OVERLOAD_* won't
71 * compile unless you give it arguments that work for the C++ method
72 */
73 PYBIND11_OVERLOAD_PURE_NAME(std::shared_ptr<Psf>, Base, "__deepcopy__", clone,);
74 }
std::shared_ptr< Psf > clone() const override
Definition python.h:69

◆ cloneStorable()

template<class Base = Storable>
std::shared_ptr< Storable > lsst::afw::typehandling::StorableHelper< Base >::cloneStorable ( ) const
inlineoverridevirtualinherited

Create a new object that is a copy of this one (optional operation).

This operation is required for Storables that are stored in GenericMap by value, but not for those stored by shared pointer.

Exceptions
UnsupportedOperationExceptionThrown if this object is not cloneable.
Note
If this class supports a clone operation, the two should behave identically except for the formal return type.
When called on Python classes, this method delegates to __deepcopy__ if it exists.

Reimplemented from lsst::afw::typehandling::Storable.

Definition at line 73 of file python.h.

73 {
74 /* __deepcopy__ takes an optional dict, but PYBIND11_OVERLOAD_* won't
75 * compile unless you give it arguments that work for the C++ method
76 */
77 PYBIND11_OVERLOAD_NAME(std::shared_ptr<Storable>, Base, "__deepcopy__", cloneStorable, );
78 }
std::shared_ptr< Storable > cloneStorable() const override
Create a new object that is a copy of this one (optional operation).
Definition python.h:73

◆ doComputeApertureFlux()

template<typename Base = ImagePsf>
double lsst::meas::algorithms::ImagePsfTrampoline< Base >::doComputeApertureFlux ( double radius,
geom::Point2D const & position,
afw::image::Color const & color ) const
inlineoverride

Definition at line 69 of file python.h.

72 {
73 PYBIND11_OVERLOAD_NAME(
74 double, Base, "_doComputeApertureFlux", doComputeApertureFlux, radius, position, color
75 );
76 }
double doComputeApertureFlux(double radius, geom::Point2D const &position, afw::image::Color const &color) const override
Definition python.h:69

◆ doComputeBBox()

template<typename Base = Psf>
lsst::geom::Box2I lsst::afw::detection::PsfTrampoline< Base >::doComputeBBox ( lsst::geom::Point2D const & position,
image::Color const & color ) const
inlineoverrideinherited

Definition at line 130 of file python.h.

133 {
134 PYBIND11_OVERLOAD_PURE_NAME(
135 lsst::geom::Box2I, Base, "_doComputeBBox", doComputeBBox, position, color
136 );
137 }
lsst::geom::Box2I doComputeBBox(lsst::geom::Point2D const &position, image::Color const &color) const override
Definition python.h:130
An integer coordinate rectangle.
Definition Box.h:55

◆ doComputeImage()

template<typename Base = Psf>
std::shared_ptr< Image > lsst::afw::detection::PsfTrampoline< Base >::doComputeImage ( lsst::geom::Point2D const & position,
image::Color const & color ) const
inlineoverrideinherited

Definition at line 85 of file python.h.

88 {
89 PYBIND11_OVERLOAD_NAME(
90 std::shared_ptr<Image>, Base, "_doComputeImage", doComputeImage, position, color
91 );
92 }
std::shared_ptr< Image > doComputeImage(lsst::geom::Point2D const &position, image::Color const &color) const override
Definition python.h:85

◆ doComputeImageBBox()

template<typename Base = Psf>
lsst::geom::Box2I lsst::afw::detection::PsfTrampoline< Base >::doComputeImageBBox ( lsst::geom::Point2D const & position,
image::Color const & color ) const
inlineoverrideinherited

Definition at line 94 of file python.h.

97 {
98 PYBIND11_OVERLOAD_NAME(
99 lsst::geom::Box2I, Base, "_doComputeImageBBox", doComputeImageBBox, position, color
100 );
101 }
lsst::geom::Box2I doComputeImageBBox(lsst::geom::Point2D const &position, image::Color const &color) const override
Definition python.h:94

◆ doComputeKernelImage()

template<typename Base = Psf>
std::shared_ptr< Image > lsst::afw::detection::PsfTrampoline< Base >::doComputeKernelImage ( lsst::geom::Point2D const & position,
image::Color const & color ) const
inlineoverrideinherited

Definition at line 103 of file python.h.

106 {
107 PYBIND11_OVERLOAD_PURE_NAME(
108 std::shared_ptr<Image>, Base, "_doComputeKernelImage", doComputeKernelImage, position, color
109 );
110 }
std::shared_ptr< Image > doComputeKernelImage(lsst::geom::Point2D const &position, image::Color const &color) const override
Definition python.h:103

◆ doComputeShape()

template<typename Base = ImagePsf>
afw::geom::ellipses::Quadrupole lsst::meas::algorithms::ImagePsfTrampoline< Base >::doComputeShape ( geom::Point2D const & position,
afw::image::Color const & color ) const
inlineoverride

Definition at line 78 of file python.h.

81 {
82 PYBIND11_OVERLOAD_NAME(
83 afw::geom::ellipses::Quadrupole, Base, "_doComputeShape", doComputeShape, position, color
84 );
85 }
afw::geom::ellipses::Quadrupole doComputeShape(geom::Point2D const &position, afw::image::Color const &color) const override
Definition python.h:78

◆ equals()

template<class Base = Storable>
bool lsst::afw::typehandling::StorableHelper< Base >::equals ( Storable const & other) const
inlineoverridevirtualnoexceptinherited

Compare this object to another Storable.

Subclasses that implement equality comparison must override this method to give results consistent with operator== for all inputs that are accepted by both.

Returns
This implementation returns whether the two objects are the same.
Warning
This method compares an object to any type of Storable, although cross-class comparisons should usually return false. If cross-class comparisons are valid, implementers should take care that they are symmetric and will give the same result no matter what the compile-time types of the left- and right-hand sides are.
See also
singleClassEquals
Note
When called on Python classes, this method delegates to __eq__ if it exists.

Reimplemented from lsst::afw::typehandling::Storable.

Definition at line 88 of file python.h.

88 {
89 PYBIND11_OVERLOAD_NAME(bool, Base, "__eq__", equals, other);
90 }
bool equals(Storable const &other) const noexcept override
Compare this object to another Storable.
Definition python.h:88

◆ getAveragePosition()

template<typename Base = Psf>
lsst::geom::Point2D lsst::afw::detection::PsfTrampoline< Base >::getAveragePosition ( ) const
inlineoverrideinherited

Definition at line 80 of file python.h.

80 {
81 PYBIND11_OVERLOAD(lsst::geom::Point2D, Base, getAveragePosition,);
82 }
lsst::geom::Point2D getAveragePosition() const override
Definition python.h:80

◆ getPersistenceName()

template<class Base = Storable>
std::string lsst::afw::typehandling::StorableHelper< Base >::getPersistenceName ( ) const
inlineoverridevirtualinherited

Return the unique name used to persist this object and look up its factory.

Must be less than ArchiveIndexSchema::MAX_NAME_LENGTH characters.

Reimplemented from lsst::afw::table::io::Persistable.

Definition at line 98 of file python.h.

98 {
99 PYBIND11_OVERLOAD_NAME(
100 std::string, Base, "_getPersistenceName", getPersistenceName
101 );
102 }
std::string getPersistenceName() const override
Return the unique name used to persist this object and look up its factory.
Definition python.h:98

◆ getPythonModule()

template<class Base = Storable>
std::string lsst::afw::typehandling::StorableHelper< Base >::getPythonModule ( ) const
inlineoverridevirtualinherited

Return the fully-qualified Python module that should be imported to guarantee that its factory is registered.

Must be less than ArchiveIndexSchema::MAX_MODULE_LENGTH characters.

Will be ignored if empty.

Reimplemented from lsst::afw::table::io::Persistable.

Definition at line 104 of file python.h.

104 {
105 PYBIND11_OVERLOAD_NAME(
106 std::string, Base, "_getPythonModule", getPythonModule
107 );
108 }
std::string getPythonModule() const override
Return the fully-qualified Python module that should be imported to guarantee that its factory is reg...
Definition python.h:104

◆ hash_value()

template<class Base = Storable>
std::size_t lsst::afw::typehandling::StorableHelper< Base >::hash_value ( ) const
inlineoverridevirtualinherited

Return a hash of this object (optional operation).

Exceptions
UnsupportedOperationExceptionThrown if this object is not hashable.
Note
C++ subclass authors are responsible for any associated specializations of std::hash.
When called on Python classes, this method delegates to __hash__ if it exists.

Reimplemented from lsst::afw::typehandling::Storable.

Definition at line 84 of file python.h.

84 {
85 PYBIND11_OVERLOAD_NAME(std::size_t, Base, "__hash__", hash_value, );
86 }
std::size_t hash_value() const override
Return a hash of this object (optional operation).
Definition python.h:84

◆ isPersistable()

template<class Base = Storable>
bool lsst::afw::typehandling::StorableHelper< Base >::isPersistable ( ) const
inlineoverridevirtualnoexceptinherited

Return true if this particular object can be persisted using afw::table::io.

Reimplemented from lsst::afw::table::io::Persistable.

Definition at line 92 of file python.h.

92 {
93 PYBIND11_OVERLOAD(
94 bool, Base, isPersistable
95 );
96 }
bool isPersistable() const noexcept override
Return true if this particular object can be persisted using afw::table::io.
Definition python.h:92

◆ resized()

template<typename Base = Psf>
std::shared_ptr< Psf > lsst::afw::detection::PsfTrampoline< Base >::resized ( int width,
int height ) const
inlineoverrideinherited

Definition at line 76 of file python.h.

76 {
77 PYBIND11_OVERLOAD_PURE(std::shared_ptr<Psf>, Base, resized, width, height);
78 }
std::shared_ptr< Psf > resized(int width, int height) const override
Definition python.h:76

◆ singleClassEquals()

template<class T >
static bool lsst::afw::typehandling::Storable::singleClassEquals ( T const & lhs,
Storable const & rhs )
inlinestaticprotectedinherited

Test if a Storable is of a particular class and equal to another object.

This method template simplifies implementations of equals that delegate to operator== without supporting cross-class comparisons.

Template Parameters
TThe class expected of the two objects to be compared.
Parameters
lhs,rhsThe objects to compare. Note that rhs need not be a T, while lhs must be.
Returns
true if rhs is a T and lhs == rhs; false otherwise.
Exception Safety
Provides the same level of exception safety as operator==. Most implementations of operator== do not throw.
Note
This method template calls operator== with both arguments of compile-time type T const&. Its use is not recommended if there would be any ambiguity as to which operator== gets picked by overload resolution.

This method template is typically called from equals as:

bool MyType::equals(Storable const& other) const noexcept {
    return singleClassEquals(*this, other);
}

Definition at line 151 of file Storable.h.

151 {
152 auto typedRhs = dynamic_cast<T const*>(&rhs);
153 if (typedRhs != nullptr) {
154 return lhs == *typedRhs;
155 } else {
156 return false;
157 }
158 }

◆ toString()

template<class Base = Storable>
std::string lsst::afw::typehandling::StorableHelper< Base >::toString ( ) const
inlineoverridevirtualinherited

Create a string representation of this object (optional operation).

Exceptions
UnsupportedOperationExceptionThrown if this object does not have a string representation.
Note
When called on Python classes, this method delegates to __repr__.

Reimplemented from lsst::afw::typehandling::Storable.

Definition at line 80 of file python.h.

80 {
81 PYBIND11_OVERLOAD_NAME(std::string, Base, "__repr__", toString, );
82 }
std::string toString() const override
Create a string representation of this object (optional operation).
Definition python.h:80

◆ write()

template<typename Base >
void StorableHelper::write ( table::io::OutputArchiveHandle & handle) const
overridevirtualinherited

Write the object to one or more catalogs.

The handle object passed to this function provides an interface for adding new catalogs and adding nested objects to the same archive (while checking for duplicates). See OutputArchiveHandle for more information.

Reimplemented from lsst::afw::table::io::Persistable.

Definition at line 193 of file python.h.

193 {
194 pybind11::gil_scoped_acquire gil;
195 pybind11::function overload = pybind11::get_overload(static_cast<const Base *>(this), "_write");
196 if (!overload)
197 throw std::runtime_error("Cannot find StorableHelper _write overload");
198 auto o = overload().cast<std::string>();
199 auto const &keys = StorableHelperPersistenceHelper::get();
200 table::BaseCatalog cat = handle.makeCatalog(keys.schema);
201 std::shared_ptr<table::BaseRecord> record = cat.addNew();
202 record->set(keys.bytes, formatters::stringToBytes(o));
203 handle.saveCatalog(cat);
204}
ndarray::Array< std::uint8_t, 1, 1 > stringToBytes(std::string const &str)
Encode a std::string as a vector of uint8.
Definition Utils.cc:43
CatalogT< BaseRecord > BaseCatalog
Definition fwd.h:72

◆ writeFits() [1/3]

void lsst::afw::table::io::Persistable::writeFits ( fits::Fits & fitsfile) const
inherited

Write the object to an already-open FITS object.

Parameters
[in]fitsfileOpen FITS object to write to.

Definition at line 18 of file Persistable.cc.

18 {
19 OutputArchive archive;
20 archive.put(this);
21 archive.writeFits(fitsfile);
22}

◆ writeFits() [2/3]

void lsst::afw::table::io::Persistable::writeFits ( fits::MemFileManager & manager,
std::string const & mode = "w" ) const
inherited

Write the object to a FITS image in memory.

Parameters
[in]managerName of the file to write to.
[in]modeIf "w", any existing file with the given name will be overwritten. If "a", new HDUs will be appended to an existing file.

Definition at line 29 of file Persistable.cc.

29 {
30 fits::Fits fitsfile(manager, mode, fits::Fits::AUTO_CLOSE | fits::Fits::AUTO_CHECK);
31 writeFits(fitsfile);
32}
void writeFits(std::string const &fileName, std::string const &mode="w") const
Write the object to a regular FITS file.

◆ writeFits() [3/3]

void lsst::afw::table::io::Persistable::writeFits ( std::string const & fileName,
std::string const & mode = "w" ) const
inherited

Write the object to a regular FITS file.

Parameters
[in]fileNameName of the file to write to.
[in]modeIf "w", any existing file with the given name will be overwritten. If "a", new HDUs will be appended to an existing file.

Definition at line 24 of file Persistable.cc.

24 {
25 fits::Fits fitsfile(fileName, mode, fits::Fits::AUTO_CLOSE | fits::Fits::AUTO_CHECK);
26 writeFits(fitsfile);
27}

Friends And Related Symbol Documentation

◆ operator<<()

std::ostream & operator<< ( std::ostream & os,
Storable const & storable )
related

Output operator for Storable.

Parameters
osthe desired output stream
storablethe object to print
Returns
a reference to os
Exceptions
UnsupportedOperationExceptionThrown if storable does not have an implementation of Storable::toString.

Definition at line 174 of file Storable.h.

174 {
175 return os << storable.toString();
176}

The documentation for this class was generated from the following file: