LSSTApplications  18.1.0
LSSTDataManagementBasePackage
Exposure.cc
Go to the documentation of this file.
1 // -*- lsst-c++ -*-
2 #include <memory>
3 #include <typeinfo>
4 #include <string>
5 
8 #include "lsst/pex/exceptions.h"
14 #include "lsst/afw/geom/SkyWcs.h"
17 #include "lsst/afw/detection/Psf.h"
22 
23 namespace lsst {
24 namespace afw {
25 namespace table {
26 
27 //-----------------------------------------------------------------------------------------------------------
28 //----- Private ExposureTable/Record classes ---------------------------------------------------------------
29 //-----------------------------------------------------------------------------------------------------------
30 
31 // These private derived classes are what you actually get when you do ExposureTable::make; like the
32 // private classes in BaseTable.cc, it's more convenient to have an extra set of trivial derived
33 // classes than to do a lot of friending.
34 
35 namespace {
36 
37 int const EXPOSURE_TABLE_CURRENT_VERSION = 5; // current version of ExposureTable
38 std::string const EXPOSURE_TABLE_VERSION_KEY = "EXPTABLE_VER"; // FITS header key for ExposureTable version
39 
40 // Field names used to store the archive IDs of different components (used in
41 // multiple places, so we define them here instead of as multiple string
42 // literals).
43 std::string const WCS_FIELD_NAME = "wcs";
44 std::string const PSF_FIELD_NAME = "psf";
45 std::string const CALIB_FIELD_NAME = "calib"; // to support the deprecated Calib in old files
46 std::string const PHOTOCALIB_FIELD_NAME = "photoCalib";
47 std::string const VISIT_INFO_FIELD_NAME = "visitInfo";
48 std::string const AP_CORR_MAP_FIELD_NAME = "apCorrMap";
49 std::string const VALID_POLYGON_FIELD_NAME = "validPolygon";
50 std::string const TRANSMISSION_CURVE_FIELD_NAME = "transmissionCurve";
51 std::string const DETECTOR_FIELD_NAME = "detector";
52 
53 int getTableVersion(daf::base::PropertySet &metadata) {
54  return metadata.exists(EXPOSURE_TABLE_VERSION_KEY) ? metadata.get<int>(EXPOSURE_TABLE_VERSION_KEY) : 1;
55 }
56 
62 struct PersistenceHelper {
63  Schema schema;
64  Key<int> wcs;
65  Key<int> psf;
66  Key<int> calib; // to support the deprecated Calib in old files (replaced with photoCalib)
67  Key<int> photoCalib;
68  Key<int> apCorrMap;
69  Key<int> validPolygon;
70  Key<int> visitInfo;
72  Key<int> detector;
73 
74  // Create a SchemaMapper that maps an ExposureRecord to a BaseRecord with IDs for Wcs, Psf, etc.
75  SchemaMapper makeWriteMapper(Schema const &inputSchema) const {
76  std::vector<Schema> inSchemas;
77  inSchemas.push_back(PersistenceHelper().schema);
78  inSchemas.push_back(inputSchema);
79  // don't need front; it's an identity mapper
80  SchemaMapper result = SchemaMapper::join(inSchemas).back();
81  result.editOutputSchema().setAliasMap(inputSchema.getAliasMap());
82  return result;
83  }
84 
85  // Create a SchemaMapper that maps a BaseRecord to an ExposureRecord with IDs for WCS, Psf, etc.
86  SchemaMapper makeReadMapper(Schema const &inputSchema) const {
87  SchemaMapper result = SchemaMapper::removeMinimalSchema(inputSchema, schema);
88  result.editOutputSchema().setAliasMap(inputSchema.getAliasMap());
89  return result;
90  }
91 
92  // Write psf, wcs, etc. from an ExposureRecord to an archive
93  template <typename OutputArchiveIsh>
94  void writeRecord(ExposureRecord const &input, BaseRecord &output, SchemaMapper const &mapper,
95  OutputArchiveIsh &archive, bool permissive) const {
96  output.assign(input, mapper);
97  output.set(psf, archive.put(input.getPsf(), permissive));
98  output.set(wcs, archive.put(input.getWcs(), permissive));
99  output.set(photoCalib, archive.put(input.getPhotoCalib(), permissive));
100  output.set(apCorrMap, archive.put(input.getApCorrMap(), permissive));
101  output.set(validPolygon, archive.put(input.getValidPolygon(), permissive));
102  output.set(visitInfo, archive.put(input.getVisitInfo(), permissive));
103  output.set(transmissionCurve, archive.put(input.getTransmissionCurve(), permissive));
104  output.set(detector, archive.put(input.getDetector(), permissive));
105  }
106 
107  // Read psf, wcs, etc. from an archive to an ExposureRecord
108  void readRecord(BaseRecord const &input, ExposureRecord &output, SchemaMapper const &mapper,
109  io::InputArchive const &archive) const {
110  output.assign(input, mapper);
111  if (psf.isValid()) {
112  output.setPsf(archive.get<detection::Psf>(input.get(psf)));
113  }
114  if (wcs.isValid()) {
115  output.setWcs(archive.get<geom::SkyWcs>(input.get(wcs)));
116  }
117  if (calib.isValid()) {
118  output.setPhotoCalib(archive.get<image::PhotoCalib>(input.get(calib)));
119  }
120  if (photoCalib.isValid()) {
121  output.setPhotoCalib(archive.get<image::PhotoCalib>(input.get(photoCalib)));
122  }
123  if (apCorrMap.isValid()) {
124  output.setApCorrMap(archive.get<image::ApCorrMap>(input.get(apCorrMap)));
125  }
126  if (validPolygon.isValid()) {
127  output.setValidPolygon(archive.get<geom::polygon::Polygon>(input.get(validPolygon)));
128  }
129  if (visitInfo.isValid()) {
130  output.setVisitInfo(archive.get<image::VisitInfo>(input.get(visitInfo)));
131  }
132  if (transmissionCurve.isValid()) {
133  output.setTransmissionCurve(archive.get<image::TransmissionCurve>(input.get(transmissionCurve)));
134  }
135  if (detector.isValid()) {
136  output.setDetector(archive.get<cameraGeom::Detector>(input.get(detector)));
137  }
138  }
139 
140  // No copying
141  PersistenceHelper(const PersistenceHelper &) = delete;
142  PersistenceHelper &operator=(const PersistenceHelper &) = delete;
143 
144  // No moving
145  PersistenceHelper(PersistenceHelper &&) = delete;
146  PersistenceHelper &operator=(PersistenceHelper &&) = delete;
147 
148  // Construct a PersistenceHelper using the most modern schema.
149  PersistenceHelper()
150  : schema(),
151  wcs(schema.addField<int>(WCS_FIELD_NAME, "archive ID for Wcs object")),
152  psf(schema.addField<int>(PSF_FIELD_NAME, "archive ID for Psf object")),
153  photoCalib(schema.addField<int>(PHOTOCALIB_FIELD_NAME, "archive ID for PhotoCalib object")),
154  apCorrMap(schema.addField<int>(AP_CORR_MAP_FIELD_NAME, "archive ID for ApCorrMap object")),
155  validPolygon(schema.addField<int>(VALID_POLYGON_FIELD_NAME, "archive ID for Polygon object")),
156  visitInfo(schema.addField<int>(VISIT_INFO_FIELD_NAME, "archive ID for VisitInfo object")),
157  transmissionCurve(schema.addField<int>(TRANSMISSION_CURVE_FIELD_NAME,
158  "archive ID for TransmissionCurve object")),
159  detector(schema.addField<int>(DETECTOR_FIELD_NAME, "archive ID for Detector object")) {}
160 
161  // Add a field to this->schema, saving its key in 'key', if and only if 'name' is a field in 'oldSchema'
162  void addIfPresent(Schema const &oldSchema, Key<int> &key, std::string const &name) {
163  try {
164  auto item = oldSchema.find<int>(name);
165  key = schema.addField(item.field);
166  } catch (pex::exceptions::NotFoundError &) {
167  }
168  }
169 
170  // Construct a PersistenceHelper from a possibly old on-disk schema
171  PersistenceHelper(Schema const &oldSchema) {
172  addIfPresent(oldSchema, wcs, WCS_FIELD_NAME);
173  addIfPresent(oldSchema, psf, PSF_FIELD_NAME);
174  addIfPresent(oldSchema, calib, CALIB_FIELD_NAME);
175  addIfPresent(oldSchema, photoCalib, PHOTOCALIB_FIELD_NAME);
176  addIfPresent(oldSchema, apCorrMap, AP_CORR_MAP_FIELD_NAME);
177  addIfPresent(oldSchema, validPolygon, VALID_POLYGON_FIELD_NAME);
178  addIfPresent(oldSchema, visitInfo, VISIT_INFO_FIELD_NAME);
179  addIfPresent(oldSchema, transmissionCurve, TRANSMISSION_CURVE_FIELD_NAME);
180  addIfPresent(oldSchema, detector, DETECTOR_FIELD_NAME);
181  assert(oldSchema.contains(schema));
182  }
183 };
184 
185 } // namespace
186 
187 //-----------------------------------------------------------------------------------------------------------
188 //----- ExposureFitsWriter ---------------------------------------------------------------------------------
189 //-----------------------------------------------------------------------------------------------------------
190 
191 // A custom FitsWriter for Exposure - this sets the AFW_TYPE key to EXPOSURE, which should ensure
192 // we use ExposureFitsReader to read it, and sets EXPOSURE_TABLE_VERSION_KEY to the current version:
193 // EXPOSURE_TABLE_CURRENT_VERSION
194 
195 namespace {
196 
197 class ExposureFitsWriter : public io::FitsWriter {
198 public:
199  ExposureFitsWriter(Fits *fits, std::shared_ptr<io::OutputArchive> archive, int flags)
200  : io::FitsWriter(fits, flags), _doWriteArchive(false), _archive(archive), _helper() {
201  if (!_archive) {
202  _doWriteArchive = true;
203  _archive.reset(new io::OutputArchive());
204  }
205  }
206 
207 protected:
208  void _writeTable(std::shared_ptr<BaseTable const> const &table, std::size_t nRows) override;
209 
210  void _writeRecord(BaseRecord const &r) override;
211 
212  void _finish() override {
213  if (_doWriteArchive) _archive->writeFits(*_fits);
214  }
215 
219  PersistenceHelper _helper;
220  SchemaMapper _mapper;
221 };
222 
223 void ExposureFitsWriter::_writeTable(std::shared_ptr<BaseTable const> const &t, std::size_t nRows) {
224  std::shared_ptr<ExposureTable const> inTable = std::dynamic_pointer_cast<ExposureTable const>(t);
225  if (!inTable) {
227  "Cannot use a ExposureFitsWriter on a non-Exposure table.");
228  }
229  _mapper = _helper.makeWriteMapper(inTable->getSchema());
230  std::shared_ptr<BaseTable> outTable = BaseTable::make(_mapper.getOutputSchema());
231  io::FitsWriter::_writeTable(outTable, nRows);
232  _fits->writeKey("AFW_TYPE", "EXPOSURE", "Tells lsst::afw to load this as an Exposure table.");
233  _fits->writeKey(EXPOSURE_TABLE_VERSION_KEY, EXPOSURE_TABLE_CURRENT_VERSION, "Exposure table version");
234  _record = outTable->makeRecord();
235 }
236 
237 void ExposureFitsWriter::_writeRecord(BaseRecord const &r) {
238  ExposureRecord const &record = static_cast<ExposureRecord const &>(r);
239  _helper.writeRecord(record, *_record, _mapper, *_archive, false);
241 }
242 
243 } // namespace
244 
245 //-----------------------------------------------------------------------------------------------------------
246 //----- ExposureFitsReader ---------------------------------------------------------------------------------
247 //-----------------------------------------------------------------------------------------------------------
248 
249 // FitsColumnReader that reads a Persistable subclass T (Wcs, Psf, or PhotoCalib here) by using an int
250 // column to retrieve the object from an InputArchive and attach it to an ExposureRecord via
251 // the Setter member function pointer.
252 template <typename T, void (ExposureRecord::*Setter)(std::shared_ptr<T const>)>
254 public:
256  auto item = mapper.find(name);
257  if (item) {
258  if (mapper.hasArchive()) {
260  mapper.customize(std::move(reader));
261  }
262  mapper.erase(item);
263  }
264  }
265 
266  PersistableObjectColumnReader(int column) : _column(column) {}
267 
269  std::shared_ptr<io::InputArchive> const &archive) const override {
270  int id = 0;
271  fits.readTableScalar<int>(row, _column, id);
272  std::shared_ptr<T> value = archive->get<T>(id);
273  (static_cast<ExposureRecord &>(record).*(Setter))(value);
274  }
275 
276 private:
277  bool _noHeavy;
278  int _column;
279 };
280 
281 namespace {
282 
283 class ExposureFitsReader : public io::FitsReader {
284 public:
285  ExposureFitsReader() : afw::table::io::FitsReader("EXPOSURE") {}
286 
288  std::shared_ptr<daf::base::PropertyList> metadata, int ioFlags,
289  bool stripMetadata) const override {
290  // We rely on the table version stored in the metadata when loading an ExposureCatalog
291  // persisted on its own. This is not as flexible in terms of backwards compatibility
292  // as the code that loads ExposureCatalogs persisted as part of something else, but
293  // we happen to know there are no ExposureCatalogs sitting on disk with with versions
294  // older than what this routine supports.
295  auto tableVersion = getTableVersion(*metadata);
299  mapper);
301  "validPolygon", mapper);
302  if (tableVersion > 1) {
304  mapper);
305  }
306  if (tableVersion > 2) {
308  &ExposureRecord::setTransmissionCurve>::setup("transmissionCurve",
309  mapper);
310  }
311  if (tableVersion > 3) {
313  "detector", mapper);
314  }
315  // Load the PhotoCalib from the `calib` table prior to version 5.
316  if (tableVersion <= 4) {
318  mapper);
319  } else {
321  "photoCalib", mapper);
322  }
323 
324  auto schema = mapper.finalize();
326  table->setMetadata(metadata);
327  return table;
328  }
329 
330  bool usesArchive(int ioFlags) const override { return true; }
331 };
332 
333 static ExposureFitsReader const exposureFitsReader;
334 
335 } // namespace
336 
337 //-----------------------------------------------------------------------------------------------------------
338 //----- ExposureTable/Record member function implementations -----------------------------------------------
339 //-----------------------------------------------------------------------------------------------------------
340 
343 }
344 
346 
347 bool ExposureRecord::contains(lsst::geom::SpherePoint const &coord, bool includeValidPolygon) const {
348  if (!getWcs()) {
350  "ExposureRecord does not have a Wcs; cannot call contains()");
351  }
352 
353  // If there is no valid polygon set to false
354  if (includeValidPolygon && !getValidPolygon()) {
355  includeValidPolygon = false;
356  }
357 
358  try {
359  lsst::geom::Point2D point = getWcs()->skyToPixel(coord);
360  if (includeValidPolygon)
361  return (lsst::geom::Box2D(getBBox()).contains(point) && getValidPolygon()->contains(point));
362  else
363  return lsst::geom::Box2D(getBBox()).contains(point);
364  } catch (pex::exceptions::DomainError &) {
365  // SkyWcs can throw if the given coordinate is outside the region where the WCS is valid.
366  return false;
367  }
368 }
369 
371  bool includeValidPolygon) const {
372  return contains(wcs.pixelToSky(point), includeValidPolygon);
373 }
374 
376 
378  try {
379  ExposureRecord const &s = dynamic_cast<ExposureRecord const &>(other);
380  _psf = s._psf;
381  _wcs = s._wcs;
382  _photoCalib = s._photoCalib;
383  _apCorrMap = s._apCorrMap;
384  _validPolygon = s._validPolygon;
385  _visitInfo = s._visitInfo;
386  _transmissionCurve = s._transmissionCurve;
387  _detector = s._detector;
388  } catch (std::bad_cast &) {
389  }
390 }
391 
393  if (!checkSchema(schema)) {
394  throw LSST_EXCEPT(
396  "Schema for Exposure must contain at least the keys defined by makeMinimalSchema().");
397  }
398  return std::shared_ptr<ExposureTable>(new ExposureTable(schema));
399 }
400 
402 
404 // Delegate to copy-constructor for backward compatibility
406 
408 
409 ExposureTable::MinimalSchema::MinimalSchema() {
410  id = schema.addField<RecordId>("id", "unique ID");
411  bbox = Box2IKey::addFields(schema, "bbox", "bounding box", "pixel");
412  schema.getCitizen().markPersistent();
413 }
414 
415 ExposureTable::MinimalSchema &ExposureTable::getMinimalSchema() {
416  static MinimalSchema it;
417  return it;
418 }
419 
420 std::shared_ptr<io::FitsWriter> ExposureTable::makeFitsWriter(fits::Fits *fitsfile, int flags) const {
421  return std::make_shared<ExposureFitsWriter>(fitsfile, std::shared_ptr<io::OutputArchive>(), flags);
422 }
423 
424 std::shared_ptr<io::FitsWriter> ExposureTable::makeFitsWriter(fits::Fits *fitsfile,
426  int flags) const {
427  return std::make_shared<ExposureFitsWriter>(fitsfile, archive, flags);
428 }
429 
432 }
433 
435  return constructRecord<ExposureRecord>();
436 }
437 
438 //-----------------------------------------------------------------------------------------------------------
439 //----- ExposureCatalogT member function implementations ----------------------------------------------------
440 //-----------------------------------------------------------------------------------------------------------
441 
442 template <typename RecordT>
444  PersistenceHelper helper{};
445  SchemaMapper mapper = helper.makeWriteMapper(this->getSchema());
446  BaseCatalog outputCat = handle.makeCatalog(mapper.getOutputSchema());
447  outputCat.reserve(this->size());
448  for (const_iterator i = this->begin(); i != this->end(); ++i) {
449  helper.writeRecord(*i, *outputCat.addNew(), mapper, handle, permissive);
450  }
451  handle.saveCatalog(outputCat);
452 }
453 
454 template <typename RecordT>
456  BaseCatalog const &catalog) {
457  // Helper constructor will infer which components are available
458  // (effectively the version, but more flexible).
459  PersistenceHelper helper{catalog.getSchema()};
460  SchemaMapper mapper = helper.makeReadMapper(catalog.getSchema());
462  result.reserve(catalog.size());
463  for (BaseCatalog::const_iterator i = catalog.begin(); i != catalog.end(); ++i) {
464  helper.readRecord(*i, *result.addNew(), mapper, archive);
465  }
466  return result;
467 }
468 
469 template <typename RecordT>
471  bool includeValidPolygon) const {
472  ExposureCatalogT result(this->getTable());
473  for (const_iterator i = this->begin(); i != this->end(); ++i) {
474  if (i->contains(coord, includeValidPolygon)) {
475  result.push_back(i);
476  }
477  }
478  return result;
479 }
480 
481 template <typename RecordT>
483  geom::SkyWcs const &wcs,
484  bool includeValidPolygon) const {
485  ExposureCatalogT result(this->getTable());
486  for (const_iterator i = this->begin(); i != this->end(); ++i) {
487  if (i->contains(point, wcs, includeValidPolygon)) {
488  result.push_back(i);
489  }
490  }
491  return result;
492 }
493 
494 //-----------------------------------------------------------------------------------------------------------
495 //----- Explicit instantiation ------------------------------------------------------------------------------
496 //-----------------------------------------------------------------------------------------------------------
497 
498 template class CatalogT<ExposureRecord>;
499 template class CatalogT<ExposureRecord const>;
500 
501 template class SortedCatalogT<ExposureRecord>;
503 
504 template class ExposureCatalogT<ExposureRecord>;
506 } // namespace table
507 } // namespace afw
508 } // namespace lsst
Defines the fields and offsets for a table.
Definition: Schema.h:50
bool _doWriteArchive
Definition: Exposure.cc:216
A 2-dimensional celestial WCS that transform pixels to ICRS RA/Dec, using the LSST standard for pixel...
Definition: SkyWcs.h:117
A spatially-varying transmission curve as a function of wavelength.
Key< int > visitInfo
Definition: Exposure.cc:70
bool contains(VertexIterator const begin, VertexIterator const end, UnitVector3d const &v)
A utility class for reading FITS binary tables.
Definition: FitsReader.h:34
Schema schema
Definition: Exposure.cc:63
A floating-point coordinate rectangle geometry.
Definition: Box.h:305
An object passed to Persistable::write to allow it to persist itself.
The photometric calibration of an exposure.
Definition: PhotoCalib.h:116
Table class used to store exposure metadata.
Definition: Exposure.h:205
std::shared_ptr< BaseTable > _clone() const override
Clone implementation with noncovariant return types.
Definition: Exposure.cc:430
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:470
A thin wrapper around std::map to allow aperture corrections to be attached to Exposures.
Definition: ApCorrMap.h:45
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:347
lsst::geom::SpherePoint pixelToSky(lsst::geom::Point2D const &pixel) const
Compute sky position(s) from pixel position(s)
Definition: SkyWcs.h:334
A mapping between the keys of two Schemas, used to copy data between them.
Definition: SchemaMapper.h:21
Schema getSchema() const
Return the table&#39;s schema.
Definition: BaseTable.h:137
static void setup(std::string const &name, io::FitsSchemaInputMapper &mapper)
Definition: Exposure.cc:255
Information about a single exposure of an imaging camera.
Definition: VisitInfo.h:68
static Box2IKey getBBoxKey()
Key for the full bbox.
Definition: Exposure.h:253
Schema const getOutputSchema() const
Return the output schema (copy-on-write).
Definition: SchemaMapper.h:27
py::object result
Definition: schema.cc:418
void readTableScalar(std::size_t row, int col, T &value)
Read an array scalar from a binary table.
Definition: fits.h:595
ExposureTable(Schema const &schema)
Definition: Exposure.cc:401
std::shared_ptr< BaseRecord > _record
Definition: Exposure.cc:218
Reports arguments outside the domain of an operation.
Definition: Runtime.h:57
Key< int > photoCalib
Definition: Exposure.cc:67
A class that describes a mapping from a FITS binary table to an afw::table Schema.
table::Key< int > id
Definition: Detector.cc:166
Schema getSchema() const
Return the schema associated with the catalog&#39;s table.
Definition: Catalog.h:117
STL class.
A simple struct that combines the two arguments that must be passed to most cfitsio routines and cont...
Definition: fits.h:297
std::shared_ptr< BaseRecord > _makeRecord() override
Default-construct an associated record (protected implementation).
Definition: Exposure.cc:434
void setBBox(lsst::geom::Box2I const &bbox)
Definition: Exposure.cc:345
Key< int > validPolygon
Definition: Exposure.cc:69
Fits * fits
Definition: FitsWriter.cc:90
STL class.
T push_back(T... args)
static SchemaMapper removeMinimalSchema(Schema const &input, Schema const &minimal)
Create a mapper by removing fields from the front of a schema.
void push_back(Record const &r)
Add a copy of the given record to the end of the catalog.
Definition: Catalog.h:476
PersistenceHelper _helper
Definition: Exposure.cc:219
static std::vector< SchemaMapper > join(std::vector< Schema > const &inputs, std::vector< std::string > const &prefixes=std::vector< std::string >())
Combine a sequence of schemas into one, creating a SchemaMapper for each.
A base class for image defects.
Key< int > wcs
Definition: Exposure.cc:64
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:63
iterator end()
Iterator access.
Definition: Catalog.h:397
bool contains(Point2D const &point) const noexcept
Return true if the box contains the point.
Definition: Box.cc:292
Iterator class for CatalogT.
Definition: Catalog.h:38
Key< int > transmissionCurve
Definition: Exposure.cc:71
SchemaMapper _mapper
Definition: Exposure.cc:220
T dynamic_pointer_cast(T... args)
Reports errors in the logical structure of the program.
Definition: Runtime.h:46
table::Box2IKey bbox
Definition: Detector.cc:169
solver_t * s
T move(T... args)
virtual void _writeTable(std::shared_ptr< BaseTable const > const &table, std::size_t nRows)
Write a table and its schema.
Definition: FitsWriter.cc:103
std::shared_ptr< io::OutputArchive > _archive
Definition: Exposure.cc:217
BaseCatalog makeCatalog(Schema const &schema)
Return a new, empty catalog with the given schema.
Key< int > calib
Definition: Exposure.cc:66
T get(T... args)
void reserve(size_type n)
Increase the capacity of the catalog to the given size.
Definition: Catalog.h:428
Key< int > apCorrMap
Definition: Exposure.cc:68
#define LSST_EXCEPT(type,...)
Create an exception with a given type.
Definition: Exception.h:48
STL class.
static std::shared_ptr< ExposureTable > make(Schema const &schema)
Construct a new table.
Definition: Exposure.cc:392
STL class.
Base class for all records.
Definition: BaseRecord.h:31
static std::shared_ptr< BaseTable > make(Schema const &schema)
Construct a new table.
Definition: BaseTable.cc:121
Point in an unspecified spherical coordinate system.
Definition: SpherePoint.h:57
Schema finalize()
Map any remaining items into regular Schema items, and return the final Schema.
Key< U > key
Definition: Schema.cc:281
static ExposureCatalogT readFromArchive(io::InputArchive const &archive, BaseCatalog const &catalog)
Convenience input function for Persistables that contain an ExposureCatalog.
Definition: Exposure.cc:455
Custom catalog class for ExposureRecord/Table.
Definition: Exposure.h:67
void writeToArchive(io::OutputArchiveHandle &handle, bool ignoreUnpersistable=true) const
Convenience output function for Persistables that contain an ExposureCatalog.
Definition: Exposure.cc:443
void setTransmissionCurve(std::shared_ptr< image::TransmissionCurve const > transmissionCurve)
Get/Set the the attached Wcs, Psf, PhotoCalib, or ApCorrMap. No copies are made.
Definition: Exposure.h:167
virtual void _writeRecord(BaseRecord const &source)
Write an individual record.
Definition: FitsWriter.cc:189
Reports invalid arguments.
Definition: Runtime.h:66
void erase(Item const *item)
Remove the given item (which should have been retrieved via find()) from the mapping, preventing it from being included in the regular fields added by finalize().
Record class used to store exposure metadata.
Definition: Exposure.h:79
size_type size() const
Return the number of elements in the catalog.
Definition: Catalog.h:408
ItemVariant const * other
Definition: Schema.cc:56
Key< int > detector
Definition: Exposure.cc:72
void saveCatalog(BaseCatalog const &catalog)
Save a catalog in the archive.
void customize(std::unique_ptr< FitsColumnReader > reader)
Customize a mapping by providing a FitsColumnReader instance that will be invoked by readRecords()...
A multi-catalog archive object used to load table::io::Persistable objects.
Definition: InputArchive.h:31
Polymorphic reader interface used to read different kinds of objects from one or more FITS binary tab...
bool hasArchive() const
Return true if the mapper has an InputArchive.
iterator begin()
Iterator access.
Definition: Catalog.h:396
Item const * find(std::string const &ttype) const
Find an item with the given column name (ttype), returning nullptr if no such column exists...
void _assign(BaseRecord const &other) override
Called by assign() after transferring fields to allow subclass data members to be copied...
Definition: Exposure.cc:377
Key< int > psf
Definition: Exposure.cc:65
An integer coordinate rectangle.
Definition: Box.h:54
void readCell(BaseRecord &record, std::size_t row, fits::Fits &fits, std::shared_ptr< io::InputArchive > const &archive) const override
Read values from a single row.
Definition: Exposure.cc:268
lsst::geom::Box2I getBBox() const
Definition: Exposure.cc:341
Implementation of the Photometric Calibration class.
static BoxKey addFields(Schema &schema, std::string const &name, std::string const &doc, std::string const &unit)
Add _min_x, _min_y, _max_x, _max_y fields to a Schema, and return a BoxKey that points to them...
Definition: aggregates.cc:60
int end
Base class for all tables.
Definition: BaseTable.h:61
SchemaMapper * mapper
Definition: SchemaMapper.cc:78
std::shared_ptr< RecordT > addNew()
Create a new record, add it to the end of the catalog, and return a pointer to it.
Definition: Catalog.h:485
int row
Definition: CR.cc:145