File Persistable.h¶
Defines
-
LSST_ARCHIVE_ASSERT
(EXPR)¶ An assertion macro used to validate the structure of an InputArchive.
This assertion is not enabled/disabled by NDEBUG, and throws an exception rather than aborting, and should be reserved for errors that should only occur when an InputArchive is found to be in a state that could not have been produced by an OutputArchive.
-
namespace
lsst
Class for a simple mapping implementing a generic AstrometryTransform.
Remove all non-astronomical counts from the Chunk Exposure’s pixels.
Forward declarations for lsst::utils::Cache
For details on the Cache class, see the Cache.h file.
It uses a template rather than a pointer so that the derived classes can use the specifics of the transform. The class simplePolyMapping overloads a few routines.
A base class for image defects
Numeric constants used by the Integrate.h integrator routines.
Compute Image Statistics
- Note
Gauss-Kronrod-Patterson quadrature coefficients for use in quadpack routine qng. These coefficients were calculated with 101 decimal digit arithmetic by L. W. Fullerton, Bell Labs, Nov 1981.
- Note
The Statistics class itself can only handle lsst::afw::image::MaskedImage() types. The philosophy has been to handle other types by making them look like lsst::afw::image::MaskedImage() and reusing that code. Users should have no need to instantiate a Statistics object directly, but should use the overloaded makeStatistics() factory functions.
-
namespace
afw
-
namespace
table
-
namespace
io
Functions
-
LSST_EXCEPTION_TYPE
(PersistenceError, lsst::pex::exceptions::IoError, lsst::afw::table::io::PersistenceError)¶ An exception thrown when problems occur during persistence. An exception thrown when an InputArchive’s contents do not make sense.
This is the exception thrown by the LSST_ARCHIVE_ASSERT macro.
-
class
Persistable
- #include <Persistable.h>
A base class for objects that can be persisted via afw::table::io Archive classes.
Inheriting from Persistable provides a public API for reading/writing individual objects to FITS that is fully defined in the base class, with derived classes only needing to implement persistence to catalogs. It is expected that objects that contain multiple persistables (such as Exposures) will create their own InputArchives and OutputArchives, and use these to avoid writing the same object twice (which would otherwise be a big concern for future objects like ExposureCatalog and CoaddPsf).
Generally speaking, an abstract base class that inherits from Persistable should also inherit from PersistableFacade<Base>. A concrete class that inherits (possibly indirectly) from Persistable should inherit from PersistableFacade<Derived> (though this just provides a slightly nicer interface to users), implement isPersistable(), getPersistenceName(), getPythonModule(), and write(), and define a subclass of PersistenceFactory. Inheritance from PersistableFacade should always precede inheritance from Persistable.
Persistable has no pure virtual member functions, and instead contains a default implementation that throws LogicError when the user attempts to save an object for which persistence has not actually been implemented.
Subclassed by lsst::afw::math::Function< Kernel::Pixel >, lsst::afw::cameraGeom::DetectorCollection, lsst::afw::cameraGeom::TransformMap, lsst::afw::detection::Footprint, lsst::afw::geom::Transform< FromEndpoint, ToEndpoint >, lsst::afw::math::BoundedField, lsst::afw::math::Function< ReturnT >, lsst::afw::math::Kernel, lsst::meas::modelfit::Mixture, lsst::afw::geom::Transform< afw::geom::Point2Endpoint, afw::geom::GenericEndpoint >
Public Functions
-
void
writeFits
(std::string const &fileName, std::string const &mode = "w") const Write the object to a regular FITS file.
- Parameters
[in] fileName
: Name of the file to write to.[in] mode
: If “w”, any existing file with the given name will be overwritten. If “a”, new HDUs will be appended to an existing file.
-
void
writeFits
(fits::MemFileManager &manager, std::string const &mode = "w") const Write the object to a FITS image in memory.
- Parameters
[in] manager
: Name of the file to write to.[in] mode
: If “w”, any existing file with the given name will be overwritten. If “a”, new HDUs will be appended to an existing file.
-
void
writeFits
(fits::Fits &fitsfile) const Write the object to an already-open FITS object.
- Parameters
[in] fitsfile
: Open FITS object to write to.
-
virtual bool
isPersistable
() const Return true if this particular object can be persisted using afw::table::io.
-
virtual
~Persistable
()
Protected Types
-
typedef io::OutputArchiveHandle
OutputArchiveHandle
Protected Functions
-
virtual std::string
getPersistenceName
() const Return the unique name used to persist this object and look up its factory.
Must be less than ArchiveIndexSchema::MAX_NAME_LENGTH characters.
-
virtual std::string
getPythonModule
() const 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.
-
virtual void
write
(OutputArchiveHandle &handle) const 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.
-
Persistable
()
-
Persistable
(Persistable const &other)
-
Persistable
(Persistable &&other)
-
Persistable &
operator=
(Persistable const &other)
-
Persistable &
operator=
(Persistable &&other)
Private Static Functions
-
static std::shared_ptr<Persistable>
_readFits
(std::string const &fileName, int hdu = fits::DEFAULT_HDU)¶
-
static std::shared_ptr<Persistable>
_readFits
(fits::MemFileManager &manager, int hdu = fits::DEFAULT_HDU)¶
-
static std::shared_ptr<Persistable>
_readFits
(fits::Fits &fitsfile)¶
Friends
-
friend
lsst::afw::table::io::io::OutputArchive
-
friend
lsst::afw::table::io::io::InputArchive
-
friend
lsst::afw::table::io::PersistableFacade
-
void
-
template<typename
T
>
classPersistableFacade
- #include <Persistable.h>
A CRTP facade class for subclasses of Persistable.
Derived classes should generally inherit from PersistableFacade at all levels, but only inherit from Persistable via the base class of each hierarchy. For example, with Psfs:
class Psf: public PersistableFacade<Psf>, public Persistable { ... }; class DoubleGaussianPsf: public PersistableFacade<DoubleGaussianPsf>, public Psf { ... };
Inheriting from PersistableFacade is not required for any classes but the base of each hierarchy, but doing so can save users from having to do some dynamic_casts.
- Note
PersistableFacade should usually be the first class in a list of base classes; if it appears after a base class that inherits from different specialization of PersistableFacade, those base class member functions will hide the desired ones.
Public Static Functions
-
static std::shared_ptr<T>
readFits
(fits::Fits &fitsfile) Read an object from an already open FITS object.
- Parameters
[in] fitsfile
: FITS object to read from, already positioned at the desired HDU.
-
static std::shared_ptr<T>
readFits
(std::string const &fileName, int hdu = fits::DEFAULT_HDU) Read an object from a regular FITS file.
- Parameters
[in] fileName
: Name of the file to read.[in] hdu
: HDU to read, where 0 is the primary. The special value of afw::fits::DEFAULT_HDU skips the primary HDU if it is empty.
-
static std::shared_ptr<T>
readFits
(fits::MemFileManager &manager, int hdu = fits::DEFAULT_HDU) Read an object from a FITS file in memory.
- Parameters
[in] manager
: Manager for the memory to read from.[in] hdu
: HDU to read, where 0 is the primary. The special value of afw::fits::DEFAULT_HDU skips the primary HDU if it is empty.
Dynamically cast a shared_ptr
You must provide an explicit template instantiation in the .cc file for each class that inherits from PersistableFacade. Designed to work around RTTI issues on macOS with hidden symbols;
Dynamically cast a shared pointer and raise on failure.
- Exceptions
lsst::pex::exceptions::LogicError
: if the cast fails
param[in] ptr The pointer to be cast.
- Return
The cast pointer.
- Exceptions
lsst::pex::exceptions::TypeError
: If the dynamic cast fails.
-
class
PersistableFactory
- #include <Persistable.h>
A base class for factory classes used to reconstruct objects from records.
Classes that inherit from Persistable should also subclass PersistableFactory, and instantiate exactly one instance of the derived factory with static duration (usually the class and instance are both defined in an anonymous namespace in a source file).
Subclassed by lsst::meas::algorithms::KernelPsfFactory< T, K >
Public Functions
-
PersistableFactory
(std::string const &name) Constructor for the factory.
This should be called only once, and only on an object with static duration, as a pointer to the object will be put in a singleton registry.
The name must be globally unique with respect to all Persistables and be the same as Persistable::getPersistenceName(); the Python module that a Persistable may also declare is not used to resolve names, but rather just to import the module that may install the necessary factory in the registry.
-
virtual std::shared_ptr<Persistable>
read
(InputArchive const &archive, CatalogVector const &catalogs) const = 0 Construct a new object from the given InputArchive and vector of catalogs.
-
virtual
~PersistableFactory
()
-
PersistableFactory
(const PersistableFactory&)
-
PersistableFactory &
operator=
(const PersistableFactory&)
-
PersistableFactory
(PersistableFactory&&)
-
PersistableFactory &
operator=
(PersistableFactory&&)
Public Static Functions
-
static PersistableFactory const &
lookup
(std::string const &name, std::string const &module = "") Return the factory that has been registered with the given name.
If the lookup fails and module is not an empty string, we will attempt to import a Python module with that name (this will only work when the C++ is being called from Python) and try again.
-
-
-
namespace
-
namespace