mxlib
c++ tools for analyzing astronomical data and other tasks by Jared R. Males. [git repo]
ADIDerotator.hpp
Go to the documentation of this file.
1 /** \file ADIDerotator.hpp
2  * \author Jared R. Males
3  * \brief Defines a generic ADI derotator class.
4  * \ingroup hc_imaging_files
5  *
6  */
7 
8 #include "../ioutils/fits/fitsHeader.hpp"
9 
10 #ifndef ADIDerotator_hpp
11 #define ADIDerotator_hpp
12 
13 #include "../math/geo.hpp"
14 
15 namespace mx
16 {
17 
18 namespace improc
19 {
20 
21 ///A generic ADI derotator class.
22 /** This class is used to calculate the derotation angle for angular differential imaging.
23  *
24  * \ingroup hc_imaging
25  *
26  */
27 template<typename _realT>
29 {
30  typedef _realT realT;
31 
32  ///Vector of keywords to extract from the fits headers
33  std::vector<std::string> m_keywords;
34 
35  ///Vector(s) to hold the keyword values
36  std::vector<realT> m_angles;
37 
38 
39  std::string m_angleKeyword; ///<The keyword for the angle attribute. Do not set this directly.
40 
41  ///Set the angle keyword
42  /** Populates the kewords vector appropriately.
43  */
44  void angleKeyword( const std::string & akw /**< [in] The angle keyword */)
45  {
46  m_angleKeyword = akw;
47  m_keywords = {akw};
48  }
49 
50  realT m_angleScale {0}; ///< The scale to multiply the angle by
51  realT m_angleConstant {0}; ///< The constant to add to the scaled-angle.
52 
53  ADIDerotator()
54  {
55  }
56 
57  ///To allow ADIobservation to check for errors.
58  bool isSetup()
59  {
60  if( (m_angleKeyword == "" || m_keywords.size() == 0) || (m_angleScale == 0 && m_angleConstant == 0)) return false;
61  return true;
62  }
63 
64  ///Method called by ADIobservation to get keyword-values
65  void extractKeywords(std::vector<fits::fitsHeader> & heads /**< [in] The headers from the images being reduced.*/)
66  {
67  m_angles = fits::headersToValues<realT>(heads, m_angleKeyword);
68  }
69 
70  ///Calculate the derotation angle for a given image number
71  /**
72  * \returns the angle in radians by which to de-rotate the image c.c.w.
73  */
74  realT derotAngle(size_t imno /**< [in] the image number */) const
75  {
76  realT derot = m_angleScale*m_angles[imno] + m_angleConstant;
77  derot = math::angleMod<math::degreesT<realT>>(derot);
78  return math::dtor(derot );
79  }
80 };
81 
82 
83 ///@}
84 
85 extern template struct ADIDerotator<float>;
86 extern template struct ADIDerotator<double>;
87 
88 } //namespace improc
89 } //namespace mx
90 
91 #endif // ADIDerotator_hpp
92 
realT dtor(realT q)
Convert from degrees to radians.
Definition: geo.hpp:132
The mxlib c++ namespace.
Definition: mxError.hpp:107
A generic ADI derotator class.
std::vector< realT > m_angles
Vector(s) to hold the keyword values.
bool isSetup()
To allow ADIobservation to check for errors.
std::vector< std::string > m_keywords
Vector of keywords to extract from the fits headers.
realT m_angleScale
The scale to multiply the angle by.
realT derotAngle(size_t imno) const
Calculate the derotation angle for a given image number.
void angleKeyword(const std::string &akw)
Set the angle keyword.
void extractKeywords(std::vector< fits::fitsHeader > &heads)
Method called by ADIobservation to get keyword-values.
std::string m_angleKeyword
The keyword for the angle attribute. Do not set this directly.
realT m_angleConstant
The constant to add to the scaled-angle.