42 class PeakFitsWriter :
public afw::table::io::FitsWriter {
44 explicit PeakFitsWriter(Fits* fits,
int flags) : afw::table::io::FitsWriter(fits, flags) {}
54 "Cannot use a PeakFitsWriter on a non-Peak table.");
57 _fits->writeKey(
"AFW_TYPE",
"PEAK",
"Tells lsst::afw to load this as a Peak table.");
71 class PeakFitsReader :
public afw::table::io::FitsReader {
73 PeakFitsReader() : afw::table::io::FitsReader(
"PEAK") {}
77 int ioFlags,
bool stripMetadata)
const {
79 table->setMetadata(metadata);
85 static PeakFitsReader
const peakFitsReader;
96 return os << (boost::format(
"%d: (%d,%d) (%.3f,%.3f)") % record.
getId() % record.
getIx() %
102 static CachedTableList cache;
103 if (!checkSchema(schema)) {
105 "Schema for Peak must contain at least the keys defined by makeMinimalSchema().");
110 CachedTableList::iterator iter = cache.begin();
111 while (iter != cache.end()) {
114 iter = cache.erase(iter);
120 if (iter != cache.begin()) {
121 cache.splice(cache.begin(), cache, iter);
130 cache.push_front(newTable);
136 : afw::table::
BaseTable(schema), _idFactory(idFactory) {}
140 _idFactory(other._idFactory ? other._idFactory->
clone() : other._idFactory) {}
146 PeakTable::MinimalSchema::MinimalSchema() {
148 fx =
schema.addField<
float>(
"f_x",
"subpixel column position",
"pixel");
149 fy =
schema.addField<
float>(
"f_y",
"subpixel row position",
"pixel");
150 ix =
schema.addField<
int>(
"i_x",
"column position of highest pixel",
"pixel");
151 iy =
schema.addField<
int>(
"i_y",
"row position of highest pixel",
"pixel");
152 peakValue =
schema.addField<
float>(
"peakValue",
"value of [smoothed] image at peak position",
"count");
153 schema.getCitizen().markPersistent();
156 PeakTable::MinimalSchema& PeakTable::getMinimalSchema() {
157 static MinimalSchema it;
162 return std::make_shared<PeakFitsWriter>(fitsfile, flags);
179 template class CatalogT<afw::detection::PeakRecord>;
180 template class CatalogT<afw::detection::PeakRecord const>;
Defines the fields and offsets for a table.
int getIy() const
Convenience accessors for the keys in the minimal schema.
std::ostream & operator<<(std::ostream &os, PeakRecord const &record)
std::shared_ptr< afw::table::IdFactory > getIdFactory()
Return the object that generates IDs for the table (may be null).
afw::table::Schema schema
std::shared_ptr< PeakTable > clone() const
Return a polymorphic deep copy of the table.
PeakRecord(PeakRecord const &)=delete
Table class for Peaks in Footprints.
static std::shared_ptr< PeakTable > make(afw::table::Schema const &schema, bool forceNew=false)
Obtain a table that can be used to create records with given schema.
std::shared_ptr< afw::table::BaseRecord > _makeRecord() override
Default-construct an associated record (protected implementation).
A simple struct that combines the two arguments that must be passed to most cfitsio routines and cont...
afw::table::RecordId getId() const
Convenience accessors for the keys in the minimal schema.
PeakTable(afw::table::Schema const &schema, std::shared_ptr< afw::table::IdFactory > const &idFactory)
A base class for image defects.
static std::shared_ptr< IdFactory > makeSimple()
Return a simple IdFactory that simply counts from 1.
virtual void _writeTable(std::shared_ptr< BaseTable const > const &table, std::size_t nRows)
Write a table and its schema.
BaseTable(Schema const &schema)
Construct from a schema.
T dynamic_pointer_cast(T... args)
int getIx() const
Convenience accessors for the keys in the minimal schema.
#define LSST_EXCEPT(type,...)
std::shared_ptr< afw::table::BaseTable > _clone() const override
Clone implementation with noncovariant return types.
Record class that represents a peak in a Footprint.
float getFy() const
Convenience accessors for the keys in the minimal schema.
float getFx() const
Convenience accessors for the keys in the minimal schema.