LSSTApplications  11.0-13-gbb96280,12.1+18,12.1+7,12.1-1-g14f38d3+72,12.1-1-g16c0db7+5,12.1-1-g5961e7a+84,12.1-1-ge22e12b+23,12.1-11-g06625e2+4,12.1-11-g0d7f63b+4,12.1-19-gd507bfc,12.1-2-g7dda0ab+38,12.1-2-gc0bc6ab+81,12.1-21-g6ffe579+2,12.1-21-gbdb6c2a+4,12.1-24-g941c398+5,12.1-3-g57f6835+7,12.1-3-gf0736f3,12.1-37-g3ddd237,12.1-4-gf46015e+5,12.1-5-g06c326c+20,12.1-5-g648ee80+3,12.1-5-gc2189d7+4,12.1-6-ga608fc0+1,12.1-7-g3349e2a+5,12.1-7-gfd75620+9,12.1-9-g577b946+5,12.1-9-gc4df26a+10
LSSTDataManagementBasePackage
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/afw/geom/Box.h"
33 
34 namespace lsst { namespace afw {
35 
36 namespace image {
37 class Wcs;
38 class Calib;
39 class ApCorrMap;
40 class VisitInfo;
41 } // namespace image
42 
43 namespace detection {
44 class Psf;
45 } // namespace detection
46 
47 namespace geom { namespace polygon {
48 class Polygon;
49 }}
50 
51 namespace table {
52 
53 class ExposureRecord;
54 class ExposureTable;
55 
56 template <typename RecordT> class ExposureCatalogT;
57 
58 namespace io {
59 
60 class OutputArchiveHandle;
61 class InputArchive;
62 
63 } // namespace io
64 
68 class ExposureRecord : public BaseRecord {
69 public:
70 
75 
77  return std::static_pointer_cast<ExposureTable const>(BaseRecord::getTable());
78  }
79 
80  RecordId getId() const;
81  void setId(RecordId id);
82 
83  geom::Box2I getBBox() const;
84  void setBBox(geom::Box2I const & bbox);
85 
94  bool contains(Coord const & coord, bool includeValidPolygon=false) const;
95 
104  bool contains(geom::Point2D const & point, image::Wcs const & wcs, bool includeValidPolygon=false) const;
105 
107  CONST_PTR(image::Wcs) getWcs() const { return _wcs; }
110 
111  CONST_PTR(detection::Psf) getPsf() const { return _psf; }
112  void setPsf(CONST_PTR(detection::Psf) psf) { _psf = psf; }
113 
114  CONST_PTR(image::Calib) getCalib() const { return _calib; }
115  void setCalib(CONST_PTR(image::Calib) calib) { _calib = calib; }
116 
118  void setApCorrMap(CONST_PTR(image::ApCorrMap) apCorrMap) { _apCorrMap = apCorrMap; }
119 
122 
124  void setVisitInfo(CONST_PTR(image::VisitInfo) visitInfo) { _visitInfo = visitInfo; }
126 
127 protected:
128 
130 
131  virtual void _assign(BaseRecord const & other);
132 
133 private:
135  CONST_PTR(detection::Psf) _psf;
138  CONST_PTR(geom::polygon::Polygon) _validPolygon;
140 };
141 
147 class ExposureTable : public BaseTable {
148 public:
149 
154 
160  static PTR(ExposureTable) make(Schema const & schema);
161 
169  static Schema makeMinimalSchema() {
170  Schema r = getMinimalSchema().schema;
171  r.disconnectAliases();
172  return r;
173  }
174 
181  static bool checkSchema(Schema const & other) {
182  return other.contains(getMinimalSchema().schema);
183  }
184 
186 
191  static Key<RecordId> getIdKey() { return getMinimalSchema().id; }
194  static PointKey<int> getBBoxMinKey() { return getMinimalSchema().bboxMin; }
196  static PointKey<int> getBBoxMaxKey() { return getMinimalSchema().bboxMax; }
198 
200  PTR(ExposureTable) clone() const { return std::static_pointer_cast<ExposureTable>(_clone()); }
201 
203  PTR(ExposureRecord) makeRecord() { return std::static_pointer_cast<ExposureRecord>(_makeRecord()); }
204 
206  PTR(ExposureRecord) copyRecord(BaseRecord const & other) {
207  return std::static_pointer_cast<ExposureRecord>(BaseTable::copyRecord(other));
208  }
209 
211  PTR(ExposureRecord) copyRecord(BaseRecord const & other, SchemaMapper const & mapper) {
212  return std::static_pointer_cast<ExposureRecord>(BaseTable::copyRecord(other, mapper));
213  }
214 
215 protected:
216 
217  ExposureTable(Schema const & schema);
218 
219  ExposureTable(ExposureTable const & other);
220 
221 private:
222 
223  // Struct that holds the minimal schema and the special keys we've added to it.
224  struct MinimalSchema {
229 
230  MinimalSchema();
231  };
232 
233  // Return the singleton minimal schema.
234  static MinimalSchema & getMinimalSchema();
235 
236  friend class io::FitsWriter;
237 
238  template <typename RecordT> friend class ExposureCatalogT;
239 
240  // Return a writer object that knows how to save in FITS format. See also FitsWriter.
241  virtual PTR(io::FitsWriter) makeFitsWriter(fits::Fits * fitsfile, int flags) const;
242  PTR(io::FitsWriter) makeFitsWriter(
243  fits::Fits * fitsfile, PTR(io::OutputArchive) archive, int flags
244  ) const;
245 };
246 
247 #ifndef SWIG
248 
255 template <typename RecordT>
256 class ExposureCatalogT : public SortedCatalogT<RecordT> {
258 public:
259 
260  typedef RecordT Record;
261  typedef typename Record::Table Table;
262 
263  typedef typename Base::iterator iterator;
265 
272  explicit ExposureCatalogT(PTR(Table) const & table = PTR(Table)()) : Base(table) {}
273 
275  explicit ExposureCatalogT(Schema const & schema) : Base(schema) {}
276 
287  template <typename InputIterator>
288  ExposureCatalogT(PTR(Table) const & table, InputIterator first, InputIterator last, bool deep=false) :
289  Base(table, first, last, deep)
290  {}
291 
298  template <typename OtherRecordT>
300 
301  using Base::writeFits;
302 
310  void writeFits(fits::Fits & fitsfile, PTR(io::OutputArchive) archive, int flags=0) const {
311  PTR(io::FitsWriter) writer = this->getTable()->makeFitsWriter(&fitsfile, archive, flags);
312  writer->write(*this);
313  }
314 
324  static ExposureCatalogT readFits(std::string const & filename, int hdu=0, int flags=0) {
325  return io::FitsReader::apply<ExposureCatalogT>(filename, hdu, flags);
326  }
327 
337  static ExposureCatalogT readFits(fits::MemFileManager & manager, int hdu=0, int flags=0) {
338  return io::FitsReader::apply<ExposureCatalogT>(manager, hdu, flags);
339  }
340 
348  static ExposureCatalogT readFits(fits::Fits & fitsfile, int flags=0) {
349  return io::FitsReader::apply<ExposureCatalogT>(fitsfile, flags);
350  }
351 
358  static ExposureCatalogT readFits(fits::Fits & fitsfile, PTR(io::InputArchive) archive, int flags=0) {
359  return io::FitsReader::apply<ExposureCatalogT>(fitsfile, flags, archive);
360  }
361 
369  void writeToArchive(io::OutputArchiveHandle & handle, bool ignoreUnpersistable=true) const;
370 
377  static ExposureCatalogT readFromArchive(io::InputArchive const & archive, BaseCatalog const & catalog);
378 
384  ExposureCatalogT<RecordT> subset(ndarray::Array<bool const,1> const & mask) const {
385  return ExposureCatalogT(Base::subset(mask));
386  }
387 
392  ExposureCatalogT subset(std::ptrdiff_t startd, std::ptrdiff_t stopd, std::ptrdiff_t step) const {
393  return ExposureCatalogT(Base::subset(startd, stopd, step));
394  }
395 
403  ExposureCatalogT subsetContaining(Coord const & coord, bool includeValidPolygon=false) const;
404 
412  ExposureCatalogT subsetContaining(geom::Point2D const & point, image::Wcs const & wcs,
413  bool includeValidPolygon=false) const;
414 
415 protected:
416  explicit ExposureCatalogT(Base const & other) : Base(other) {}
417 };
418 
422 
423 inline RecordId ExposureRecord::getId() const { return get(ExposureTable::getIdKey()); }
425 
426 #endif // !SWIG
427 
428 }}} // namespace lsst::afw::table
429 
430 #endif // !AFW_TABLE_Exposure_h_INCLUDED
Defines the fields and offsets for a table.
Definition: Schema.h:44
int contains(Schema const &other, int flags=EQUAL_KEYS) const
Test whether the given schema is a subset of this.
void disconnectAliases()
Sever the connection between this schema and any others with which it shares aliases.
bool contains(Coord const &coord, bool includeValidPolygon=false) const
Return true if the bounding box contains the given celestial coordinate point, taking into account th...
boost::shared_ptr< geom::polygon::Polygon const > getValidPolygon() const
Get/Set the the attached Wcs, Psf, Calib, or ApCorrMap. No copies are made.
Definition: Exposure.h:120
static ExposureCatalogT readFits(fits::Fits &fitsfile, boost::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:358
Writer object for FITS binary tables.
Definition: FitsWriter.h:22
static Key< RecordId > getIdKey()
Get keys for standard fields shared by all references.
Definition: Exposure.h:192
boost::shared_ptr< image::VisitInfo const > _visitInfo
Definition: Exposure.h:139
ExposureCatalogT< ExposureRecord const > ConstCatalog
Definition: Exposure.h:74
ExposureCatalogT< ExposureRecord const > ConstExposureCatalog
Definition: Exposure.h:421
void setPsf(boost::shared_ptr< detection::Psf const > psf)
Get/Set the the attached Wcs, Psf, Calib, or ApCorrMap. No copies are made.
Definition: Exposure.h:112
ExposureCatalogT< Record > Catalog
Definition: Exposure.h:152
An object passed to Persistable::write to allow it to persist itself.
ExposureCatalogT(boost::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:288
void writeFits(fits::Fits &fitsfile, boost::shared_ptr< io::OutputArchive > archive, int flags=0) const
Write a FITS binary table to an open file object.
Definition: Exposure.h:310
static PointKey< int > getBBoxMaxKey()
Key for the maximum point of the bbox.
Definition: Exposure.h:196
Table class used to store exposure metadata.
Definition: Exposure.h:147
A custom container class for records, based on std::vector.
Definition: Catalog.h:95
ColumnViewT< ExposureRecord > ExposureColumnView
Definition: Exposure.h:419
afw::table::Schema schema
Definition: GaussianPsf.cc:41
A thin wrapper around std::map to allow aperture corrections to be attached to Exposures.
Definition: ApCorrMap.h:42
ExposureCatalogT< Record const > ConstCatalog
Definition: Exposure.h:153
A mapping between the keys of two Schemas, used to copy data between them.
Definition: SchemaMapper.h:19
boost::shared_ptr< image::Wcs const > _wcs
Definition: Exposure.h:134
ExposureCatalogT(Schema const &schema)
Construct a vector from a schema, creating a table with Table::make(schema).
Definition: Exposure.h:275
Information about a single exposure of an imaging camera.
Definition: VisitInfo.h:63
tbl::Key< int > wcs
ColumnViewT< ExposureRecord > ColumnView
Definition: Exposure.h:72
boost::shared_ptr< image::VisitInfo const > getVisitInfo() const
Get/Set the the attached Wcs, Psf, Calib, or ApCorrMap. No copies are made.
Definition: Exposure.h:123
Implementation of the WCS standard for a any projection.
Definition: Wcs.h:107
void setCalib(boost::shared_ptr< image::Calib const > calib)
Get/Set the the attached Wcs, Psf, Calib, or ApCorrMap. No copies are made.
Definition: Exposure.h:115
A simple struct that combines the two arguments that must be passed to most cfitsio routines and cont...
Definition: fits.h:202
static PointKey< int > getBBoxMinKey()
Key for the minimum point of the bbox.
Definition: Exposure.h:194
void set(Key< T > const &key, U const &value)
Set value of a field for the given key.
Definition: BaseRecord.h:145
Describe an exposure&#39;s calibration.
Definition: Calib.h:82
An integer coordinate rectangle.
Definition: Box.h:53
boost::shared_ptr< detection::Psf const > getPsf() const
Get/Set the the attached Wcs, Psf, Calib, or ApCorrMap. No copies are made.
Definition: Exposure.h:111
table::Key< table::Array< Kernel::Pixel > > image
Definition: FixedKernel.cc:117
boost::shared_ptr< ExposureTable const > getTable() const
Definition: Exposure.h:76
boost::shared_ptr< detection::Psf const > _psf
Definition: Exposure.h:135
A multi-catalog archive object used to save table::io::Persistable objects.
Definition: OutputArchive.h:31
geom::Box2I getBBox() const
ColumnViewT< ExposureRecord > ColumnView
Definition: Exposure.h:151
std::int64_t RecordId
Type used for unique IDs for records.
Definition: misc.h:20
ExposureRecord(boost::shared_ptr< ExposureTable > const &table)
Custom catalog class for record/table subclasses that are guaranteed to have an ID, and should generally be sorted by that ID.
Definition: fwd.h:55
void setBBox(geom::Box2I const &bbox)
Lifetime-management for memory that goes into FITS memory files.
Definition: fits.h:106
std::map< Citizen const *, CitizenInfo > table
Definition: Citizen.h:90
static bool checkSchema(Schema const &other)
Return true if the given schema is a valid ExposureTable schema.
Definition: Exposure.h:181
Iterator class for CatalogT.
Definition: Catalog.h:35
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:384
boost::shared_ptr< geom::polygon::Polygon const > _validPolygon
Definition: Exposure.h:138
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:392
static ExposureCatalogT readFits(fits::MemFileManager &manager, int hdu=0, int flags=0)
Read a FITS binary table from a RAM file.
Definition: Exposure.h:337
boost::shared_ptr< image::ApCorrMap const > getApCorrMap() const
Get/Set the the attached Wcs, Psf, Calib, or ApCorrMap. No copies are made.
Definition: Exposure.h:117
ExposureCatalogT(ExposureCatalogT< OtherRecordT > const &other)
Shallow copy constructor from a container containing a related record type.
Definition: Exposure.h:299
static ExposureCatalogT readFits(std::string const &filename, int hdu=0, int flags=0)
Read a FITS binary table from a regular file.
Definition: Exposure.h:324
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:348
boost::shared_ptr< BaseTable const > getTable() const
Return the table this record is associated with.
Definition: BaseRecord.h:60
Base class for all records.
Definition: BaseRecord.h:27
SortedCatalogT< RecordT > Base
Definition: Exposure.h:257
boost::shared_ptr< image::Calib const > _calib
Definition: Exposure.h:136
ExposureCatalogT(boost::shared_ptr< Table > const &table=boost::shared_ptr< Table >())
Construct a vector from a table (or nothing).
Definition: Exposure.h:272
#define PTR(...)
Definition: base.h:41
ExposureCatalogT< ExposureRecord > Catalog
Definition: Exposure.h:73
void setWcs(boost::shared_ptr< image::Wcs const > wcs)
Get/Set the the attached Wcs, Psf, Calib, or ApCorrMap. No copies are made.
Definition: Exposure.h:109
RecordId getId() const
Definition: Exposure.h:423
ExposureCatalogT(Base const &other)
Definition: Exposure.h:416
Custom catalog class for ExposureRecord/Table.
Definition: Exposure.h:56
void setApCorrMap(boost::shared_ptr< image::ApCorrMap const > apCorrMap)
Get/Set the the attached Wcs, Psf, Calib, or ApCorrMap. No copies are made.
Definition: Exposure.h:118
boost::shared_ptr< BaseRecord > copyRecord(BaseRecord const &input)
Deep-copy a record, requiring that it have the same schema as this table.
boost::shared_ptr< image::Calib const > getCalib() const
Get/Set the the attached Wcs, Psf, Calib, or ApCorrMap. No copies are made.
Definition: Exposure.h:114
void setValidPolygon(boost::shared_ptr< geom::polygon::Polygon const > polygon)
Get/Set the the attached Wcs, Psf, Calib, or ApCorrMap. No copies are made.
Definition: Exposure.h:121
Record class used to store exposure metadata.
Definition: Exposure.h:68
Record::Table Table
Definition: Catalog.h:100
virtual void _assign(BaseRecord const &other)
Called by assign() after transferring fields to allow subclass data members to be copied...
Cartesian polygons.
Definition: Polygon.h:55
void setVisitInfo(boost::shared_ptr< image::VisitInfo const > visitInfo)
Get/Set the the attached Wcs, Psf, Calib, or ApCorrMap. No copies are made.
Definition: Exposure.h:124
boost::shared_ptr< image::Wcs const > getWcs() const
Get/Set the the attached Wcs, Psf, Calib, or ApCorrMap. No copies are made.
Definition: Exposure.h:108
ExposureCatalogT< ExposureRecord > ExposureCatalog
Definition: Exposure.h:420
A multi-catalog archive object used to load table::io::Persistable objects.
Definition: InputArchive.h:28
#define CONST_PTR(...)
A shared pointer to a const object.
Definition: base.h:47
Base::const_iterator const_iterator
Definition: Exposure.h:264
A polymorphic base class for representing an image&#39;s Point Spread Function.
Definition: Psf.h:68
void setId(RecordId id)
Definition: Exposure.h:424
This is the base class for spherical coordinates.
Definition: Coord.h:69
boost::shared_ptr< image::ApCorrMap const > _apCorrMap
Definition: Exposure.h:137
Base class for all tables.
Definition: BaseTable.h:43