Alexandria  2.14.1
Please provide a description of the project.
Photometry.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2012-2020 Euclid Science Ground Segment
3  *
4  * This library is free software; you can redistribute it and/or modify it under
5  * the terms of the GNU Lesser General Public License as published by the Free
6  * Software Foundation; either version 3.0 of the License, or (at your option)
7  * any later version.
8  *
9  * This library is distributed in the hope that it will be useful, but WITHOUT
10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11  * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12  * details.
13  *
14  * You should have received a copy of the GNU Lesser General Public License
15  * along with this library; if not, write to the Free Software Foundation, Inc.,
16  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17  */
18 
26 #ifndef PHOTOMETRY_H_
27 #define PHOTOMETRY_H_
28 
29 #include <memory>
30 #include <vector>
31 #include <iterator>
32 
33 #include "ElementsKernel/Export.h"
35 
37 
38 namespace Euclid {
39 namespace SourceCatalog {
40 
41 struct FluxErrorPair {
42  double flux;
43  double error;
46  FluxErrorPair(double flux, double error, bool missing_photometry_flag=false,
47  bool upper_limit_flag=false);
48  FluxErrorPair(const FluxErrorPair&) = default;
49  bool operator==(const FluxErrorPair& other) const;
50  bool operator!=(const FluxErrorPair& other) const;
51 };
52 
68 
69 public:
70 
75  class PhotometryConstIterator : public std::iterator<std::forward_iterator_tag,
76  const FluxErrorPair> {
77  public:
80  PhotometryConstIterator& operator++();
81  reference operator*();
82  bool operator==(const PhotometryConstIterator& other) const;
83  bool operator!=(const PhotometryConstIterator& other) const;
84  const std::string& filterName() const;
85  private:
88  };
90 
91 
103  std::vector<FluxErrorPair> value_vector) :
104  m_filter_name_vector_ptr(filter_name_vector_ptr), m_value_vector(
105  std::move(value_vector)) {
106  if (m_filter_name_vector_ptr == nullptr) {
107  throw Elements::Exception() << "Photometry filter names vector pointer is null";
108  }
109  // Only check the size, but not the consistency
110  if (m_filter_name_vector_ptr->size() != m_value_vector.size()) {
111  throw Elements::Exception()
112  << "Photometry filter names vector has different size than the values vector";
113  }
114  }
115 
117  virtual ~Photometry() {
118  }
119 
121  return const_iterator { m_filter_name_vector_ptr->cbegin(),
122  m_value_vector.cbegin() };
123  }
124 
125  const_iterator end() const {
126  return const_iterator { m_filter_name_vector_ptr->cend(),
127  m_value_vector.cend() };
128  }
129 
134  std::size_t size() const {
135  return m_filter_name_vector_ptr->size();
136  }
137 
147  std::unique_ptr<FluxErrorPair> find(std::string filter_name) const;
148 
149 private:
150 
153 
156 
157 };
158 // Eof class Photometry
159 
160 } /* namespace SourceCatalog */
161 } // end of namespace Euclid
162 
163 #endif /* PHOTOMETRY_H_ */
Euclid::SourceCatalog::Photometry::m_filter_name_vector_ptr
std::shared_ptr< std::vector< std::string > > m_filter_name_vector_ptr
Shared pointer to the common list of filter names.
Definition: Photometry.h:152
std::string
STL class.
std::shared_ptr
STL class.
Export.h
Euclid::SourceCatalog::FluxErrorPair::operator!=
bool operator!=(const FluxErrorPair &other) const
Definition: FluxErrorPair.cpp:40
Euclid::SourceCatalog::Photometry::PhotometryConstIterator::m_values_iter
std::vector< FluxErrorPair >::const_iterator m_values_iter
Definition: Photometry.h:87
std::vector
STL class.
Euclid::SourceCatalog::FluxErrorPair
Definition: Photometry.h:41
Euclid::SourceCatalog::Photometry::PhotometryConstIterator
Definition: Photometry.h:75
std::iterator
boost::operator!=
bool operator!=(const Euclid::SourceCatalog::Source::id_type &a, const Euclid::SourceCatalog::Source::id_type &b)
boost::variant specifies an equality operator (==), but, in older boost versions, not an inequality o...
Definition: Source.h:118
Euclid::SourceCatalog::Attribute
Attribute interface extended by all source attributes.
Definition: Attribute.h:41
Euclid::SourceCatalog::Photometry::PhotometryConstIterator::m_filters_iter
std::vector< std::string >::const_iterator m_filters_iter
Definition: Photometry.h:86
Euclid::SourceCatalog::FluxErrorPair::FluxErrorPair
FluxErrorPair(double flux, double error, bool missing_photometry_flag=false, bool upper_limit_flag=false)
Definition: FluxErrorPair.cpp:30
Euclid::SourceCatalog::Photometry
Definition: Photometry.h:67
Euclid::SourceCatalog::FluxErrorPair::operator==
bool operator==(const FluxErrorPair &other) const
Definition: FluxErrorPair.cpp:34
Euclid::SourceCatalog::Photometry::m_value_vector
std::vector< FluxErrorPair > m_value_vector
The photometry map.
Definition: Photometry.h:155
Euclid::SourceCatalog::Photometry::size
std::size_t size() const
Return the size of the photometry map.
Definition: Photometry.h:134
ELEMENTS_API
#define ELEMENTS_API
Exception.h
Euclid::SourceCatalog::Photometry::end
const_iterator end() const
Definition: Photometry.h:125
Euclid::SourceCatalog::FluxErrorPair::upper_limit_flag
bool upper_limit_flag
Definition: Photometry.h:45
Elements::Exception
Euclid::SourceCatalog::Photometry::Photometry
Photometry(std::shared_ptr< std::vector< std::string >> filter_name_vector_ptr, std::vector< FluxErrorPair > value_vector)
Constructor which should never be called directly. Use the PhotometryAttributeHandler to build Photom...
Definition: Photometry.h:102
Euclid::SourceCatalog::FluxErrorPair::missing_photometry_flag
bool missing_photometry_flag
Definition: Photometry.h:44
std
STL namespace.
Euclid::SourceCatalog::FluxErrorPair::flux
double flux
Definition: Photometry.h:42
std::size_t
Euclid::SourceCatalog::FluxErrorPair::error
double error
Definition: Photometry.h:43
Euclid::SourceCatalog::Photometry::const_iterator
PhotometryConstIterator const_iterator
Definition: Photometry.h:89
std::unique_ptr
STL class.
Euclid
Definition: InstOrRefHolder.h:29
Euclid::SourceCatalog::Photometry::~Photometry
virtual ~Photometry()
default destructor
Definition: Photometry.h:117
Attribute.h
Euclid::SourceCatalog::Photometry::begin
const_iterator begin() const
Definition: Photometry.h:120