LSSTApplications  10.0+286,10.0+36,10.0+46,10.0-2-g4f67435,10.1+152,10.1+37,11.0,11.0+1,11.0-1-g47edd16,11.0-1-g60db491,11.0-1-g7418c06,11.0-2-g04d2804,11.0-2-g68503cd,11.0-2-g818369d,11.0-2-gb8b8ce7
LSSTDataManagementBasePackage
Public Member Functions | Public Attributes | List of all members
lsst::afw::math::Kernel::PersistenceHelper Struct Reference

#include <KernelPersistenceHelper.h>

Public Member Functions

 PersistenceHelper (int nSpatialFunctions)
 
 PersistenceHelper (afw::table::Schema const &schema_)
 
boost::shared_ptr
< afw::table::BaseRecord
write (afw::table::io::OutputArchiveHandle &handle, Kernel const &kernel) const
 
void writeSpatialFunctions (afw::table::io::OutputArchiveHandle &handle, afw::table::BaseRecord &record, std::vector< SpatialFunctionPtr > const &spatialFunctionList) const
 
std::vector< SpatialFunctionPtrreadSpatialFunctions (afw::table::io::InputArchive const &archive, afw::table::BaseRecord const &record) const
 

Public Attributes

afw::table::Schema schema
 
afw::table::PointKey< int > dimensions
 
afw::table::PointKey< int > center
 
afw::table::Key
< afw::table::Array< int > > 
spatialFunctions
 

Detailed Description

Definition at line 37 of file KernelPersistenceHelper.h.

Constructor & Destructor Documentation

lsst::afw::math::Kernel::PersistenceHelper::PersistenceHelper ( int  nSpatialFunctions)
explicit

Definition at line 31 of file KernelPersistenceHelper.cc.

31  :
32  schema(),
33  dimensions(
35  schema, "dimensions", "dimensions of a Kernel's images", "pixels"
36  )
37  ),
38  center(
39  afw::table::PointKey<int>::addFields(schema, "center", "center point in a Kernel image", "pixels")
40  )
41 {
42  if (nSpatialFunctions > 0) {
43  spatialFunctions = schema.addField< afw::table::Array<int> >(
44  "spatialfunctions", "archive IDs for the Kernel's spatial functions", nSpatialFunctions
45  );
46  }
47 }
static PointKey addFields(Schema &schema, std::string const &name, std::string const &doc, std::string const &unit)
Key< T > addField(Field< T > const &field, bool doReplace=false)
Add a new field to the Schema, and return the associated Key.
afw::table::Key< afw::table::Array< int > > spatialFunctions
lsst::afw::math::Kernel::PersistenceHelper::PersistenceHelper ( afw::table::Schema const &  schema_)
explicit

Definition at line 49 of file KernelPersistenceHelper.cc.

49  :
50  schema(schema_),
51  dimensions(schema["dimensions"]),
52  center(schema["center"])
53 {
54  try {
55  spatialFunctions = schema["spatialfunctions"];
56  } catch (...) {}
57 }
afw::table::Key< afw::table::Array< int > > spatialFunctions

Member Function Documentation

std::vector< boost::shared_ptr< Kernel::SpatialFunction > > lsst::afw::math::Kernel::PersistenceHelper::readSpatialFunctions ( afw::table::io::InputArchive const &  archive,
afw::table::BaseRecord const &  record 
) const

Definition at line 85 of file KernelPersistenceHelper.cc.

88  {
90  std::vector<PTR(Kernel::SpatialFunction)> spatialFunctionList(array.getSize<0>());
91  for (std::size_t n = 0; n < spatialFunctionList.size(); ++n) {
92  spatialFunctionList[n] = archive.get<SpatialFunction>(array[n]);
93  LSST_ARCHIVE_ASSERT(array[n] == 0 || (spatialFunctionList[n]));
94  }
95  return spatialFunctionList;
96 }
lsst::afw::math::Function2< double > SpatialFunction
Definition: Kernel.h:144
int getSize() const
Return the size of a specific dimension.
Definition: ArrayBase.h:126
afw::table::Key< afw::table::Array< int > > spatialFunctions
#define LSST_ARCHIVE_ASSERT(EXPR)
An assertion macro used to validate the structure of an InputArchive.
Definition: Persistable.h:47
A multidimensional strided array.
Definition: Array.h:47
boost::shared_ptr< afw::table::BaseRecord > lsst::afw::math::Kernel::PersistenceHelper::write ( afw::table::io::OutputArchiveHandle handle,
Kernel const &  kernel 
) const

Definition at line 59 of file KernelPersistenceHelper.cc.

62  {
63  afw::table::BaseCatalog catalog = handle.makeCatalog(schema);
64  PTR(afw::table::BaseRecord) record = catalog.addNew();
65  record->set(dimensions, geom::Point2I(kernel.getDimensions()));
66  record->set(center, kernel.getCtr());
67  if (spatialFunctions.isValid()) {
68  writeSpatialFunctions(handle, *record, kernel._spatialFunctionList);
69  }
70  handle.saveCatalog(catalog);
71  return record;
72 }
geom::Extent2I const getDimensions() const
Return the Kernel&#39;s dimensions (width, height)
Definition: Kernel.h:226
CatalogT< BaseRecord > BaseCatalog
Definition: fwd.h:61
#define PTR(...)
Definition: base.h:41
Point< int, 2 > Point2I
Definition: Point.h:283
afw::table::Key< afw::table::Array< int > > spatialFunctions
if(width!=gim.getWidth()||height!=gim.getHeight()||x0!=gim.getX0()||y0!=gim.getY0())
Definition: saturated.cc:47
lsst::afw::geom::Point2I getCtr() const
Return index of kernel&#39;s center.
Definition: Kernel.h:254
void writeSpatialFunctions(afw::table::io::OutputArchiveHandle &handle, afw::table::BaseRecord &record, std::vector< SpatialFunctionPtr > const &spatialFunctionList) const
void lsst::afw::math::Kernel::PersistenceHelper::writeSpatialFunctions ( afw::table::io::OutputArchiveHandle handle,
afw::table::BaseRecord record,
std::vector< SpatialFunctionPtr > const &  spatialFunctionList 
) const

Definition at line 74 of file KernelPersistenceHelper.cc.

78  {
80  for (std::size_t n = 0; n < spatialFunctionList.size(); ++n) {
81  array[n] = handle.put(spatialFunctionList[n]);
82  }
83 }
afw::table::Key< afw::table::Array< int > > spatialFunctions

Member Data Documentation

afw::table::PointKey<int> lsst::afw::math::Kernel::PersistenceHelper::center

Definition at line 40 of file KernelPersistenceHelper.h.

afw::table::PointKey<int> lsst::afw::math::Kernel::PersistenceHelper::dimensions

Definition at line 39 of file KernelPersistenceHelper.h.

afw::table::Schema lsst::afw::math::Kernel::PersistenceHelper::schema

Definition at line 38 of file KernelPersistenceHelper.h.

afw::table::Key< afw::table::Array<int> > lsst::afw::math::Kernel::PersistenceHelper::spatialFunctions

Definition at line 41 of file KernelPersistenceHelper.h.


The documentation for this struct was generated from the following files: