45 :
Kernel(width, height, kernelFunction.getNParameters(), spatialFunction),
52 std::ostringstream os;
53 os <<
"kernelFunction.getNParameters() = " << kernelFunction.getNParameters()
54 <<
" != " << spatialFunctionList.size() <<
" = "
55 <<
"spatialFunctionList.size()";
56 throw LSST_EXCEPT(pexExcept::InvalidParameterError, os.str());
68 retPtr->setCtr(this->
getCtr());
97 os << prefix <<
"AnalyticKernel:" <<
std::endl;
113 for (
int y = 0; y !=
image.getHeight(); ++y) {
116 for (
int x = 0; x !=
image.getWidth(); ++x, ++ptr) {
118 Pixel const pixelVal = (*_kernelFunctionPtr)(fx, fy);
124 if (doNormalize && (imSum != 1)) {
126 throw LSST_EXCEPT(pexExcept::OverflowError,
"Cannot normalize; kernel sum is 0");
146 explicit AnalyticKernelPersistenceHelper(
int nSpatialFunctions)
147 :
Kernel::PersistenceHelper(nSpatialFunctions),
148 kernelFunction(schema.addField<int>(
149 "kernelfunction",
"archive ID for analytic function used to produce kernel images")) {}
151 explicit AnalyticKernelPersistenceHelper(
table::Schema const &schema_)
152 : Kernel::PersistenceHelper(schema_), kernelFunction(schema[
"kernelfunction"]) {}
163 AnalyticKernelPersistenceHelper
const keys(catalogs.front().getSchema());
168 if (keys.spatialFunctions.isValid()) {
170 record.
get(keys.dimensions.getY()), *kernelFunction,
171 keys.readSpatialFunctions(archive, record));
174 record.
get(keys.dimensions.getY()), *kernelFunction);
176 result->setCtr(record.
get(keys.center));
185std::string getAnalyticKernelPersistenceName() {
return "AnalyticKernel"; }
187AnalyticKernel::Factory registration(getAnalyticKernelPersistenceName());
#define LSST_EXCEPT(type,...)
Create an exception with a given type.
#define LSST_ARCHIVE_ASSERT(EXPR)
An assertion macro used to validate the structure of an InputArchive.
A class to represent a 2-dimensional array of pixels.
std::shared_ptr< afw::table::io::Persistable > read(InputArchive const &archive, CatalogVector const &catalogs) const override
Construct a new object from the given InputArchive and vector of catalogs.
Factory(std::string const &name)
A kernel described by a function.
std::vector< double > getKernelParameters() const override
Return the current kernel parameters.
std::string toString(std::string const &prefix="") const override
Return a string representation of the kernel.
lsst::afw::math::Function2< Pixel > KernelFunction
std::shared_ptr< Kernel > resized(int width, int height) const override
Return a pointer to a clone with specified kernel dimensions.
double computeImage(lsst::afw::image::Image< Pixel > &image, bool doNormalize, double x=0.0, double y=0.0) const
Compute an image (pixellized representation of the kernel) in place.
std::shared_ptr< Kernel > clone() const override
Return a pointer to a deep copy of this kernel.
void setKernelParameter(unsigned int ind, double value) const override
Set one kernel parameter.
virtual KernelFunctionPtr getKernelFunction() const
Get a deep copy of the kernel function.
double doComputeImage(lsst::afw::image::Image< Pixel > &image, bool doNormalize) const override
Low-level version of computeImage.
void write(OutputArchiveHandle &handle) const override
Write the object to one or more catalogs.
KernelFunctionPtr _kernelFunctionPtr
std::shared_ptr< lsst::afw::math::Function2< Pixel > > KernelFunctionPtr
std::string getPersistenceName() const override
Return the unique name used to persist this object and look up its factory.
AnalyticKernel()
Construct an empty spatially invariant AnalyticKernel of size 0x0.
unsigned int getNParameters() const noexcept
Return the number of function parameters.
Kernels are used for convolution with MaskedImages and (eventually) Images.
lsst::geom::Extent2I const getDimensions() const
Return the Kernel's dimensions (width, height)
std::vector< SpatialFunctionPtr > _spatialFunctionList
int getHeight() const
Return the Kernel's height.
lsst::geom::Point2I getCtr() const
Return index of kernel's center.
virtual std::string toString(std::string const &prefix="") const
Return a string representation of the kernel.
lsst::afw::math::Function2< double > SpatialFunction
int getWidth() const
Return the Kernel's width.
bool isSpatiallyVarying() const
Return true iff the kernel is spatially varying (has a spatial function)
Kernel()
Construct a null Kernel of size 0,0.
void setKernelParametersFromSpatialModel(double x, double y) const
Set the kernel parameters from the spatial model (if any).
Base class for all records.
Field< T >::Value get(Key< T > const &key) const
Return the value of a field for the given key.
A class used as a handle to a particular field in a table.
Defines the fields and offsets for a table.
int put(Persistable const *obj, bool permissive=false)
Save an object to the archive and return a unique ID that can be used to retrieve it from an InputArc...
A CRTP facade class for subclasses of Persistable.
A base class for factory classes used to reconstruct objects from records.
io::CatalogVector CatalogVector
io::InputArchive InputArchive
PersistableFactory(std::string const &name)
Constructor for the factory.
io::OutputArchiveHandle OutputArchiveHandle
Extent< int, 2 > Extent2I