40class PeakFitsWriter :
public afw::table::io::FitsWriter {
42 explicit PeakFitsWriter(Fits* fits,
int flags) : afw::table::io::FitsWriter(fits, flags) {}
52 "Cannot use a PeakFitsWriter on a non-Peak table.");
54 afw::table::io::FitsWriter::_writeTable(table, nRows);
55 _fits->writeKey(
"AFW_TYPE",
"PEAK",
"Tells lsst::afw to load this as a Peak table.");
69class PeakFitsReader :
public afw::table::io::FitsReader {
71 PeakFitsReader() : afw::table::io::FitsReader(
"PEAK") {}
75 int ioFlags,
bool stripMetadata)
const override {
77 table->setMetadata(metadata);
83static PeakFitsReader
const peakFitsReader;
92 return os << (boost::format(
"%d: (%d,%d) (%.3f,%.3f)") % record.
getId() % record.
getIx() %
98 static CachedTableList cache;
99 if (!checkSchema(
schema)) {
101 "Schema for Peak must contain at least the keys defined by makeMinimalSchema().");
106 CachedTableList::iterator iter = cache.begin();
107 while (iter != cache.end()) {
110 iter = cache.erase(iter);
116 if (iter != cache.begin()) {
117 cache.splice(cache.begin(), cache, iter);
126 cache.push_front(newTable);
132 : afw::table::BaseTable(
schema), _idFactory(idFactory) {}
135 : afw::table::BaseTable(other),
136 _idFactory(other._idFactory ? other._idFactory->clone() : other._idFactory) {}
142PeakTable::MinimalSchema::MinimalSchema() {
144 fx = schema.
addField<
float>(
"f_x",
"subpixel column position",
"pixel");
145 fy = schema.
addField<
float>(
"f_y",
"subpixel row position",
"pixel");
146 ix = schema.
addField<
int>(
"i_x",
"column position of highest pixel",
"pixel");
147 iy = schema.
addField<
int>(
"i_y",
"row position of highest pixel",
"pixel");
148 peakValue = schema.
addField<
float>(
"peakValue",
"value of [smoothed] image at peak position",
"count");
151PeakTable::MinimalSchema& PeakTable::getMinimalSchema() {
152 static MinimalSchema it;
157 return std::make_shared<PeakFitsWriter>(fitsfile, flags);
165 auto record = constructRecord<PeakRecord>();
174template class CatalogT<afw::detection::PeakRecord>;
175template class CatalogT<afw::detection::PeakRecord const>;
#define LSST_EXCEPT(type,...)
Record class that represents a peak in a Footprint.
afw::table::RecordId getId() const
Convenience accessors for the keys in the minimal schema.
Table class for Peaks in Footprints.
std::shared_ptr< afw::table::BaseTable > _clone() const override
Clone implementation with noncovariant return types.
PeakTable(afw::table::Schema const &schema, std::shared_ptr< afw::table::IdFactory > const &idFactory)
std::shared_ptr< afw::table::BaseRecord > _makeRecord() override
Default-construct an associated record (protected implementation).
std::shared_ptr< afw::table::IdFactory > getIdFactory()
Return the object that generates IDs for the table (may be null).
std::shared_ptr< afw::table::io::FitsWriter > makeFitsWriter(fits::Fits *fitsfile, int flags) const override
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.
A simple struct that combines the two arguments that must be passed to most cfitsio routines and cont...
static std::shared_ptr< IdFactory > makeSimple()
Return a simple IdFactory that simply counts from 1.
Defines the fields and offsets for a table.
Key< T > addField(Field< T > const &field, bool doReplace=false)
Add a new field to the Schema, and return the associated Key.
@ IDENTICAL
Everything is the same.
std::ostream & operator<<(std::ostream &os, Footprint const &rhs)
Print a Footprint to the stream.