LSSTApplications
19.0.0-14-gb0260a2+72efe9b372,20.0.0+7927753e06,20.0.0+8829bf0056,20.0.0+995114c5d2,20.0.0+b6f4b2abd1,20.0.0+bddc4f4cbe,20.0.0-1-g253301a+8829bf0056,20.0.0-1-g2b7511a+0d71a2d77f,20.0.0-1-g5b95a8c+7461dd0434,20.0.0-12-g321c96ea+23efe4bbff,20.0.0-16-gfab17e72e+fdf35455f6,20.0.0-2-g0070d88+ba3ffc8f0b,20.0.0-2-g4dae9ad+ee58a624b3,20.0.0-2-g61b8584+5d3db074ba,20.0.0-2-gb780d76+d529cf1a41,20.0.0-2-ged6426c+226a441f5f,20.0.0-2-gf072044+8829bf0056,20.0.0-2-gf1f7952+ee58a624b3,20.0.0-20-geae50cf+e37fec0aee,20.0.0-25-g3dcad98+544a109665,20.0.0-25-g5eafb0f+ee58a624b3,20.0.0-27-g64178ef+f1f297b00a,20.0.0-3-g4cc78c6+e0676b0dc8,20.0.0-3-g8f21e14+4fd2c12c9a,20.0.0-3-gbd60e8c+187b78b4b8,20.0.0-3-gbecbe05+48431fa087,20.0.0-38-ge4adf513+a12e1f8e37,20.0.0-4-g97dc21a+544a109665,20.0.0-4-gb4befbc+087873070b,20.0.0-4-gf910f65+5d3db074ba,20.0.0-5-gdfe0fee+199202a608,20.0.0-5-gfbfe500+d529cf1a41,20.0.0-6-g64f541c+d529cf1a41,20.0.0-6-g9a5b7a1+a1cd37312e,20.0.0-68-ga3f3dda+5fca18c6a4,20.0.0-9-g4aef684+e18322736b,w.2020.45
LSSTDataManagementBasePackage
|
Go to the documentation of this file.
37 int const EXPOSURE_TABLE_CURRENT_VERSION = 5;
38 std::string const EXPOSURE_TABLE_VERSION_KEY =
"EXPTABLE_VER";
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";
53 int getTableVersion(daf::base::PropertySet &metadata) {
54 return metadata.exists(EXPOSURE_TABLE_VERSION_KEY) ? metadata.get<
int>(EXPOSURE_TABLE_VERSION_KEY) : 1;
62 struct PersistenceHelper {
75 SchemaMapper makeWriteMapper(Schema
const &inputSchema)
const {
81 result.editOutputSchema().setAliasMap(inputSchema.getAliasMap());
86 SchemaMapper makeReadMapper(Schema
const &inputSchema)
const {
88 result.editOutputSchema().setAliasMap(inputSchema.getAliasMap());
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));
108 void readRecord(BaseRecord
const &input, ExposureRecord &output, SchemaMapper
const &
mapper,
109 io::InputArchive
const &archive)
const {
110 output.assign(input,
mapper);
112 output.setPsf(archive.get<detection::Psf>(input.get(
psf)));
115 output.setWcs(archive.get<geom::SkyWcs>(input.get(
wcs)));
127 output.setValidPolygon(archive.get<geom::polygon::Polygon>(input.get(
validPolygon)));
136 output.setDetector(archive.get<cameraGeom::Detector>(input.get(
detector)));
141 PersistenceHelper(
const PersistenceHelper &) =
delete;
142 PersistenceHelper &operator=(
const PersistenceHelper &) =
delete;
145 PersistenceHelper(PersistenceHelper &&) =
delete;
146 PersistenceHelper &operator=(PersistenceHelper &&) =
delete;
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")),
158 "archive ID for TransmissionCurve object")),
159 detector(
schema.addField<int>(DETECTOR_FIELD_NAME,
"archive ID for Detector object")) {}
164 auto item = oldSchema.find<
int>(
name);
166 }
catch (pex::exceptions::NotFoundError &) {
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);
180 addIfPresent(oldSchema,
detector, DETECTOR_FIELD_NAME);
181 assert(oldSchema.contains(
schema));
197 class ExposureFitsWriter :
public io::FitsWriter {
203 _archive.reset(
new io::OutputArchive());
210 void _writeRecord(BaseRecord
const &r)
override;
212 void _finish()
override {
227 "Cannot use a ExposureFitsWriter on a non-Exposure table.");
234 _fits->writeKey(
"AFW_TYPE",
"EXPOSURE",
"Tells lsst::afw to load this as an Exposure table.");
235 _fits->writeKey(EXPOSURE_TABLE_VERSION_KEY, EXPOSURE_TABLE_CURRENT_VERSION,
"Exposure table version");
239 void ExposureFitsWriter::_writeRecord(BaseRecord
const &r) {
240 ExposureRecord
const &record =
static_cast<ExposureRecord
const &
>(r);
254 template <
typename T,
void (ExposureRecord::*Setter)(std::shared_ptr<T const>)>
260 if (
mapper.hasArchive()) {
273 fits.readTableScalar<
int>(
row, _column,
id);
285 class ExposureFitsReader :
public io::FitsReader {
287 ExposureFitsReader() :
afw::table::io::FitsReader(
"EXPOSURE") {}
291 bool stripMetadata)
const override {
297 auto tableVersion = getTableVersion(*metadata);
304 if (tableVersion > 1) {
308 if (tableVersion > 2) {
313 if (tableVersion > 3) {
318 if (tableVersion <= 4) {
328 table->setMetadata(metadata);
332 bool usesArchive(
int ioFlags)
const override {
return true; }
335 static ExposureFitsReader
const exposureFitsReader;
352 "ExposureRecord does not have a Wcs; cannot call contains()");
357 includeValidPolygon =
false;
362 if (includeValidPolygon)
373 bool includeValidPolygon)
const {
374 return contains(
wcs.pixelToSky(point), includeValidPolygon);
384 _photoCalib = s._photoCalib;
385 _apCorrMap = s._apCorrMap;
386 _validPolygon = s._validPolygon;
387 _visitInfo = s._visitInfo;
388 _transmissionCurve = s._transmissionCurve;
389 _detector = s._detector;
398 "Schema for Exposure must contain at least the keys defined by makeMinimalSchema().");
411 ExposureTable::MinimalSchema::MinimalSchema() {
416 ExposureTable::MinimalSchema &ExposureTable::getMinimalSchema() {
417 static MinimalSchema it;
428 return std::make_shared<ExposureFitsWriter>(fitsfile, archive, flags);
436 return constructRecord<ExposureRecord>();
443 template <
typename RecordT>
445 PersistenceHelper helper{};
448 outputCat.
reserve(this->size());
450 helper.writeRecord(*i, *outputCat.
addNew(),
mapper, handle, permissive);
455 template <
typename RecordT>
460 PersistenceHelper helper{catalog.
getSchema()};
465 helper.readRecord(*i, *
result.addNew(),
mapper, archive);
470 template <
typename RecordT>
472 bool includeValidPolygon)
const {
475 if (i->contains(coord, includeValidPolygon)) {
482 template <
typename RecordT>
484 geom::SkyWcs
const &
wcs,
485 bool includeValidPolygon)
const {
488 if (i->contains(point,
wcs, includeValidPolygon)) {
lsst::geom::Box2I getBBox() const
static Box2IKey getBBoxKey()
Key for the full bbox.
Key< T > addField(Field< T > const &field, bool doReplace=false)
Add a new field to the Schema, and return the associated Key.
virtual void _writeRecord(BaseRecord const &source)
Write an individual record.
Table class used to store exposure metadata.
Field< T >::Value get(Key< T > const &key) const
Return the value of a field for the given key.
An object passed to Persistable::write to allow it to persist itself.
A simple struct that combines the two arguments that must be passed to most cfitsio routines and cont...
Key< int > transmissionCurve
bool contains(Point2D const &point) const noexcept
Return true if the box contains the point.
std::shared_ptr< BaseTable > _clone() const override
Clone implementation with noncovariant return types.
void saveCatalog(BaseCatalog const &catalog)
Save a catalog in the archive.
Custom catalog class for ExposureRecord/Table.
void setBBox(lsst::geom::Box2I const &bbox)
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.
std::shared_ptr< io::OutputArchive > _archive
Defines the fields and offsets for a table.
std::shared_ptr< BaseRecord > _record
PersistableObjectColumnReader(int column)
static ExposureCatalogT readFromArchive(io::InputArchive const &archive, BaseCatalog const &catalog)
Convenience input function for Persistables that contain an ExposureCatalog.
Base class for all tables.
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...
std::shared_ptr< BaseRecord > _makeRecord() override
Default-construct an associated record (protected implementation).
void reserve(size_type n)
Increase the capacity of the catalog to the given size.
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.
BaseCatalog makeCatalog(Schema const &schema)
Return a new, empty catalog with the given schema.
size_type size() const
Return the number of elements in the catalog.
Reports arguments outside the domain of an operation.
std::shared_ptr< BaseRecord > makeRecord()
Default-construct an associated record.
Information about a single exposure of an imaging camera.
ItemVariant const * other
Base class for all records.
~ExposureRecord() override
Reports errors in the logical structure of the program.
A mapping between the keys of two Schemas, used to copy data between them.
Schema getSchema() const
Return the schema associated with the catalog's table.
static bool checkSchema(Schema const &other)
Return true if the given schema is a valid ExposureTable schema.
bool isValid() const noexcept
Return true if the key was initialized to valid offset.
Iterator class for CatalogT.
Polymorphic reader interface used to read different kinds of objects from one or more FITS binary tab...
The photometric calibration of an exposure.
Schema getSchema() const
Return the table's schema.
void setMetadata(std::shared_ptr< daf::base::PropertyList > const &metadata)
Set the flexible metadata associated with the table. May be null.
A base class for image defects.
#define LSST_EXCEPT(type,...)
Create an exception with a given type.
A spatially-varying transmission curve as a function of wavelength.
static SchemaMapper removeMinimalSchema(Schema const &input, Schema const &minimal)
Create a mapper by removing fields from the front of a schema.
virtual void _writeTable(std::shared_ptr< BaseTable const > const &table, std::size_t nRows)
Write a table and its schema.
ExposureTable(Schema const &schema)
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.
void setTransmissionCurve(std::shared_ptr< image::TransmissionCurve const > transmissionCurve)
Reports invalid arguments.
Implementation of the Photometric Calibration class.
PersistenceHelper _helper
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.
void writeToArchive(io::OutputArchiveHandle &handle, bool ignoreUnpersistable=true) const
Convenience output function for Persistables that contain an ExposureCatalog.
Schema const getOutputSchema() const
Return the output schema (copy-on-write).
static void setup(std::string const &name, io::FitsSchemaInputMapper &mapper)
An integer coordinate rectangle.
Record class used to store exposure metadata.
std::shared_ptr< daf::base::PropertyList > getMetadata() const
Return the flexible metadata associated with the table. May be null.
~ExposureTable() override
Point in an unspecified spherical coordinate system.
std::shared_ptr< RecordT > addNew()
Create a new record, add it to the end of the catalog, and return a pointer to it.
void set(Key< T > const &key, U const &value)
Set value of a field for the given key.
A floating-point coordinate rectangle geometry.
A thin wrapper around std::map to allow aperture corrections to be attached to Exposures.
iterator begin()
Iterator access.
static std::shared_ptr< BaseTable > make(Schema const &schema)
Construct a new table.
static std::shared_ptr< ExposureTable > make(Schema const &schema)
Construct a new table.
std::shared_ptr< geom::polygon::Polygon const > getValidPolygon() const
void _assign(BaseRecord const &other) override
Called by assign() after transferring fields to allow subclass data members to be copied.
std::shared_ptr< geom::SkyWcs const > getWcs() const
Get/Set the the attached Wcs, Psf, PhotoCalib, or ApCorrMap. No copies are made.
Custom catalog class for record/table subclasses that are guaranteed to have an ID,...