Loading [MathJax]/extensions/tex2jax.js
LSST Applications g04a91732dc+2945638123,g07dc498a13+7e3c5f68a2,g12483e3c20+e0fa9c8503,g1409bbee79+7e3c5f68a2,g1a7e361dbc+7e3c5f68a2,g1fd858c14a+9f35e23ec3,g35bb328faa+fcb1d3bbc8,g3ad4f90e5c+e0fa9c8503,g3bd4b5ce2c+36fb6ead7f,g4e0f332c67+5d362be553,g53246c7159+fcb1d3bbc8,g5477a8d5ce+db04660fe6,g60b5630c4e+e0fa9c8503,g75b6c65c88+55830bd904,g78460c75b0+2f9a1b4bcd,g786e29fd12+cf7ec2a62a,g7b71ed6315+fcb1d3bbc8,g8852436030+4639f750a5,g89139ef638+7e3c5f68a2,g8f1d76f86f+11a01f47f4,g9125e01d80+fcb1d3bbc8,g919ac25b3e+28db628500,g95236ca021+f7a31438ed,g989de1cb63+7e3c5f68a2,g9f33ca652e+d1e6496fea,ga365f290ef+26a6f9aaf0,gaaedd4e678+7e3c5f68a2,gabe3b4be73+1e0a283bba,gb1101e3267+c09b629e83,gb4a253aaf5+0122250889,gb58c049af0+f03b321e39,gbaa7868d32+e0fa9c8503,gc99c83e5f0+76d20ab76d,gcf25f946ba+4639f750a5,gd6cbbdb0b4+c8606af20c,gde0f65d7ad+021d0de224,ge278dab8ac+932305ba37,gfba249425e+fcb1d3bbc8,w.2025.08
LSST Data Management Base Package
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
Exposure.h
Go to the documentation of this file.
1// -*- lsst-c++ -*-
2/*
3 * LSST Data Management System
4 * Copyright 2008, 2009, 2010, 2011 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_TABLE_Exposure_h_INCLUDED
24#define AFW_TABLE_Exposure_h_INCLUDED
25
26#include "lsst/geom/Box.h"
35
36namespace lsst {
37namespace afw {
38
39namespace image {
40class PhotoCalib;
41class ApCorrMap;
42class VisitInfo;
44} // namespace image
45
46namespace detection {
47class Psf;
48} // namespace detection
49
50namespace geom {
51class SkyWcs;
52namespace polygon {
53class Polygon;
54}
55} // namespace geom
56
57namespace cameraGeom {
58class Detector;
59} // namespace cameraGeom
60
61namespace table {
62
63class ExposureRecord;
64class ExposureTable;
65
66template <typename RecordT>
68
69namespace io {
70
72class InputArchive;
73
74} // namespace io
75
79class ExposureRecord : public BaseRecord {
80public:
85
96 BaseRecord(token, std::move(data))
97 {}
98
102
103 RecordId getId() const;
104 void setId(RecordId id);
105
107 void setBBox(lsst::geom::Box2I const& bbox);
108
119 bool contains(lsst::geom::SpherePoint const& coord, bool includeValidPolygon = false) const;
120
131 bool contains(lsst::geom::Point2D const& point, geom::SkyWcs const& wcs,
132 bool includeValidPolygon = false) const;
133
135
138
141
143 void setPhotoCalib(std::shared_ptr<image::PhotoCalib const> photoCalib) { _photoCalib = photoCalib; }
144
146 void setApCorrMap(std::shared_ptr<image::ApCorrMap const> apCorrMap) { _apCorrMap = apCorrMap; }
147
149 void setValidPolygon(std::shared_ptr<geom::polygon::Polygon const> polygon) { _validPolygon = polygon; }
150
152 void setVisitInfo(std::shared_ptr<image::VisitInfo const> visitInfo) { _visitInfo = visitInfo; }
153
155 return _transmissionCurve;
156 }
158 _transmissionCurve = std::move(transmissionCurve);
159 }
160
163 _detector = std::move(detector);
164 }
165
166
171 ~ExposureRecord() override;
172
173protected:
174
175 void _assign(BaseRecord const& other) override;
176
177private:
178 friend class ExposureTable;
179
188};
189
195class ExposureTable : public BaseTable {
196public:
201
207 static std::shared_ptr<ExposureTable> make(Schema const& schema);
208
217 Schema r = getMinimalSchema().schema;
218 r.disconnectAliases();
219 return r;
220 }
221
228 static bool checkSchema(Schema const& other) { return other.contains(getMinimalSchema().schema); }
229
231
237 static Key<RecordId> getIdKey() { return getMinimalSchema().id; }
239 static PointKey<int> getBBoxMinKey() { return getMinimalSchema().bbox.getMin(); }
241 static PointKey<int> getBBoxMaxKey() { return getMinimalSchema().bbox.getMax(); }
243 static Box2IKey getBBoxKey() { return getMinimalSchema().bbox; }
245
248
253
258
263
266 ~ExposureTable() override;
267
268protected:
269 explicit ExposureTable(Schema const& schema);
270
272
273 std::shared_ptr<BaseTable> _clone() const override;
274
276
277private:
278 // Struct that holds the minimal schema and the special keys we've added to it.
279 struct MinimalSchema {
280 Schema schema;
281 Key<RecordId> id;
282 Box2IKey bbox;
283
284 MinimalSchema();
285 };
286
287 // Return the singleton minimal schema.
288 static MinimalSchema& getMinimalSchema();
289
290 friend class io::FitsWriter;
291
292 template <typename RecordT>
293 friend class ExposureCatalogT;
294
295 // Return a writer object that knows how to save in FITS format. See also FitsWriter.
296 std::shared_ptr<io::FitsWriter> makeFitsWriter(fits::Fits* fitsfile, int flags) const override;
297
300 int flags) const;
301};
302
309template <typename RecordT>
310class ExposureCatalogT : public SortedCatalogT<RecordT> {
311 using Base = SortedCatalogT<RecordT>;
312
313public:
314 using Record = RecordT;
315 using Table = typename Record::Table;
316
317 using iterator = typename Base::iterator;
319
327
329 explicit ExposureCatalogT(Schema const& schema) : Base(schema) {}
330
341 template <typename InputIterator>
342 ExposureCatalogT(std::shared_ptr<Table> const& table, InputIterator first, InputIterator last,
343 bool deep = false)
344 : Base(table, first, last, deep) {}
345
352 template <typename OtherRecordT>
354
359 ~ExposureCatalogT() = default;
360
361 using Base::writeFits;
362
370 void writeFits(fits::Fits& fitsfile, std::shared_ptr<io::OutputArchive> archive, int flags = 0) const {
371 std::shared_ptr<io::FitsWriter> writer = this->getTable()->makeFitsWriter(&fitsfile, archive, flags);
372 writer->write(*this);
373 }
374
385 static ExposureCatalogT readFits(std::string const& filename, int hdu = fits::DEFAULT_HDU,
386 int flags = 0) {
387 return io::FitsReader::apply<ExposureCatalogT>(filename, hdu, flags);
388 }
389
401 int flags = 0) {
402 return io::FitsReader::apply<ExposureCatalogT>(manager, hdu, flags);
403 }
404
412 static ExposureCatalogT readFits(fits::Fits& fitsfile, int flags = 0) {
413 return io::FitsReader::apply<ExposureCatalogT>(fitsfile, flags);
414 }
415
423 int flags = 0) {
424 return io::FitsReader::apply<ExposureCatalogT>(fitsfile, flags, archive);
425 }
426
434 void writeToArchive(io::OutputArchiveHandle& handle, bool ignoreUnpersistable = true) const;
435
442 static ExposureCatalogT readFromArchive(io::InputArchive const& archive, BaseCatalog const& catalog);
443
449 ExposureCatalogT<RecordT> subset(ndarray::Array<bool const, 1> const& mask) const {
450 return ExposureCatalogT(Base::subset(mask));
451 }
452
458 return ExposureCatalogT(Base::subset(startd, stopd, step));
459 }
460
470 bool includeValidPolygon = false) const;
471
480 ExposureCatalogT subsetContaining(lsst::geom::Point2D const& point, geom::SkyWcs const& wcs,
481 bool includeValidPolygon = false) const;
482
483protected:
484 explicit ExposureCatalogT(Base const& other) : Base(other) {}
485};
486
490
493} // namespace table
494} // namespace afw
495} // namespace lsst
496
497#endif // !AFW_TABLE_Exposure_h_INCLUDED
A representation of a detector in a mosaic camera.
Definition Detector.h:185
A polymorphic base class for representing an image's Point Spread Function.
Definition Psf.h:82
A simple struct that combines the two arguments that must be passed to most cfitsio routines and cont...
Definition fits.h:308
Lifetime-management for memory that goes into FITS memory files.
Definition fits.h:125
A 2-dimensional celestial WCS that transform pixels to ICRS RA/Dec, using the LSST standard for pixel...
Definition SkyWcs.h:117
Cartesian polygons.
Definition Polygon.h:59
A thin wrapper around std::map to allow aperture corrections to be attached to Exposures.
Definition ApCorrMap.h:45
The photometric calibration of an exposure.
Definition PhotoCalib.h:114
A spatially-varying transmission curve as a function of wavelength.
Information about a single exposure of an imaging camera.
Definition VisitInfo.h:68
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.
void set(Key< T > const &key, U const &value)
Set value of a field for the given key.
Definition BaseRecord.h:164
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
BaseTable(Schema const &schema, std::shared_ptr< daf::base::PropertyList > metadata=nullptr)
Construct from a schema.
Definition BaseTable.cc:152
std::shared_ptr< Table > getTable() const
Return the table associated with the catalog.
Definition Catalog.h:114
void writeFits(std::string const &filename, std::string const &mode="w", int flags=0) const
Write a FITS binary table to a regular file.
Definition Catalog.h:310
Custom catalog class for ExposureRecord/Table.
Definition Exposure.h:310
ExposureCatalogT & operator=(ExposureCatalogT &&)=default
ExposureCatalogT(ExposureCatalogT &&)=default
static ExposureCatalogT readFits(std::string const &filename, int hdu=fits::DEFAULT_HDU, int flags=0)
Read a FITS binary table from a regular file.
Definition Exposure.h:385
static ExposureCatalogT readFits(fits::MemFileManager &manager, int hdu=fits::DEFAULT_HDU, int flags=0)
Read a FITS binary table from a RAM file.
Definition Exposure.h:400
ExposureCatalogT(Base const &other)
Definition Exposure.h:484
ExposureCatalogT(ExposureCatalogT const &)=default
ExposureCatalogT(std::shared_ptr< Table > const &table, InputIterator first, InputIterator last, bool deep=false)
Construct a vector from a table and an iterator range.
Definition Exposure.h:342
typename Base::const_iterator const_iterator
Definition Exposure.h:318
ExposureCatalogT subsetContaining(lsst::geom::Point2D const &point, geom::SkyWcs const &wcs, bool includeValidPolygon=false) const
Return a shallow subset of the catalog with only those records that contain the given point.
Definition Exposure.cc:485
static ExposureCatalogT readFromArchive(io::InputArchive const &archive, BaseCatalog const &catalog)
Convenience input function for Persistables that contain an ExposureCatalog.
Definition Exposure.cc:458
void writeToArchive(io::OutputArchiveHandle &handle, bool ignoreUnpersistable=true) const
Convenience output function for Persistables that contain an ExposureCatalog.
Definition Exposure.cc:446
static ExposureCatalogT readFits(fits::Fits &fitsfile, int flags=0)
Read a FITS binary table from a file object already at the correct extension.
Definition Exposure.h:412
ExposureCatalogT & operator=(ExposureCatalogT const &)=default
ExposureCatalogT(Schema const &schema)
Construct a vector from a schema, creating a table with Table::make(schema).
Definition Exposure.h:329
static ExposureCatalogT readFits(fits::Fits &fitsfile, std::shared_ptr< io::InputArchive > archive, int flags=0)
Read a FITS binary table from a file object already at the correct extension.
Definition Exposure.h:422
void writeFits(fits::Fits &fitsfile, std::shared_ptr< io::OutputArchive > archive, int flags=0) const
Write a FITS binary table to an open file object.
Definition Exposure.h:370
ExposureCatalogT subsetContaining(lsst::geom::SpherePoint const &coord, bool includeValidPolygon=false) const
Return a shallow subset of the catalog with only those records that contain the given point.
Definition Exposure.cc:473
ExposureCatalogT< RecordT > subset(ndarray::Array< bool const, 1 > const &mask) const
Return the subset of a catalog corresponding to the True values of the given mask array.
Definition Exposure.h:449
ExposureCatalogT subset(std::ptrdiff_t startd, std::ptrdiff_t stopd, std::ptrdiff_t step) const
Shallow copy a subset of another ExposureCatalog.
Definition Exposure.h:457
ExposureCatalogT(std::shared_ptr< Table > const &table=std::shared_ptr< Table >())
Construct a vector from a table (or nothing).
Definition Exposure.h:326
ExposureCatalogT(ExposureCatalogT< OtherRecordT > const &other)
Shallow copy constructor from a container containing a related record type.
Definition Exposure.h:353
Record class used to store exposure metadata.
Definition Exposure.h:79
bool contains(lsst::geom::SpherePoint const &coord, bool includeValidPolygon=false) const
Return true if the bounding box contains the given celestial coordinate point, taking into account th...
Definition Exposure.cc:349
ColumnViewT< ExposureRecord > ColumnView
Definition Exposure.h:82
std::shared_ptr< image::PhotoCalib const > getPhotoCalib() const
Definition Exposure.h:142
std::shared_ptr< detection::Psf const > getPsf() const
Definition Exposure.h:139
void setVisitInfo(std::shared_ptr< image::VisitInfo const > visitInfo)
Definition Exposure.h:152
std::shared_ptr< image::VisitInfo const > getVisitInfo() const
Definition Exposure.h:151
lsst::geom::Box2I getBBox() const
Definition Exposure.cc:343
std::shared_ptr< image::TransmissionCurve const > getTransmissionCurve() const
Definition Exposure.h:154
ExposureCatalogT< const ExposureRecord > ConstCatalog
Definition Exposure.h:84
std::shared_ptr< geom::polygon::Polygon const > getValidPolygon() const
Definition Exposure.h:148
void setTransmissionCurve(std::shared_ptr< image::TransmissionCurve const > transmissionCurve)
Definition Exposure.h:157
std::shared_ptr< geom::SkyWcs const > getWcs() const
Get/Set the the attached Wcs, Psf, PhotoCalib, or ApCorrMap. No copies are made.
Definition Exposure.h:136
ExposureRecord(ExposureRecord &&)=delete
void setValidPolygon(std::shared_ptr< geom::polygon::Polygon const > polygon)
Definition Exposure.h:149
ExposureRecord(ConstructionToken const &token, detail::RecordData &&data)
Constructor used by ExposureTable.
Definition Exposure.h:95
void setApCorrMap(std::shared_ptr< image::ApCorrMap const > apCorrMap)
Definition Exposure.h:146
void setWcs(std::shared_ptr< geom::SkyWcs const > wcs)
Definition Exposure.h:137
ExposureRecord(ExposureRecord const &)=delete
ExposureRecord & operator=(ExposureRecord &&)=delete
ExposureCatalogT< ExposureRecord > Catalog
Definition Exposure.h:83
void setBBox(lsst::geom::Box2I const &bbox)
Definition Exposure.cc:347
std::shared_ptr< ExposureTable const > getTable() const
Definition Exposure.h:99
void setPsf(std::shared_ptr< detection::Psf const > psf)
Definition Exposure.h:140
ExposureRecord & operator=(ExposureRecord const &)=delete
std::shared_ptr< cameraGeom::Detector const > getDetector() const
Definition Exposure.h:161
void _assign(BaseRecord const &other) override
Called by assign() after transferring fields to allow subclass data members to be copied.
Definition Exposure.cc:379
void setPhotoCalib(std::shared_ptr< image::PhotoCalib const > photoCalib)
Definition Exposure.h:143
std::shared_ptr< image::ApCorrMap const > getApCorrMap() const
Definition Exposure.h:145
void setDetector(std::shared_ptr< cameraGeom::Detector const > detector)
Definition Exposure.h:162
Table class used to store exposure metadata.
Definition Exposure.h:195
std::shared_ptr< ExposureRecord > makeRecord()
Default-construct an associated record.
Definition Exposure.h:250
ExposureCatalogT< const Record > ConstCatalog
Definition Exposure.h:200
static PointKey< int > getBBoxMinKey()
Key for the minimum point of the bbox.
Definition Exposure.h:239
std::shared_ptr< ExposureRecord > copyRecord(BaseRecord const &other)
Deep-copy a record, requiring that it have the same schema as this table.
Definition Exposure.h:255
std::shared_ptr< BaseRecord > _makeRecord() override
Default-construct an associated record (protected implementation).
Definition Exposure.cc:437
std::shared_ptr< ExposureTable > clone() const
Return a polymorphic deep copy of the table.
Definition Exposure.h:247
std::shared_ptr< io::FitsWriter > makeFitsWriter(fits::Fits *fitsfile, int flags) const override
Definition Exposure.cc:421
static Box2IKey getBBoxKey()
Key for the full bbox.
Definition Exposure.h:243
ColumnViewT< ExposureRecord > ColumnView
Definition Exposure.h:198
static Key< RecordId > getIdKey()
Get keys for standard fields shared by all references.
Definition Exposure.h:237
ExposureTable & operator=(ExposureTable &&)=delete
static bool checkSchema(Schema const &other)
Return true if the given schema is a valid ExposureTable schema.
Definition Exposure.h:228
ExposureCatalogT< Record > Catalog
Definition Exposure.h:199
static Schema makeMinimalSchema()
Return a minimal schema for Exposure tables and records.
Definition Exposure.h:216
ExposureTable(Schema const &schema)
Definition Exposure.cc:405
static PointKey< int > getBBoxMaxKey()
Key for the maximum point of the bbox.
Definition Exposure.h:241
std::shared_ptr< BaseTable > _clone() const override
Clone implementation with noncovariant return types.
Definition Exposure.cc:431
ExposureTable(ExposureTable const &other)
std::shared_ptr< ExposureRecord > copyRecord(BaseRecord const &other, SchemaMapper const &mapper)
Deep-copy a record, requiring that it have the same schema as this table.
Definition Exposure.h:260
static std::shared_ptr< ExposureTable > make(Schema const &schema)
Construct a new table.
Definition Exposure.cc:394
ExposureTable & operator=(ExposureTable const &)=delete
A class used as a handle to a particular field in a table.
Definition Key.h:53
A FunctorKey used to get or set a lsst::geom::Point from an (x,y) pair of int or double Keys.
Definition aggregates.h:51
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.
typename Base::const_iterator const_iterator
typename Base::iterator iterator
SortedCatalogT(SortedCatalogT const &)=default
SortedCatalogT< RecordT > subset(ndarray::Array< bool const, 1 > const &mask) const
Return the subset of a catalog corresponding to the True values of the given mask array.
static ContainerT apply(afw::fits::Fits &fits, int ioFlags, std::shared_ptr< InputArchive > archive=std::shared_ptr< InputArchive >())
Create a new Catalog by reading a FITS binary table.
Definition FitsReader.h:71
Writer object for FITS binary tables.
Definition FitsWriter.h:25
A multi-catalog archive object used to load table::io::Persistable objects.
An object passed to Persistable::write to allow it to persist itself.
An integer coordinate rectangle.
Definition Box.h:55
Point in an unspecified spherical coordinate system.
Definition SpherePoint.h:57
T move(T... args)
const int DEFAULT_HDU
Specify that the default HDU should be read.
ColumnViewT< ExposureRecord > ExposureColumnView
Definition Exposure.h:487
ExposureCatalogT< ExposureRecord > ExposureCatalog
Definition Exposure.h:488
ExposureCatalogT< const ExposureRecord > ConstExposureCatalog
Definition Exposure.h:489
CatalogT< BaseRecord > BaseCatalog
Definition fwd.h:72
BoxKey< lsst::geom::Box2I > Box2IKey
Definition aggregates.h:283
std::int64_t RecordId
Type used for unique IDs for records.
Definition misc.h:21
Point< double, 2 > Point2D
Definition Point.h:324
STL namespace.
T static_pointer_cast(T... args)
Helper struct that contains the information passed from BaseTable to BaseRecord at construction.
Definition BaseTable.h:32