lsst.afw  14.0-25-g0e8fc950e+7
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 
51  }
52 
56  void setId(afw::table::RecordId id);
57 
58  int getIx() const;
59  int getIy() const;
60  void setIx(int ix);
61  void setIy(int iy);
63  afw::geom::Point2I getCentroid(bool) const { return getI(); }
64 
65  float getFx() const;
66  float getFy() const;
67  void setFx(float fx);
68  void setFy(float fy);
70  afw::geom::Point2D getCentroid() const { return getF(); }
71 
72  float getPeakValue() const;
73  void setPeakValue(float peakValue);
75 
76 protected:
77  explicit PeakRecord(std::shared_ptr<PeakTable> const& table);
78 
79 private:
80  friend class PeakTable;
81 };
82 
87 public:
88  typedef PeakRecord Record;
92 
108  static std::shared_ptr<PeakTable> make(afw::table::Schema const& schema, bool forceNew = false);
109 
117  static afw::table::Schema makeMinimalSchema() { return getMinimalSchema().schema; }
118 
125  static bool checkSchema(afw::table::Schema const& other) {
126  return other.contains(getMinimalSchema().schema);
127  }
128 
131 
134 
137 
139 
144  static afw::table::Key<afw::table::RecordId> getIdKey() { return getMinimalSchema().id; }
145  static afw::table::Key<int> getIxKey() { return getMinimalSchema().ix; }
146  static afw::table::Key<int> getIyKey() { return getMinimalSchema().iy; }
147  static afw::table::Key<float> getFxKey() { return getMinimalSchema().fx; }
148  static afw::table::Key<float> getFyKey() { return getMinimalSchema().fy; }
149  static afw::table::Key<float> getPeakValueKey() { return getMinimalSchema().peakValue; }
151 
154 
157 
161  }
162 
165  afw::table::SchemaMapper const& mapper) {
167  }
168 
169 protected:
171 
172  PeakTable(PeakTable const& other);
173 
174  std::shared_ptr<afw::table::BaseTable> _clone() const override;
175 
176  std::shared_ptr<afw::table::BaseRecord> _makeRecord() override;
177 
178 private:
179  // Struct that holds the minimal schema and the special keys we've added to it.
180  struct MinimalSchema {
187  afw::table::Key<float> peakValue;
188 
189  MinimalSchema();
190  };
191 
192  // Return the singleton minimal schema.
193  static MinimalSchema& getMinimalSchema();
194 
196 
197  // Return a writer object that knows how to save in FITS format. See also FitsWriter.
199  int flags) const override;
200 
201  std::shared_ptr<afw::table::IdFactory> _idFactory; // generates IDs for new records
202 };
203 
204 std::ostream& operator<<(std::ostream& os, PeakRecord const& record);
205 
208 
209 inline int PeakRecord::getIx() const { return get(PeakTable::getIxKey()); }
210 inline int PeakRecord::getIy() const { return get(PeakTable::getIyKey()); }
211 inline void PeakRecord::setIx(int ix) { set(PeakTable::getIxKey(), ix); }
212 inline void PeakRecord::setIy(int iy) { set(PeakTable::getIyKey(), iy); }
213 
214 inline float PeakRecord::getFx() const { return get(PeakTable::getFxKey()); }
215 inline float PeakRecord::getFy() const { return get(PeakTable::getFyKey()); }
216 inline void PeakRecord::setFx(float fx) { set(PeakTable::getFxKey(), fx); }
217 inline void PeakRecord::setFy(float fy) { set(PeakTable::getFyKey(), fy); }
218 
219 inline float PeakRecord::getPeakValue() const { return get(PeakTable::getPeakValueKey()); }
220 inline void PeakRecord::setPeakValue(float peakValue) { set(PeakTable::getPeakValueKey(), peakValue); }
221 
225 }
226 }
227 } // namespace lsst::afw::detection
228 
229 #endif // !AFW_DETECTION_Peak_h_INCLUDED
Defines the fields and offsets for a table.
Definition: Schema.h:46
static afw::table::Key< float > getFxKey()
Get keys for standard fields shared by all peaks.
Definition: Peak.h:147
int getIy() const
Convenience accessors for the keys in the minimal schema.
Definition: Peak.h:210
Writer object for FITS binary tables.
Definition: FitsWriter.h:25
std::ostream & operator<<(std::ostream &os, PeakRecord const &record)
Definition: Peak.cc:95
afw::geom::Point2D getF() const
Convenience accessors for the keys in the minimal schema.
Definition: Peak.h:69
std::shared_ptr< afw::table::IdFactory > getIdFactory()
Return the object that generates IDs for the table (may be null).
Definition: Peak.h:130
std::shared_ptr< PeakRecord > makeRecord()
Definition: Peak.h:156
static afw::table::Schema makeMinimalSchema()
Return a minimal schema for Peak tables and records.
Definition: Peak.h:117
afw::table::Schema schema
Definition: GaussianPsf.cc:43
std::shared_ptr< PeakTable > clone() const
Definition: Peak.h:153
A mapping between the keys of two Schemas, used to copy data between them.
Definition: SchemaMapper.h:21
afw::table::CatalogT< PeakRecord > Catalog
Definition: Peak.h:46
afw::table::CatalogT< Record const > ConstCatalog
Definition: Peak.h:91
Table class for Peaks in Footprints.
Definition: Peak.h:86
A simple struct that combines the two arguments that must be passed to most cfitsio routines and cont...
Definition: fits.h:279
static afw::table::Key< float > getPeakValueKey()
Get keys for standard fields shared by all peaks.
Definition: Peak.h:149
float getPeakValue() const
Convenience accessors for the keys in the minimal schema.
Definition: Peak.h:219
std::shared_ptr< PeakTable const > getTable() const
Definition: Peak.h:49
void setId(afw::table::RecordId id)
Convenience accessors for the keys in the minimal schema.
Definition: Peak.h:207
afw::table::RecordId getId() const
Convenience accessors for the keys in the minimal schema.
Definition: Peak.h:206
static afw::table::Key< float > getFyKey()
Get keys for standard fields shared by all peaks.
Definition: Peak.h:148
std::shared_ptr< BaseRecord > copyRecord(BaseRecord const &input)
Deep-copy a record, requiring that it have the same schema as this table.
void setIy(int iy)
Convenience accessors for the keys in the minimal schema.
Definition: Peak.h:212
afw::table::CatalogT< PeakRecord const > ConstCatalog
Definition: Peak.h:47
afw::geom::Point2D getCentroid() const
Convenience accessors for the keys in the minimal schema.
Definition: Peak.h:70
std::shared_ptr< PeakRecord > copyRecord(afw::table::BaseRecord const &other)
Definition: Peak.h:159
afw::table::CatalogT< PeakRecord const > ConstPeakCatalog
Definition: Peak.h:224
void setFy(float fy)
Convenience accessors for the keys in the minimal schema.
Definition: Peak.h:217
A base class for image defects.
afw::table::CatalogT< PeakRecord > PeakCatalog
Definition: Peak.h:223
afw::table::CatalogT< Record > Catalog
Definition: Peak.h:90
Point< double, 2 > Point2D
Definition: Point.h:273
int contains(Schema const &other, int flags=EQUAL_KEYS) const
Test whether the given schema is a subset of this.
afw::table::ColumnViewT< PeakRecord > PeakColumnView
Definition: Peak.h:222
std::shared_ptr< PeakRecord > copyRecord(afw::table::BaseRecord const &other, afw::table::SchemaMapper const &mapper)
Definition: Peak.h:164
static afw::table::Key< afw::table::RecordId > getIdKey()
Get keys for standard fields shared by all peaks.
Definition: Peak.h:144
T static_pointer_cast(T... args)
int getIx() const
Convenience accessors for the keys in the minimal schema.
Definition: Peak.h:209
std::shared_ptr< BaseTable const > getTable() const
Return the table this record is associated with.
Definition: BaseRecord.h:55
static bool checkSchema(afw::table::Schema const &other)
Return true if the given schema is a valid PeakTable schema.
Definition: Peak.h:125
afw::table::ColumnViewT< PeakRecord > ColumnView
Definition: Peak.h:89
Base class for all records.
Definition: BaseRecord.h:29
A class used as a handle to a particular field in a table.
Definition: fwd.h:45
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:136
static afw::table::Key< int > getIyKey()
Get keys for standard fields shared by all peaks.
Definition: Peak.h:146
void setPeakValue(float peakValue)
Convenience accessors for the keys in the minimal schema.
Definition: Peak.h:220
void setIx(int ix)
Convenience accessors for the keys in the minimal schema.
Definition: Peak.h:211
Point< int, 2 > Point2I
Definition: Point.h:270
void setFx(float fx)
Convenience accessors for the keys in the minimal schema.
Definition: Peak.h:216
PeakRecord(std::shared_ptr< PeakTable > const &table)
Definition: Peak.cc:93
Record class that represents a peak in a Footprint.
Definition: Peak.h:42
STL class.
afw::geom::Point2I getCentroid(bool) const
Convenience accessors for the keys in the minimal schema.
Definition: Peak.h:63
afw::geom::Point2I getI() const
Convenience accessors for the keys in the minimal schema.
Definition: Peak.h:62
afw::table::ColumnViewT< PeakRecord > ColumnView
Definition: Peak.h:45
float getFy() const
Convenience accessors for the keys in the minimal schema.
Definition: Peak.h:215
Base class for all tables.
Definition: BaseTable.h:44
std::shared_ptr< afw::table::IdFactory const > getIdFactory() const
Return the object that generates IDs for the table (may be null).
Definition: Peak.h:133
static afw::table::Key< int > getIxKey()
Get keys for standard fields shared by all peaks.
Definition: Peak.h:145
float getFx() const
Convenience accessors for the keys in the minimal schema.
Definition: Peak.h:214