Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DM-19575: Add Storable mixin to ExposureInfo components #465

Merged
merged 20 commits into from
Jun 7, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion COPYRIGHT
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Copyright 2014-2018 The Trustees of Princeton University
Copyright 2014-2018 University of Washington
Copyright 2014-2019 University of Washington
Copyright 2014-2018 Association of Universities for Research in Astronomy
Copyright 2014-2015, 2017-2018 The Board of Trustees of the Leland Stanford Junior University, through SLAC National Accelerator Laboratory
Copyright 2017 California Institute of Technology
Expand Down
3 changes: 2 additions & 1 deletion include/lsst/afw/cameraGeom/Detector.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#include "lsst/afw/cameraGeom/CameraSys.h"
#include "lsst/afw/cameraGeom/Orientation.h"
#include "lsst/afw/cameraGeom/TransformMap.h"
#include "lsst/afw/typehandling/Storable.h"

namespace lsst {
namespace afw {
Expand All @@ -58,7 +59,7 @@ enum DetectorType {
* for instance it is not possible to construct one from a non-const catalog,
* so I don't know how to construct one.
*/
class Detector final : public table::io::PersistableFacade<Detector>, public table::io::Persistable {
class Detector final : public table::io::PersistableFacade<Detector>, public typehandling::Storable {
public:
typedef ndarray::Array<float const, 2> CrosstalkMatrix;

Expand Down
11 changes: 10 additions & 1 deletion include/lsst/afw/detection/Psf.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
#include "lsst/afw/math/Kernel.h"
#include "lsst/afw/image/Color.h"
#include "lsst/afw/table/io/Persistable.h"
#include "lsst/afw/typehandling/Storable.h"

namespace lsst {
namespace afw {
Expand Down Expand Up @@ -74,7 +75,7 @@ struct PsfCacheKey;
*/
class Psf : public daf::base::Citizen,
public afw::table::io::PersistableFacade<Psf>,
public afw::table::io::Persistable {
public afw::typehandling::Storable {
static lsst::geom::Point2D makeNullPoint() {
return lsst::geom::Point2D(std::numeric_limits<double>::quiet_NaN());
}
Expand Down Expand Up @@ -108,6 +109,14 @@ class Psf : public daf::base::Citizen,
*/
virtual std::shared_ptr<Psf> clone() const = 0;

/**
* @copybrief clone
*
* This method is an alias of @ref clone that can be called from a
* reference to @ref typehandling::Storable "Storable".
*/
std::shared_ptr<typehandling::Storable> cloneStorable() const override final { return clone(); }

/**
* Return clone with specified kernel dimensions
*
Expand Down
18 changes: 17 additions & 1 deletion include/lsst/afw/geom/SkyWcs.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
#include "lsst/afw/geom/Endpoint.h"
#include "lsst/afw/geom/Transform.h"
#include "lsst/afw/table/io/Persistable.h"
#include "lsst/afw/typehandling/Storable.h"

namespace lsst {
namespace afw {
Expand Down Expand Up @@ -113,7 +114,7 @@ Eigen::Matrix2d makeCdMatrix(lsst::geom::Angle const &scale,
*
* The other frames are of type ast::Frame and have 2 axes.
*/
class SkyWcs final : public table::io::PersistableFacade<SkyWcs>, public table::io::Persistable {
class SkyWcs final : public table::io::PersistableFacade<SkyWcs>, public typehandling::Storable {
public:
SkyWcs(SkyWcs const &) = default;
SkyWcs(SkyWcs &&) = default;
Expand Down Expand Up @@ -401,6 +402,21 @@ class SkyWcs final : public table::io::PersistableFacade<SkyWcs>, public table::
/// Serialize this SkyWcs to a string, using the same format as writeStream
std::string writeString() const;

// Override methods required by afw::typehandling::Storable

/// Create a new SkyWcs that is a copy of this one.
std::shared_ptr<typehandling::Storable> cloneStorable() const override;

/// Create a string representation of this object.
std::string toString() const override;

/**
* Compare this object to another Storable.
*
* @returns `*this == other` if `other` is a SkyWcs; otherwise `false`.
*/
bool equals(typehandling::Storable const &other) const noexcept override;

protected:
// Override methods required by afw::table::io::Persistable
std::string getPersistenceName() const override;
Expand Down
19 changes: 16 additions & 3 deletions include/lsst/afw/geom/polygon/Polygon.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
#include "lsst/afw/geom/Transform.h"
#include "lsst/afw/image/Image.h"
#include "lsst/afw/image/MaskedImage.h"
#include "lsst/afw/typehandling/Storable.h"

namespace lsst {
namespace afw {
Expand All @@ -55,7 +56,7 @@ LSST_EXCEPTION_TYPE(SinglePolygonException, lsst::pex::exceptions::RuntimeError,
///
/// Polygons are defined by a set of vertices

class Polygon : public afw::table::io::PersistableFacade<Polygon>, public afw::table::io::Persistable {
class Polygon final : public afw::table::io::PersistableFacade<Polygon>, public afw::typehandling::Storable {
public:
typedef lsst::geom::Box2D Box;
typedef lsst::geom::Point2D Point;
Expand Down Expand Up @@ -137,7 +138,7 @@ class Polygon : public afw::table::io::PersistableFacade<Polygon>, public afw::t
bool operator!=(Polygon const& other) const { return !(*this == other); }

/// Return a hash of this object.
std::size_t hash_value() const noexcept;
std::size_t hash_value() const noexcept override;
kfindeisen marked this conversation as resolved.
Show resolved Hide resolved

/// Returns whether the polygon contains the point
bool contains(Point const& point) const;
Expand Down Expand Up @@ -249,10 +250,22 @@ class Polygon : public afw::table::io::PersistableFacade<Polygon>, public afw::t
}
//@}

//@{
/// Whether Polygon is persistable which is always true
bool isPersistable() const noexcept override { return true; }

/// Create a new Polygon that is a copy of this one.
std::shared_ptr<typehandling::Storable> cloneStorable() const override;

/// Create a string representation of this object.
std::string toString() const override;

/**
* Compare this object to another Storable.
*
* @returns `*this == other` if `other` is a Polygon; otherwise `false`.
*/
bool equals(typehandling::Storable const& other) const noexcept override;

protected:
std::string getPersistenceName() const override;

Expand Down
6 changes: 5 additions & 1 deletion include/lsst/afw/image/ApCorrMap.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include <map>

#include "lsst/afw/table/io/Persistable.h"
#include "lsst/afw/typehandling/Storable.h"
#include "lsst/afw/math/BoundedField.h"

namespace lsst {
Expand All @@ -41,7 +42,7 @@ namespace image {
* (given the simplified interface, for instance, we could switch to unordered_map or some other
* underyling container in the future).
*/
class ApCorrMap : public table::io::PersistableFacade<ApCorrMap>, public table::io::Persistable {
class ApCorrMap final : public table::io::PersistableFacade<ApCorrMap>, public typehandling::Storable {
typedef std::map<std::string, std::shared_ptr<math::BoundedField>> Internal;

public:
Expand Down Expand Up @@ -80,6 +81,9 @@ class ApCorrMap : public table::io::PersistableFacade<ApCorrMap>, public table::
ApCorrMap& operator*=(double const scale);
ApCorrMap& operator/=(double const scale) { return *this *= 1.0 / scale; }

/// Create a new ApCorrMap that is a copy of this one.
std::shared_ptr<typehandling::Storable> cloneStorable() const override;

private:
std::string getPersistenceName() const override;

Expand Down
6 changes: 5 additions & 1 deletion include/lsst/afw/image/CoaddInputs.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include "lsst/base.h"
#include "lsst/afw/table/Exposure.h"
#include "lsst/afw/table/io/Persistable.h"
#include "lsst/afw/typehandling/Storable.h"

namespace lsst {
namespace afw {
Expand All @@ -45,7 +46,7 @@ namespace image {
* single-depth ones, so they simply pick out the single non-coadd-Psf that is valid for each
* point).
*/
class CoaddInputs : public table::io::PersistableFacade<CoaddInputs>, public table::io::Persistable {
class CoaddInputs final : public table::io::PersistableFacade<CoaddInputs>, public typehandling::Storable {
public:
table::ExposureCatalog visits;
table::ExposureCatalog ccds;
Expand Down Expand Up @@ -78,6 +79,9 @@ class CoaddInputs : public table::io::PersistableFacade<CoaddInputs>, public tab
*/
bool isPersistable() const noexcept override;

/// Create a new CoaddInputs that is a copy of this one.
std::shared_ptr<typehandling::Storable> cloneStorable() const override;

protected:
std::string getPersistenceName() const override;
std::string getPythonModule() const override;
Expand Down
23 changes: 20 additions & 3 deletions include/lsst/afw/image/Filter.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
#include <memory>
#include "lsst/base.h"
#include "lsst/daf/base/PropertySet.h"

#include "lsst/afw/typehandling/Storable.h"

namespace lsst {
namespace afw {
Expand Down Expand Up @@ -138,7 +138,7 @@ class FilterProperty final {
/**
* Holds an integer identifier for an LSST filter.
*/
class Filter final {
class Filter final : public typehandling::Storable {
public:
static int const AUTO;
static int const UNKNOWN;
Expand Down Expand Up @@ -177,7 +177,7 @@ class Filter final {
bool operator!=(Filter const& rhs) const noexcept { return !(*this == rhs); }

/// Return a hash of this object.
std::size_t hash_value() const noexcept;
std::size_t hash_value() const noexcept override;

/**
* Return a Filter's integral id
Expand Down Expand Up @@ -230,6 +230,23 @@ class Filter final {
*/
static std::vector<std::string> getNames();

/// Create a new Filter that is a copy of this one.
std::shared_ptr<typehandling::Storable> cloneStorable() const override;

/**
* Compare this object to another Storable.
*
* @returns `*this == other` if `other` is a Filter; otherwise `false`.
*/
bool equals(typehandling::Storable const& other) const noexcept override;

bool isPersistable() const noexcept override;

protected:
std::string getPersistenceName() const override;
std::string getPythonModule() const override;
void write(OutputArchiveHandle& handle) const override;

private:
typedef std::unordered_map<std::string, std::string const> AliasMap;
typedef std::unordered_map<std::string, unsigned int const> NameMap;
Expand Down
19 changes: 16 additions & 3 deletions include/lsst/afw/image/PhotoCalib.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
#include "lsst/geom/Box.h"
#include "lsst/afw/table/Source.h"
#include "lsst/afw/table/io/Persistable.h"
#include "lsst/afw/typehandling/Storable.h"
#include "lsst/afw/image/MaskedImage.h"
#include "lsst/daf/base/PropertyList.h"
#include "lsst/pex/exceptions/Exception.h"
Expand Down Expand Up @@ -112,7 +113,7 @@ inline void assertNonNegative(double value, std::string const &name) {
* @f]
* Note that this is independent of referenceFlux.
*/
class PhotoCalib : public table::io::PersistableFacade<PhotoCalib>, public table::io::Persistable {
class PhotoCalib final : public table::io::PersistableFacade<PhotoCalib>, public typehandling::Storable {
public:
// Allow move, but no copy
PhotoCalib(PhotoCalib const &) = default;
Expand Down Expand Up @@ -478,8 +479,6 @@ class PhotoCalib : public table::io::PersistableFacade<PhotoCalib>, public table

bool isPersistable() const noexcept override { return true; }

friend std::ostream &operator<<(std::ostream &os, PhotoCalib const &photoCalib);

/* Backwards compatibility with old Calib object */

/// No-op: for backwards compatibility with Calib.
Expand Down Expand Up @@ -555,6 +554,20 @@ class PhotoCalib : public table::io::PersistableFacade<PhotoCalib>, public table
throw LSST_EXCEPT(pex::exceptions::RuntimeError, msg);
}

/// Create a new PhotoCalib that is a copy of this one.
std::shared_ptr<typehandling::Storable> cloneStorable() const override;

/// Create a string representation of this object.
std::string toString() const override;

/**
* Compare this object to another Storable.
*
* @returns `*this == other` if `other` is a PhotoCalib; otherwise `false`.
*/
bool equals(typehandling::Storable const &other) const noexcept override;
// PhotoCalib equality comparable but intentionally not hashable

protected:
std::string getPersistenceName() const override;

Expand Down
3 changes: 2 additions & 1 deletion include/lsst/afw/image/TransmissionCurve.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include "lsst/afw/geom/Transform.h"
#include "lsst/geom/Box.h"
#include "lsst/afw/table/io/Persistable.h"
#include "lsst/afw/typehandling/Storable.h"

namespace lsst {
namespace afw {
Expand Down Expand Up @@ -56,7 +57,7 @@ namespace image {
* normalization expected/provided.
*/
class TransmissionCurve : public table::io::PersistableFacade<TransmissionCurve>,
public table::io::Persistable,
public typehandling::Storable,
public std::enable_shared_from_this<TransmissionCurve> {
public:
/**
Expand Down
18 changes: 16 additions & 2 deletions include/lsst/afw/image/VisitInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
#include "lsst/geom/SpherePoint.h"
#include "lsst/afw/table/misc.h" // for RecordId
#include "lsst/afw/table/io/Persistable.h"
#include "lsst/afw/typehandling/Storable.h"

namespace lsst {
namespace afw {
Expand Down Expand Up @@ -64,7 +65,7 @@ enum class RotType {
*
* VisitInfo is immutable.
*/
class VisitInfo : public table::io::PersistableFacade<VisitInfo>, public table::io::Persistable {
class VisitInfo : public table::io::PersistableFacade<VisitInfo>, public typehandling::Storable {
public:
/**
* Construct a VisitInfo
Expand Down Expand Up @@ -118,7 +119,7 @@ class VisitInfo : public table::io::PersistableFacade<VisitInfo>, public table::
bool operator!=(VisitInfo const &other) const { return !(*this == other); };

/// Return a hash of this object.
std::size_t hash_value() const noexcept;
std::size_t hash_value() const noexcept override;

/// get exposure ID
table::RecordId getExposureId() const { return _exposureId; }
Expand Down Expand Up @@ -186,6 +187,19 @@ class VisitInfo : public table::io::PersistableFacade<VisitInfo>, public table::
*/
lsst::geom::Angle getBoresightParAngle() const;

/// Create a new VisitInfo that is a copy of this one.
std::shared_ptr<typehandling::Storable> cloneStorable() const override;

/// Create a string representation of this object.
std::string toString() const override;

/**
* Compare this object to another Storable.
*
* @returns `*this == other` if `other` is a VisitInfo; otherwise `false`.
*/
bool equals(typehandling::Storable const &other) const noexcept override;

protected:
std::string getPersistenceName() const override;

Expand Down