LSST Applications g0b6bd0c080+a72a5dd7e6,g1182afd7b4+2a019aa3bb,g17e5ecfddb+2b8207f7de,g1d67935e3f+06cf436103,g38293774b4+ac198e9f13,g396055baef+6a2097e274,g3b44f30a73+6611e0205b,g480783c3b1+98f8679e14,g48ccf36440+89c08d0516,g4b93dc025c+98f8679e14,g5c4744a4d9+a302e8c7f0,g613e996a0d+e1c447f2e0,g6c8d09e9e7+25247a063c,g7271f0639c+98f8679e14,g7a9cd813b8+124095ede6,g9d27549199+a302e8c7f0,ga1cf026fa3+ac198e9f13,ga32aa97882+7403ac30ac,ga786bb30fb+7a139211af,gaa63f70f4e+9994eb9896,gabf319e997+ade567573c,gba47b54d5d+94dc90c3ea,gbec6a3398f+06cf436103,gc6308e37c7+07dd123edb,gc655b1545f+ade567573c,gcc9029db3c+ab229f5caf,gd01420fc67+06cf436103,gd877ba84e5+06cf436103,gdb4cecd868+6f279b5b48,ge2d134c3d5+cc4dbb2e3f,ge448b5faa6+86d1ceac1d,gecc7e12556+98f8679e14,gf3ee170dca+25247a063c,gf4ac96e456+ade567573c,gf9f5ea5b4d+ac198e9f13,gff490e6085+8c2580be5c,w.2022.27
LSST Data Management Base Package
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
31
32namespace lsst {
33namespace afw {
34namespace detection {
35
36class PeakRecord;
37class PeakTable;
38
43public:
48
59 BaseRecord(token, std::move(data))
60 {}
61
62 ~PeakRecord() override = default;
63 PeakRecord(PeakRecord const&) = delete;
65 PeakRecord& operator=(PeakRecord const&) = delete;
67
69 return std::static_pointer_cast<PeakTable const>(afw::table::BaseRecord::getTable());
70 }
71
73
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
95private:
96 friend class PeakTable;
97};
98
103public:
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
189protected:
191
192 PeakTable(PeakTable const& other);
193 PeakTable(PeakTable&& other);
194
196
198
199private:
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
230inline int PeakRecord::getIx() const { return get(PeakTable::getIxKey()); }
231inline int PeakRecord::getIy() const { return get(PeakTable::getIyKey()); }
232inline void PeakRecord::setIx(int ix) { set(PeakTable::getIxKey(), ix); }
233inline void PeakRecord::setIy(int iy) { set(PeakTable::getIyKey(), iy); }
234
235inline float PeakRecord::getFx() const { return get(PeakTable::getFxKey()); }
236inline float PeakRecord::getFy() const { return get(PeakTable::getFyKey()); }
237inline void PeakRecord::setFx(float fx) { set(PeakTable::getFxKey(), fx); }
238inline void PeakRecord::setFy(float fy) { set(PeakTable::getFyKey(), fy); }
239
240inline float PeakRecord::getPeakValue() const { return get(PeakTable::getPeakValueKey()); }
241inline 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
char * data
Definition: BaseRecord.cc:61
table::Key< int > id
Definition: Detector.cc:162
std::ostream * os
Definition: Schema.cc:557
SchemaMapper * mapper
Definition: SchemaMapper.cc:71
table::Schema schema
Definition: python.h:134
Record class that represents a peak in a Footprint.
Definition: Peak.h:42
lsst::geom::Point2I getI() const
Definition: Peak.h:81
lsst::geom::Point2I getCentroid(bool) const
Definition: Peak.h:82
PeakRecord(ConstructionToken const &token, table::detail::RecordData &&data)
Constructor used by PeakTable.
Definition: Peak.h:58
lsst::geom::Point2D getCentroid() const
Definition: Peak.h:89
std::shared_ptr< PeakTable const > getTable() const
Definition: Peak.h:68
PeakRecord & operator=(PeakRecord &&)=delete
lsst::geom::Point2D getF() const
Definition: Peak.h:88
PeakRecord(PeakRecord const &)=delete
void setPeakValue(float peakValue)
Definition: Peak.h:241
PeakRecord(PeakRecord &&)=delete
PeakRecord & operator=(PeakRecord const &)=delete
void setId(afw::table::RecordId id)
Definition: Peak.h:228
float getPeakValue() const
Definition: Peak.h:240
afw::table::RecordId getId() const
Convenience accessors for the keys in the minimal schema.
Definition: Peak.h:227
~PeakRecord() override=default
Table class for Peaks in Footprints.
Definition: Peak.h:102
std::shared_ptr< afw::table::BaseTable > _clone() const override
Clone implementation with noncovariant return types.
Definition: Peak.cc:160
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
PeakTable(afw::table::Schema const &schema, std::shared_ptr< afw::table::IdFactory > const &idFactory)
Definition: Peak.cc:130
static afw::table::Key< afw::table::RecordId > getIdKey()
Get keys for standard fields shared by all peaks.
Definition: Peak.h:164
static afw::table::Schema makeMinimalSchema()
Return a minimal schema for Peak tables and records.
Definition: Peak.h:137
PeakTable & operator=(PeakTable &&)=delete
static afw::table::Key< float > getPeakValueKey()
Definition: Peak.h:169
static afw::table::Key< float > getFyKey()
Definition: Peak.h:168
std::shared_ptr< afw::table::BaseRecord > _makeRecord() override
Default-construct an associated record (protected implementation).
Definition: Peak.cc:164
std::shared_ptr< PeakRecord > makeRecord()
Default-construct an associated record.
Definition: Peak.h:176
std::shared_ptr< PeakTable > clone() const
Return a polymorphic deep copy of the table.
Definition: Peak.h:173
PeakTable & operator=(PeakTable const &)=delete
std::shared_ptr< afw::table::IdFactory > getIdFactory()
Return the object that generates IDs for the table (may be null).
Definition: Peak.h:150
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
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:96
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
static afw::table::Key< int > getIxKey()
Definition: Peak.h:165
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
static afw::table::Key< float > getFxKey()
Definition: Peak.h:167
static afw::table::Key< int > getIyKey()
Definition: Peak.h:166
static bool checkSchema(afw::table::Schema const &other)
Return true if the given schema is a valid PeakTable schema.
Definition: Peak.h:145
A simple struct that combines the two arguments that must be passed to most cfitsio routines and cont...
Definition: fits.h:297
Base class for all records.
Definition: BaseRecord.h:31
Field< T >::Value get(Key< T > const &key) const
Return the value of a field for the given key.
Definition: BaseRecord.h:151
std::shared_ptr< BaseTable const > getTable() const
Return the table this record is associated with.
Definition: BaseRecord.h:83
BaseRecord(ConstructionToken const &, detail::RecordData &&data)
Construct a record with uninitialized data.
Definition: BaseRecord.cc:143
void set(Key< T > const &key, U const &value)
Set value of a field for the given key.
Definition: BaseRecord.h:164
Base class for all tables.
Definition: BaseTable.h:61
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:128
A class used as a handle to a particular field in a table.
Definition: Key.h:53
Defines the fields and offsets for a table.
Definition: Schema.h:51
int contains(Schema const &other, int flags=EQUAL_KEYS) const
Test whether the given schema is a subset of this.
Definition: Schema.cc:490
A mapping between the keys of two Schemas, used to copy data between them.
Definition: SchemaMapper.h:21
Writer object for FITS binary tables.
Definition: FitsWriter.h:25
std::ostream & operator<<(std::ostream &os, Footprint const &rhs)
Print a Footprint to the stream.
Definition: Footprint.cc:443
Point< double, 2 > Point2D
Definition: Point.h:324
Point< int, 2 > Point2I
Definition: Point.h:321
A base class for image defects.
STL namespace.
Helper struct that contains the information passed from BaseTable to BaseRecord at construction.
Definition: BaseTable.h:32