LSSTApplications  19.0.0-11-g2ce9f25+4,20.0.0+1,20.0.0+10,20.0.0+11,20.0.0+13,20.0.0+2,20.0.0+3,20.0.0+4,20.0.0+6,20.0.0-1-g10df615+10,20.0.0-1-g253301a+5,20.0.0-1-g596936a+11,20.0.0-1-g8a53f90+1,20.0.0-1-gc96f8cb+12,20.0.0-1-gd1c87d7+1,20.0.0-17-g41c5faf,20.0.0-2-g04cfba9+4,20.0.0-2-gd11eeda,20.0.0-2-gec03fae+3,20.0.0-3-g082faa5+1,20.0.0-3-gbdbfa727+3,20.0.0-3-gc53c7b6,20.0.0-4-gde602ef96+4,20.0.0-4-ge48a6ca+6,20.0.0-4-ge987224+1,20.0.0-8-g7eef53f7+7,20.0.0-9-g8e1b333,w.2020.28
LSSTDataManagementBasePackage
Peak.h
Go to the documentation of this file.
1 // -*- lsst-c++ -*-
2 /*
3  * LSST Data Management System
4  * Copyright 2008-2014 LSST Corporation.
5  *
6  * This product includes software developed by the
7  * LSST Project (http://www.lsst.org/).
8  *
9  * This program is free software: you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation, either version 3 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the LSST License Statement and
20  * the GNU General Public License along with this program. If not,
21  * see <http://www.lsstcorp.org/LegalNotices/>.
22  */
23 #ifndef AFW_DETECTION_Peak_h_INCLUDED
24 #define AFW_DETECTION_Peak_h_INCLUDED
25 
29 #include "lsst/afw/table/Catalog.h"
31 
32 namespace lsst {
33 namespace afw {
34 namespace detection {
35 
36 class PeakRecord;
37 class PeakTable;
38 
43 public:
44  typedef PeakTable Table;
48 
59  BaseRecord(token, std::move(data))
60  {}
61 
62  ~PeakRecord() override = default;
63  PeakRecord(PeakRecord const&) = delete;
64  PeakRecord(PeakRecord&&) = delete;
65  PeakRecord& operator=(PeakRecord const&) = delete;
67 
69  return std::static_pointer_cast<PeakTable const>(afw::table::BaseRecord::getTable());
70  }
71 
75  void setId(afw::table::RecordId id);
76 
77  int getIx() const;
78  int getIy() const;
79  void setIx(int ix);
80  void setIy(int iy);
82  lsst::geom::Point2I getCentroid(bool) const { return getI(); }
83 
84  float getFx() const;
85  float getFy() const;
86  void setFx(float fx);
87  void setFy(float fy);
89  lsst::geom::Point2D getCentroid() const { return getF(); }
90 
91  float getPeakValue() const;
92  void setPeakValue(float peakValue);
94 
95 private:
96  friend class PeakTable;
97 };
98 
103 public:
108 
109  ~PeakTable() override;
110  PeakTable& operator=(PeakTable const&) = delete;
112 
128  static std::shared_ptr<PeakTable> make(afw::table::Schema const& schema, bool forceNew = false);
129 
137  static afw::table::Schema makeMinimalSchema() { return getMinimalSchema().schema; }
138 
145  static bool checkSchema(afw::table::Schema const& other) {
146  return other.contains(getMinimalSchema().schema);
147  }
148 
151 
154 
157 
159 
164  static afw::table::Key<afw::table::RecordId> getIdKey() { return getMinimalSchema().id; }
165  static afw::table::Key<int> getIxKey() { return getMinimalSchema().ix; }
166  static afw::table::Key<int> getIyKey() { return getMinimalSchema().iy; }
167  static afw::table::Key<float> getFxKey() { return getMinimalSchema().fx; }
168  static afw::table::Key<float> getFyKey() { return getMinimalSchema().fy; }
169  static afw::table::Key<float> getPeakValueKey() { return getMinimalSchema().peakValue; }
171 
173  std::shared_ptr<PeakTable> clone() const { return std::static_pointer_cast<PeakTable>(_clone()); }
174 
176  std::shared_ptr<PeakRecord> makeRecord() { return std::static_pointer_cast<PeakRecord>(_makeRecord()); }
177 
180  return std::static_pointer_cast<PeakRecord>(afw::table::BaseTable::copyRecord(other));
181  }
182 
186  return std::static_pointer_cast<PeakRecord>(afw::table::BaseTable::copyRecord(other, mapper));
187  }
188 
189 protected:
191 
192  PeakTable(PeakTable const& other);
194 
196 
198 
199 private:
200  // Struct that holds the minimal schema and the special keys we've added to it.
201  struct MinimalSchema {
208  afw::table::Key<float> peakValue;
209 
210  MinimalSchema();
211  };
212 
213  // Return the singleton minimal schema.
214  static MinimalSchema& getMinimalSchema();
215 
217 
218  // Return a writer object that knows how to save in FITS format. See also FitsWriter.
220  int flags) const override;
221 
222  std::shared_ptr<afw::table::IdFactory> _idFactory; // generates IDs for new records
223 };
224 
226 
229 
230 inline int PeakRecord::getIx() const { return get(PeakTable::getIxKey()); }
231 inline int PeakRecord::getIy() const { return get(PeakTable::getIyKey()); }
232 inline void PeakRecord::setIx(int ix) { set(PeakTable::getIxKey(), ix); }
233 inline void PeakRecord::setIy(int iy) { set(PeakTable::getIyKey(), iy); }
234 
235 inline float PeakRecord::getFx() const { return get(PeakTable::getFxKey()); }
236 inline float PeakRecord::getFy() const { return get(PeakTable::getFyKey()); }
237 inline void PeakRecord::setFx(float fx) { set(PeakTable::getFxKey(), fx); }
238 inline void PeakRecord::setFy(float fy) { set(PeakTable::getFyKey(), fy); }
239 
240 inline float PeakRecord::getPeakValue() const { return get(PeakTable::getPeakValueKey()); }
241 inline void PeakRecord::setPeakValue(float peakValue) { set(PeakTable::getPeakValueKey(), peakValue); }
242 
246 } // namespace detection
247 } // namespace afw
248 } // namespace lsst
249 
250 #endif // !AFW_DETECTION_Peak_h_INCLUDED
schema
table::Schema schema
Definition: Amplifier.cc:115
lsst::afw::detection::operator<<
std::ostream & operator<<(std::ostream &os, PeakRecord const &record)
Definition: Peak.cc:93
lsst::afw::detection::PeakRecord::setFx
void setFx(float fx)
Definition: Peak.h:237
lsst::afw::detection::PeakTable::_clone
std::shared_ptr< afw::table::BaseTable > _clone() const override
Clone implementation with noncovariant return types.
Definition: Peak.cc:162
lsst::afw::detection::PeakTable::Record
PeakRecord Record
Definition: Peak.h:104
lsst::afw::detection::PeakRecord::~PeakRecord
~PeakRecord() override=default
std::shared_ptr
STL class.
lsst::afw::detection::PeakRecord
Record class that represents a peak in a Footprint.
Definition: Peak.h:42
lsst::afw::table::BaseRecord::get
Field< T >::Value get(Key< T > const &key) const
Return the value of a field for the given key.
Definition: BaseRecord.h:151
lsst::afw::table::ColumnViewT
Definition: BaseColumnView.h:170
lsst::afw::detection::PeakTable::copyRecord
std::shared_ptr< PeakRecord > copyRecord(afw::table::BaseRecord const &other, afw::table::SchemaMapper const &mapper)
Deep-copy a record, requiring that it have the same schema as this table.
Definition: Peak.h:184
lsst::afw::fits::Fits
A simple struct that combines the two arguments that must be passed to most cfitsio routines and cont...
Definition: fits.h:297
lsst::afw::detection::PeakRecord::setId
void setId(afw::table::RecordId id)
Definition: Peak.h:228
lsst::afw::detection::PeakTable::~PeakTable
~PeakTable() override
lsst::afw::detection::PeakTable::getFyKey
static afw::table::Key< float > getFyKey()
Definition: Peak.h:168
lsst::afw
Definition: imageAlgorithm.dox:1
lsst::afw::detection::PeakRecord::getId
afw::table::RecordId getId() const
Convenience accessors for the keys in the minimal schema.
Definition: Peak.h:227
BaseColumnView.h
lsst::afw::detection::PeakRecord::operator=
PeakRecord & operator=(PeakRecord &&)=delete
lsst::afw::detection::PeakTable::clone
std::shared_ptr< PeakTable > clone() const
Return a polymorphic deep copy of the table.
Definition: Peak.h:173
lsst::afw::detection::PeakTable::getIyKey
static afw::table::Key< int > getIyKey()
Definition: Peak.h:166
lsst::afw::detection::PeakRecord::PeakRecord
PeakRecord(PeakRecord const &)=delete
lsst::afw::table::Schema
Defines the fields and offsets for a table.
Definition: Schema.h:50
lsst::afw::detection::PeakTable::copyRecord
std::shared_ptr< PeakRecord > copyRecord(afw::table::BaseRecord const &other)
Deep-copy a record, requiring that it have the same schema as this table.
Definition: Peak.h:179
lsst::afw::detection::PeakRecord::getIy
int getIy() const
Definition: Peak.h:231
lsst::afw::table::detail::RecordData
Helper struct that contains the information passed from BaseTable to BaseRecord at construction.
Definition: BaseTable.h:32
lsst::geom::Point2D
Point< double, 2 > Point2D
Definition: Point.h:324
lsst::afw::table::BaseTable
Base class for all tables.
Definition: BaseTable.h:61
lsst::afw::detection::PeakTable::makeMinimalSchema
static afw::table::Schema makeMinimalSchema()
Return a minimal schema for Peak tables and records.
Definition: Peak.h:137
BaseRecord.h
lsst::afw::detection::ConstPeakCatalog
afw::table::CatalogT< PeakRecord const > ConstPeakCatalog
Definition: Peak.h:245
lsst::afw::detection::PeakRecord::getCentroid
lsst::geom::Point2I getCentroid(bool) const
Definition: Peak.h:82
data
char * data
Definition: BaseRecord.cc:62
lsst::afw::detection::PeakTable::getIxKey
static afw::table::Key< int > getIxKey()
Definition: Peak.h:165
lsst::afw::detection::PeakTable::make
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.
Definition: Peak.cc:98
lsst::afw::table::BaseRecord::BaseRecord
BaseRecord(ConstructionToken const &, detail::RecordData &&data)
Construct a record with uninitialized data.
Definition: BaseRecord.cc:144
lsst::afw::detection::PeakRecord::getI
lsst::geom::Point2I getI() const
Definition: Peak.h:81
std::ostream
STL class.
lsst::afw::detection::PeakTable::getIdFactory
std::shared_ptr< afw::table::IdFactory const > getIdFactory() const
Return the object that generates IDs for the table (may be null).
Definition: Peak.h:153
lsst::afw::detection::PeakTable::getFxKey
static afw::table::Key< float > getFxKey()
Definition: Peak.h:167
id
table::Key< int > id
Definition: Detector.cc:162
lsst::afw::detection::PeakTable::getIdFactory
std::shared_ptr< afw::table::IdFactory > getIdFactory()
Return the object that generates IDs for the table (may be null).
Definition: Peak.h:150
other
ItemVariant const * other
Definition: Schema.cc:56
lsst::afw::table::BaseRecord
Base class for all records.
Definition: BaseRecord.h:31
lsst::afw::table::SchemaMapper
A mapping between the keys of two Schemas, used to copy data between them.
Definition: SchemaMapper.h:21
IdFactory.h
lsst::afw::detection::PeakCatalog
afw::table::CatalogT< PeakRecord > PeakCatalog
Definition: Peak.h:244
lsst::afw::detection::PeakRecord::ConstCatalog
afw::table::CatalogT< PeakRecord const > ConstCatalog
Definition: Peak.h:47
lsst::afw::table::Key
A class used as a handle to a particular field in a table.
Definition: fwd.h:45
lsst::afw::detection::PeakRecord::getPeakValue
float getPeakValue() const
Definition: Peak.h:240
lsst::afw::detection::PeakTable::Catalog
afw::table::CatalogT< Record > Catalog
Definition: Peak.h:106
lsst::afw::detection::PeakRecord::PeakRecord
PeakRecord(ConstructionToken const &token, table::detail::RecordData &&data)
Constructor used by PeakTable.
Definition: Peak.h:58
std::int64_t
lsst::afw::detection::PeakTable::operator=
PeakTable & operator=(PeakTable &&)=delete
lsst
A base class for image defects.
Definition: imageAlgorithm.dox:1
lsst::afw::detection::PeakRecord::Catalog
afw::table::CatalogT< PeakRecord > Catalog
Definition: Peak.h:46
lsst::afw::table::BaseRecord::ConstructionToken
Definition: BaseRecord.h:38
lsst::afw::detection::PeakRecord::getFx
float getFx() const
Definition: Peak.h:235
lsst::afw::detection::PeakTable::ConstCatalog
afw::table::CatalogT< Record const > ConstCatalog
Definition: Peak.h:107
lsst::afw::detection::PeakColumnView
afw::table::ColumnViewT< PeakRecord > PeakColumnView
Definition: Peak.h:243
lsst::afw::detection::PeakRecord::setFy
void setFy(float fy)
Definition: Peak.h:238
lsst::afw::detection::PeakTable::checkSchema
static bool checkSchema(afw::table::Schema const &other)
Return true if the given schema is a valid PeakTable schema.
Definition: Peak.h:145
os
std::ostream * os
Definition: Schema.cc:746
lsst::afw::detection::PeakRecord::Table
PeakTable Table
Definition: Peak.h:44
lsst::afw::detection::PeakRecord::PeakRecord
PeakRecord(PeakRecord &&)=delete
lsst::afw::detection::PeakRecord::setIx
void setIx(int ix)
Definition: Peak.h:232
std
STL namespace.
lsst::afw::detection::PeakRecord::getF
lsst::geom::Point2D getF() const
Definition: Peak.h:88
lsst::afw::detection::PeakTable::getIdKey
static afw::table::Key< afw::table::RecordId > getIdKey()
Get keys for standard fields shared by all peaks.
Definition: Peak.h:164
lsst::geom::Point< int, 2 >
lsst::afw::table::io::FitsWriter
Writer object for FITS binary tables.
Definition: FitsWriter.h:25
lsst::afw::table::BaseTable::copyRecord
std::shared_ptr< BaseRecord > copyRecord(BaseRecord const &input)
Deep-copy a record, requiring that it have the same schema as this table.
Definition: BaseTable.cc:125
lsst::afw::detection::PeakRecord::getCentroid
lsst::geom::Point2D getCentroid() const
Definition: Peak.h:89
lsst::geom::Point2I
Point< int, 2 > Point2I
Definition: Point.h:321
mapper
SchemaMapper * mapper
Definition: SchemaMapper.cc:78
lsst::afw::detection::PeakRecord::ColumnView
afw::table::ColumnViewT< PeakRecord > ColumnView
Definition: Peak.h:45
lsst::afw::detection::PeakTable::_makeRecord
std::shared_ptr< afw::table::BaseRecord > _makeRecord() override
Default-construct an associated record (protected implementation).
Definition: Peak.cc:166
lsst::afw::detection::PeakTable
Table class for Peaks in Footprints.
Definition: Peak.h:102
BaseTable.h
lsst::afw::detection::PeakTable::PeakTable
PeakTable(afw::table::Schema const &schema, std::shared_ptr< afw::table::IdFactory > const &idFactory)
Definition: Peak.cc:132
lsst::afw::detection::PeakRecord::getIx
int getIx() const
Definition: Peak.h:230
lsst::afw::detection::PeakRecord::operator=
PeakRecord & operator=(PeakRecord const &)=delete
lsst::afw::table::BaseRecord::getTable
std::shared_ptr< BaseTable const > getTable() const
Return the table this record is associated with.
Definition: BaseRecord.h:83
lsst::afw::detection::PeakTable::makeRecord
std::shared_ptr< PeakRecord > makeRecord()
Default-construct an associated record.
Definition: Peak.h:176
lsst::afw::detection::PeakTable::setIdFactory
void setIdFactory(std::shared_ptr< afw::table::IdFactory > f)
Switch to a new IdFactory – object that generates IDs for the table (may be null).
Definition: Peak.h:156
lsst::afw::table::BaseRecord::set
void set(Key< T > const &key, U const &value)
Set value of a field for the given key.
Definition: BaseRecord.h:164
lsst::afw::detection::PeakTable::operator=
PeakTable & operator=(PeakTable const &)=delete
Catalog.h
lsst::afw::detection::PeakTable::getPeakValueKey
static afw::table::Key< float > getPeakValueKey()
Definition: Peak.h:169
lsst::afw::detection::PeakRecord::getTable
std::shared_ptr< PeakTable const > getTable() const
Definition: Peak.h:68
lsst::afw::detection::PeakRecord::setPeakValue
void setPeakValue(float peakValue)
Definition: Peak.h:241
lsst::afw::table::CatalogT< PeakRecord >
lsst::afw::detection::PeakTable::ColumnView
afw::table::ColumnViewT< PeakRecord > ColumnView
Definition: Peak.h:105
lsst::afw::detection::PeakRecord::setIy
void setIy(int iy)
Definition: Peak.h:233
lsst::afw::detection::PeakRecord::getFy
float getFy() const
Definition: Peak.h:236