lsst.meas.algorithms  13.0-13-gf5c99ad+4
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
CoaddBoundedField.h
Go to the documentation of this file.
1 // -*- lsst-c++ -*-
2 /*
3  * LSST Data Management System
4  * Copyright 2008-2014 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 
24 #ifndef LSST_MEAS_ALGORITHMS_CoaddBoundedField_h_INCLUDED
25 #define LSST_MEAS_ALGORITHMS_CoaddBoundedField_h_INCLUDED
26 
27 #include "lsst/afw/math/BoundedField.h"
28 #include "lsst/afw/image/Wcs.h"
29 #include "lsst/afw/geom/polygon/Polygon.h"
30 
31 namespace lsst { namespace meas { namespace algorithms {
32 
35 
37  PTR(afw::math::BoundedField) field_,
38  PTR(afw::image::Wcs const) wcs_,
39  PTR(afw::geom::polygon::Polygon const) validPolygon_,
40  double weight_=1.0
41  ) : field(field_), wcs(wcs_), validPolygon(validPolygon_),
42  weight(weight_) {}
43 
45  bool operator==(CoaddBoundedFieldElement const& rhs) const {
46  return (field == rhs.field) && (wcs == rhs.wcs) && (rhs.validPolygon) && (weight == rhs.weight);
47  }
49  bool operator!=(CoaddBoundedFieldElement const& rhs) const { return !(*this == rhs); };
50 
51  PTR(afw::math::BoundedField) field;
52  PTR(afw::image::Wcs const) wcs;
53  PTR(afw::geom::polygon::Polygon const) validPolygon;
54  double weight;
55 };
56 
58  public afw::table::io::PersistableFacade<CoaddBoundedField>,
59  public afw::math::BoundedField
60 {
61 public:
62 
64  typedef std::vector<Element> ElementVector;
65 
66  explicit CoaddBoundedField(
67  afw::geom::Box2I const & bbox,
68  PTR(afw::image::Wcs const) coaddWcs,
69  ElementVector const & elements
70  );
71 
72  explicit CoaddBoundedField(
73  afw::geom::Box2I const & bbox,
74  PTR(afw::image::Wcs const) coaddWcs,
75  ElementVector const & elements,
76  double default_
77  );
78 
80  virtual double evaluate(afw::geom::Point2D const & position) const;
81 
85  virtual bool isPersistable() const { return true; }
86 
87  // Factory used to read CoaddPsf from an InputArchive; defined only in the source file.
88  class Factory;
89 
90  virtual PTR(afw::math::BoundedField) operator*(double const scale) const;
91 
93  virtual bool operator==(BoundedField const& rhs) const;
94 
95 protected:
96 
97  // See afw::table::io::Persistable::getPersistenceName
98  virtual std::string getPersistenceName() const;
99 
100  // See afw::table::io::Persistable::getPythonModule
101  virtual std::string getPythonModule() const;
102 
103  // See afw::table::io::Persistable::write
104  virtual void write(OutputArchiveHandle & handle) const;
105 
106 private:
107 
108  bool _throwOnMissing; // instead of using _default, raise an exception
109  double _default; // when none of the elements contribute at a point, return this value
110  PTR(afw::image::Wcs const) _coaddWcs; // coordinate system this field is defined in
111  ElementVector _elements; // vector of constituent fields being coadded
112 
113  virtual std::string toString() const {
114  std::ostringstream os;
115  os << "CoaddBoundedField with " << _elements.size() << " elements, default " << _default;
116  return os.str();
117  }
118 };
119 
120 }}} // namespace lsst::meas::algorithms
121 
122 #endif // !LSST_MEAS_ALGORITHMS_CoaddBoundedField_h_INCLUDED
Struct used to hold one Exposure&#39;s data in a CoaddBoundedField.
boost::shared_ptr< afw::image::Wcs const > wcs
virtual bool isPersistable() const
Return true if the CoaddBoundedField persistable (always true).
CoaddBoundedFieldElement(boost::shared_ptr< afw::math::BoundedField > field_, boost::shared_ptr< afw::image::Wcs const > wcs_, boost::shared_ptr< afw::geom::polygon::Polygon const > validPolygon_, double weight_=1.0)
tbl::Key< double > default_
bool operator!=(CoaddBoundedFieldElement const &rhs) const
Elements are equal if all their components are equal.
boost::shared_ptr< afw::math::BoundedField > field
bool operator==(CoaddBoundedFieldElement const &rhs) const
Elements are equal if all their components are equal.
tbl::Key< int > coaddWcs
boost::shared_ptr< afw::geom::polygon::Polygon const > validPolygon