lsst.afw
21.0.0-11-ga6ea59e8e+47cba9fc36
|
Go to the documentation of this file.
28 #include "boost/algorithm/string/trim.hpp"
68 double getDouble(daf::base::PropertySet
const& metadata,
std::string const&
key) {
69 return metadata.exists(
key) ? metadata.getAsDouble(
key) :
nan;
93 return metadata.exists(
key) ? metadata.getAsString(
key) :
"";
104 bool setDouble(daf::base::PropertySet& metadata,
std::string const&
key,
double value,
107 metadata.set(
key, value);
123 return setDouble(metadata,
key,
angle.asDegrees(), comment);
136 if (!value.
empty()) {
137 metadata.set(
key, value);
150 case RotType::UNKNOWN:
154 case RotType::HORIZON:
160 os <<
"Unknown RotType enum: " <<
static_cast<int>(
rotType);
170 if (rotTypeName ==
"UNKNOWN") {
171 return RotType::UNKNOWN;
172 }
else if (rotTypeName ==
"SKY") {
174 }
else if (rotTypeName ==
"HORIZON") {
175 return RotType::HORIZON;
176 }
else if (rotTypeName ==
"MOUNT") {
177 return RotType::MOUNT;
180 os <<
"Unknown RotType name: \"" << rotTypeName <<
"\"";
184 class VisitInfoSchema {
190 table::Key<std::int64_t>
tai;
192 table::Key<lsst::geom::Angle>
era;
210 static VisitInfoSchema
const& get() {
211 static VisitInfoSchema instance;
216 VisitInfoSchema(
const VisitInfoSchema&) =
delete;
217 VisitInfoSchema& operator=(
const VisitInfoSchema&) =
delete;
220 VisitInfoSchema(VisitInfoSchema&&) =
delete;
221 VisitInfoSchema& operator=(VisitInfoSchema&&) =
delete;
228 darkTime(
schema.addField<double>(
"darktime",
"time from CCD flush to readout",
"s")),
230 "tai",
"TAI date and time at middle of exposure as nsec from unix epoch",
"nsec")),
231 ut1(
schema.addField<double>(
"ut1",
"UT1 date and time at middle of exposure",
"MJD")),
232 era(
schema.addField<
lsst::geom::
Angle>(
"era",
"earth rotation angle at middle of exposure",
235 "sky position of boresight at middle of exposure")),
240 "refracted apparent topocentric position of boresight at middle of exposure",
"")),
242 "boresightazalt_alt",
243 "refracted apparent topocentric position of boresight at middle of exposure",
"")),
245 "boresightairmass",
"airmass at boresight, relative to zenith at sea level",
"")),
247 "boresightrotangle",
"rotation angle at boresight at middle of exposure",
"")),
248 rotType(
schema.addField<int>(
"rottype",
"rotation type; see VisitInfo.getRotType for details",
252 "latitude",
"latitude of telescope (+ is east of Greenwich)",
"")),
254 elevation(
schema.addField<double>(
"elevation",
"elevation of telescope",
"")),
259 humidity(
schema.addField<double>(
"humidity",
"humidity (%)",
"")),
262 "instrumentlabel",
"Short name of the instrument that took this data",
"", 0)) {}
265 class VisitInfoFactory :
public table::io::PersistableFactory {
268 CatalogVector
const& catalogs)
const override {
269 VisitInfoSchema
const&
keys = VisitInfoSchema::get();
273 table::BaseRecord
const& record = catalogs.front().front();
275 new VisitInfo(record.get(
keys.exposureId), record.get(
keys.exposureTime),
276 record.get(
keys.darkTime), ::
DateTime(record.get(
keys.tai), ::DateTime::TAI),
277 record.
get(
keys.ut1), record.get(
keys.era), record.get(
keys.boresightRaDec),
279 record.get(
keys.boresightAzAlt_alt)),
280 record.get(
keys.boresightAirmass), record.get(
keys.boresightRotAngle),
282 coord::Observatory(record.get(
keys.longitude), record.get(
keys.latitude),
283 record.get(
keys.elevation)),
284 coord::Weather(record.get(
keys.airTemperature), record.get(
keys.airPressure),
285 record.get(
keys.humidity)),
286 record.get(
keys.instrumentLabel)));
290 explicit VisitInfoFactory(
std::string const&
name) : table::io::PersistableFactory(
name) {}
293 std::string getVisitInfoPersistenceName() {
return "VisitInfo"; }
295 VisitInfoFactory registration(getVisitInfoPersistenceName());
305 "TIME-MID",
"MJD-AVG-UT1",
"AVG-ERA",
"BORE-RA",
"BORE-DEC",
306 "BORE-AZ",
"BORE-ALT",
"BORE-AIRMASS",
"BORE-ROTANG",
"ROTTYPE",
307 "OBS-LONG",
"OBS-LAT",
"OBS-ELEV",
"AIRTEMP",
"AIRPRESS",
308 "HUMIDITY",
"INSTRUMENT"};
309 for (
auto&&
key : keyList) {
322 setDouble(metadata,
"EXPTIME",
visitInfo.getExposureTime(),
"Exposure time (sec)");
323 setDouble(metadata,
"DARKTIME",
visitInfo.getDarkTime(),
"Time from CCD flush to readout (sec)");
325 metadata.
set(
"DATE-AVG",
visitInfo.getDate().toString(::DateTime::TAI),
326 "TAI date at middle of observation");
327 metadata.
set(
"TIMESYS",
"TAI");
329 setDouble(metadata,
"MJD-AVG-UT1",
visitInfo.getUt1(),
"UT1 MJD date at ctr of obs");
330 setAngle(metadata,
"AVG-ERA",
visitInfo.getEra(),
"Earth rot ang at ctr of obs (deg)");
332 setAngle(metadata,
"BORE-RA",
boresightRaDec[0],
"ICRS RA (deg) at boresight");
333 setAngle(metadata,
"BORE-DEC",
boresightRaDec[1],
"ICRS Dec (deg) at boresight");
334 auto boresightAzAlt =
visitInfo.getBoresightAzAlt();
335 setAngle(metadata,
"BORE-AZ", boresightAzAlt[0],
"Refr app topo az (deg) at bore");
336 setAngle(metadata,
"BORE-ALT", boresightAzAlt[1],
"Refr app topo alt (deg) at bore");
337 setDouble(metadata,
"BORE-AIRMASS",
visitInfo.getBoresightAirmass(),
"Airmass at boresight");
338 setAngle(metadata,
"BORE-ROTANG",
visitInfo.getBoresightRotAngle(),
"Rotation angle (deg) at boresight");
339 metadata.
set(
"ROTTYPE", rotTypeStrFromEnum(
visitInfo.getRotType()),
"Type of rotation angle");
340 auto observatory =
visitInfo.getObservatory();
341 setAngle(metadata,
"OBS-LONG", observatory.getLongitude(),
"Telescope longitude (+E, deg)");
342 setAngle(metadata,
"OBS-LAT", observatory.getLatitude(),
"Telescope latitude (deg)");
343 setDouble(metadata,
"OBS-ELEV", observatory.getElevation(),
"Telescope elevation (m)");
345 setDouble(metadata,
"AIRTEMP", weather.getAirTemperature(),
"Outside air temperature (C)");
346 setDouble(metadata,
"AIRPRESS", weather.getAirPressure(),
"Outdoor air pressure (P)");
347 setDouble(metadata,
"HUMIDITY", weather.getHumidity(),
"Relative humidity (%)");
348 setString(metadata,
"INSTRUMENT",
visitInfo.getInstrumentLabel(),
349 "Short name of the instrument that took this data");
357 _darkTime(getDouble(metadata,
"DARKTIME")),
359 _ut1(getDouble(metadata,
"MJD-AVG-UT1")),
360 _era(getAngle(metadata,
"AVG-ERA")),
362 lsst::geom::
SpherePoint(getAngle(metadata,
"BORE-RA"), getAngle(metadata,
"BORE-DEC"))),
364 lsst::geom::
SpherePoint(getAngle(metadata,
"BORE-AZ"), getAngle(metadata,
"BORE-ALT"))),
365 _boresightAirmass(getDouble(metadata,
"BORE-AIRMASS")),
366 _boresightRotAngle(getAngle(metadata,
"BORE-ROTANG")),
368 _observatory(getAngle(metadata,
"OBS-LONG"), getAngle(metadata,
"OBS-LAT"),
369 getDouble(metadata,
"OBS-ELEV")),
370 _weather(getDouble(metadata,
"AIRTEMP"), getDouble(metadata,
"AIRPRESS"),
371 getDouble(metadata,
"HUMIDITY")),
372 _instrumentLabel(getString(metadata,
"INSTRUMENT")) {
391 if (metadata.
exists(
"TIMESYS")) {
392 auto timesysName = boost::algorithm::trim_right_copy(metadata.
getAsString(
"TIMESYS"));
393 if (timesysName !=
"TAI") {
398 os <<
"TIMESYS = \"" << timesysName
399 <<
"\"; VisitInfo requires TIMESYS to exist and to equal \"TAI\"";
404 "TIMESYS not found; VistitInfo requires TIMESYS to exist and to equal \"TAI\"");
423 return _exposureId ==
other.getExposureId() && _exposureTime ==
other.getExposureTime() &&
424 _darkTime ==
other.getDarkTime() && _date ==
other.getDate() && _ut1 ==
other.getUt1() &&
425 _era ==
other.getEra() && _boresightRaDec ==
other.getBoresightRaDec() &&
426 _boresightAzAlt ==
other.getBoresightAzAlt() && _boresightAirmass ==
other.getBoresightAirmass() &&
427 _boresightRotAngle ==
other.getBoresightRotAngle() && _rotType ==
other.getRotType() &&
428 _observatory ==
other.getObservatory() && _weather ==
other.getWeather() &&
429 _instrumentLabel ==
other.getInstrumentLabel();
434 return utils::hashCombine(17, _exposureId, _exposureTime, _darkTime, _date, _ut1, _era, _boresightRaDec,
435 _boresightAzAlt, _boresightAirmass, _boresightRotAngle, _rotType, _observatory,
436 _weather, _instrumentLabel);
442 VisitInfoSchema
const&
keys = VisitInfoSchema::get();
448 record->set(
keys.tai,
getDate().nsecs(::DateTime::TAI));
453 record->set(
keys.boresightAzAlt_az, boresightAzAlt[0]);
454 record->set(
keys.boresightAzAlt_alt, boresightAzAlt[1]);
459 record->set(
keys.latitude, observatory.getLatitude());
460 record->set(
keys.longitude, observatory.getLongitude());
461 record->set(
keys.elevation, observatory.getElevation());
463 record->set(
keys.airTemperature, weather.getAirTemperature());
464 record->set(
keys.airPressure, weather.getAirPressure());
465 record->set(
keys.humidity, weather.getHumidity());
479 double _parallactic_y, _parallactic_x,
result;
484 result = atan2(_parallactic_y, _parallactic_x);
489 return std::make_unique<VisitInfo>(*
this);
493 return singleClassEquals(*
this,
other);
498 buffer <<
"VisitInfo(";
503 buffer <<
"UT1=" <<
getUt1() <<
", ";
504 buffer <<
"ERA=" <<
getEra() <<
", ";
509 buffer <<
"rotType=" <<
static_cast<int>(
getRotType()) <<
", ";
constexpr AngleUnit degrees
lsst::geom::Angle getLongitude() const noexcept
get telescope longitude (positive values are E of Greenwich)
Backwards-compatibility support for depersisting the old Calib (FluxMag0/FluxMag0Err) objects.
daf::base::DateTime getDate() const
get uniform date and time at middle of exposure
#define LSST_ARCHIVE_ASSERT(EXPR)
An assertion macro used to validate the structure of an InputArchive.
std::int64_t RecordId
Type used for unique IDs for records.
double getUt1() const
get UT1 (universal time) MJD date at middle of exposure
table::Key< std::string > instrumentLabel
table::RecordId getExposureId() const
get exposure ID
lsst::geom::SpherePoint SpherePoint
table::Key< double > boresightAirmass
table::Key< lsst::geom::Angle > era
bool equals(typehandling::Storable const &other) const noexcept override
Compare this object to another Storable.
RotType getRotType() const
get rotation type of boresightRotAngle
An object passed to Persistable::write to allow it to persist itself.
void setVisitInfoMetadata(daf::base::PropertyList &metadata, VisitInfo const &visitInfo)
Set FITS metadata from a VisitInfo.
void saveCatalog(BaseCatalog const &catalog)
Save a catalog in the archive.
lsst::geom::Angle getBoresightParAngle() const
Get parallactic angle at the boresight.
lsst::geom::Angle getEra() const
get earth rotation angle at middle of exposure
double getExposureTime() const
get exposure duration (shutter open time); (sec)
std::string toString(Timescale scale) const
bool exists(std::string const &name) const
std::ostream & operator<<(std::ostream &os, Measurement const &measurement)
lsst::geom::SpherePoint getBoresightRaDec() const
get ICRS RA/Dec position at the boresight (and at the middle of the exposure, if it varies with time)
std::size_t hash_value() const noexcept override
Return a hash of this object.
table::Key< double > airPressure
Interface supporting iteration over heterogenous containers.
table::Key< double > angle
table::Key< double > airTemperature
table::Key< int > rotType
coord::Weather getWeather() const
get basic weather information
table::Key< double > elevation
BaseCatalog makeCatalog(Schema const &schema)
Return a new, empty catalog with the given schema.
table::Key< lsst::geom::Angle > boresightAzAlt_az
std::unique_ptr< SchemaItem< U > > result
Information about a single exposure of an imaging camera.
double get(DateSystem system=MJD, Timescale scale=TAI) const
table::Key< double > humidity
int64_t getAsInt64(std::string const &name) const
std::string getAsString(std::string const &name) const
lsst::geom::SpherePoint getBoresightAzAlt() const
get refracted apparent topocentric Az/Alt position at the boresight (and at the middle of the exposur...
void set(std::string const &name, T const &value)
ItemVariant const * other
lsst::geom::Angle getBoresightRotAngle() const
Get rotation angle at boresight at middle of exposure.
table::Key< table::RecordId > exposureId
table::Key< lsst::geom::Angle > boresightRotAngle
bool isValid() const noexcept
Return true if the key was initialized to valid offset.
lsst::geom::Angle getBoresightHourAngle() const
table::Key< double > exposureTime
table::CoordKey boresightRaDec
table::Key< double > darkTime
A base class for image defects.
virtual void remove(std::string const &name)
#define LSST_EXCEPT(type,...)
double getAsDouble(std::string const &name) const
static std::shared_ptr< T > dynamicCast(std::shared_ptr< Persistable > const &ptr)
Dynamically cast a shared_ptr.
double getBoresightAirmass() const
get airmass at the boresight, relative to zenith at sea level (and at the middle of the exposure,...
bool operator==(VisitInfo const &other) const
void write(OutputArchiveHandle &handle) const override
Write the object to one or more catalogs.
std::size_t hashCombine(std::size_t seed) noexcept
std::string toString() const override
Create a string representation of this object.
table::Key< std::int64_t > tai
std::string getInstrumentLabel() const
table::Key< lsst::geom::Angle > boresightAzAlt_alt
lsst::geom::Angle getLocalEra() const
double getDarkTime() const
get time from CCD flush to exposure readout, including shutter open time (despite the name); (sec)
constexpr AngleUnit radians
table::Key< lsst::geom::Angle > longitude
std::shared_ptr< RecordT > addNew()
Create a new record, add it to the end of the catalog, and return a pointer to it.
table::Key< lsst::geom::Angle > latitude
int stripVisitInfoKeywords(daf::base::PropertySet &metadata)
Remove VisitInfo-related keywords from the metadata.
coord::Observatory getObservatory() const
get observatory longitude, latitude and elevation
std::shared_ptr< typehandling::Storable > cloneStorable() const override
Create a new VisitInfo that is a copy of this one.
std::string getPersistenceName() const override
Return the unique name used to persist this object and look up its factory.