CppEphem
CECorrections.h
Go to the documentation of this file.
1 /***************************************************************************
2  * CECorrections.h: CppEphem *
3  * ----------------------------------------------------------------------- *
4  * Copyright © 2019 JCardenzana *
5  * ----------------------------------------------------------------------- *
6  * *
7  * This program is free software: you can redistribute it and/or modify *
8  * it under the terms of the GNU General Public License as published by *
9  * the Free Software Foundation, either version 3 of the License, or *
10  * (at your option) any later version. *
11  * *
12  * This program is distributed in the hope that it will be useful, *
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
15  * GNU General Public License for more details. *
16  * *
17  * You should have received a copy of the GNU General Public License *
18  * along with this program. If not, see <http://www.gnu.org/licenses/>. *
19  * *
20  ***************************************************************************/
21 
22 #ifndef CECorrections_h
23 #define CECorrections_h
24 
25 #include <map>
26 #include <string>
27 #include <vector>
28 
29 class CECorrections {
30 public:
31  CECorrections();
32  CECorrections(const CECorrections& other);
33  virtual ~CECorrections() {}
34 
35  CECorrections& operator=(const CECorrections& other);
36 
37  double dut1(const double& mjd) const;
38  double xpolar(const double& mjd) const;
39  double ypolar(const double& mjd) const;
40  double deps(const double& mjd) const;
41  double dpsi(const double& mjd) const;
42  double ttut1(const double& mjd) const;
43  std::string NutationFile(void) const;
44  std::string TtUt1HistFile(void) const;
45  std::string TtUt1PredFile(void) const;
46  void SetNutationFile(const std::string& filename);
47  void SetTtUt1HistFile(const std::string& filename);
48  void SetTtUt1PredFile(const std::string& filename);
49  void SetInterp(bool set_interp);
50 
51 private:
52 
53  void copy_members(const CECorrections& other);
54  void free_members(void);
55  void init_members(void);
56  std::ifstream LoadFile(const std::string& filename,
57  const std::string& url) const;
58  bool DownloadTable(const std::string& filename,
59  const std::string& url) const;
60  bool LoadNutation(void) const;
61  bool LoadTtUt1(void) const;
62  double InterpValue(const double& x,
63  const double& x0, const double& x1,
64  const double& y0, const double& y1) const;
65  void UpdateNutationCache(const double& mjd) const;
66  void UpdateTtUt1Cache(const double& mjd) const;
67 
68  // Filenames for storing/loading correction values
69  mutable std::string nutation_file_;
70  mutable std::string ttut1_file_hist_;
71  mutable std::string ttut1_file_pred_;
72 
73  // Table to hold the corrections for a given MJD
74  mutable std::vector<int> nutation_mjd_;
75  mutable std::vector<double> nutation_dut1_;
76  mutable std::vector<double> nutation_xp_;
77  mutable std::vector<double> nutation_yp_;
78  mutable std::vector<double> nutation_deps_;
79  mutable std::vector<double> nutation_dpsi_;
80 
81  mutable std::vector<double> ttut1_mjd_;
82  mutable std::vector<double> ttut1_delt_;
83 
84  // Specifies whether to interpolate values between dates or not
85  // Interpolating will give slightly more accurate results at the expense
86  // of increasing computation time.
87  bool interp_;
88 
89  // Caching variables so that we dont need to find new values if we've
90  // already looked up the appropriate index
91  mutable double cache_nut_mjd_;
92  mutable double cache_nut_dut1_;
93  mutable double cache_nut_xp_;
94  mutable double cache_nut_yp_;
95  mutable double cache_nut_deps_;
96  mutable double cache_nut_dpsi_;
97  mutable double cache_ttut1_mjd_;
98  mutable double cache_ttut1_delt_;
99 };
100 
101 
102 /**********************************************************************/
107 inline
108 std::string CECorrections::NutationFile(void) const
109 {
111 }
112 
113 
114 /**********************************************************************/
119 inline
120 std::string CECorrections::TtUt1HistFile(void) const
121 {
122  return ttut1_file_hist_;
123 }
124 
125 
126 /**********************************************************************/
131 inline
132 std::string CECorrections::TtUt1PredFile(void) const
133 {
134  return ttut1_file_pred_;
135 }
136 
137 #endif /* CECorrections_h */
CECorrections::DownloadTable
bool DownloadTable(const std::string &filename, const std::string &url) const
Downloads the IERS earth orientation correction parameters.
Definition: CECorrections.cpp:360
CECorrections::cache_nut_deps_
double cache_nut_deps_
Definition: CECorrections.h:112
CECorrections::init_members
void init_members(void)
Initialize data members.
Definition: CECorrections.cpp:289
CECorrections::nutation_dut1_
std::vector< double > nutation_dut1_
Definition: CECorrections.h:92
CECorrections::dut1
double dut1(const double &mjd) const
Return the DUT1 correction parameter (represents UT1 - UTC in seconds)
Definition: CECorrections.cpp:79
CECorrections::SetTtUt1PredFile
void SetTtUt1PredFile(const std::string &filename)
Sets the name of the predicted values TT-UT1 corrections file.
Definition: CECorrections.cpp:213
CECorrections::cache_nut_xp_
double cache_nut_xp_
Definition: CECorrections.h:110
CECorrections::ttut1_file_pred_
std::string ttut1_file_pred_
File for predicted TT-UT1 corrections.
Definition: CECorrections.h:88
CECorrections::CECorrections
CECorrections()
Constructor for coordinate corrections object.
Definition: CECorrections.cpp:58
CECorrections::InterpValue
double InterpValue(const double &x, const double &x0, const double &x1, const double &y0, const double &y1) const
Return the interpolated value at a given x value between two known values.
Definition: CECorrections.cpp:707
CECorrections::cache_nut_dpsi_
double cache_nut_dpsi_
Definition: CECorrections.h:113
CECorrections
Definition: CECorrections.h:28
CECorrections::cache_nut_dut1_
double cache_nut_dut1_
Definition: CECorrections.h:109
CECorrections::deps
double deps(const double &mjd) const
Return the offset in obliquity correction parameter (radians)
Definition: CECorrections.cpp:127
CECorrections::SetInterp
void SetInterp(bool set_interp)
Defines that the correction values should be interpolated.
Definition: CECorrections.cpp:224
CECorrections::cache_nut_mjd_
double cache_nut_mjd_
Definition: CECorrections.h:108
CECorrections::nutation_file_
std::string nutation_file_
File for nutation corrections.
Definition: CECorrections.h:86
CECorrections::copy_members
void copy_members(const CECorrections &other)
Copy data members from another object.
Definition: CECorrections.cpp:260
CECorrections::xpolar
double xpolar(const double &mjd) const
Return the x-polar motion correction parameter (radians)
Definition: CECorrections.cpp:95
CECorrections::nutation_deps_
std::vector< double > nutation_deps_
Definition: CECorrections.h:95
CECorrections::cache_ttut1_mjd_
double cache_ttut1_mjd_
Definition: CECorrections.h:114
CECorrections::cache_nut_yp_
double cache_nut_yp_
Definition: CECorrections.h:111
CECorrections::UpdateTtUt1Cache
void UpdateTtUt1Cache(const double &mjd) const
Recompute cached values of nutation valeus if necessary.
Definition: CECorrections.cpp:654
CECorrections::ttut1_file_hist_
std::string ttut1_file_hist_
File for historic TT-UT1 corrections.
Definition: CECorrections.h:87
CECorrections::ttut1
double ttut1(const double &mjd) const
Return the TT-UT1 correction at a given date (in seconds)
Definition: CECorrections.cpp:159
CECorrections::SetTtUt1HistFile
void SetTtUt1HistFile(const std::string &filename)
Sets the name of the historic values TT-UT1 corrections file.
Definition: CECorrections.cpp:202
CECorrections::nutation_mjd_
std::vector< int > nutation_mjd_
Definition: CECorrections.h:91
CECorrections::nutation_xp_
std::vector< double > nutation_xp_
Definition: CECorrections.h:93
CECorrections::LoadFile
std::ifstream LoadFile(const std::string &filename, const std::string &url) const
Initialize data members.
Definition: CECorrections.cpp:324
CECorrections::nutation_dpsi_
std::vector< double > nutation_dpsi_
Definition: CECorrections.h:96
CECorrections::free_members
void free_members(void)
Free data member objects.
Definition: CECorrections.cpp:239
CECorrections::NutationFile
std::string NutationFile(void) const
Returns the name of the nutation corrections file.
Definition: CECorrections.h:107
CECorrections::ttut1_delt_
std::vector< double > ttut1_delt_
Definition: CECorrections.h:99
CECorrections::ypolar
double ypolar(const double &mjd) const
Return the y-polar motion correction parameter (radians)
Definition: CECorrections.cpp:111
CECorrections::UpdateNutationCache
void UpdateNutationCache(const double &mjd) const
Recompute cached values of nutation valeus if necessary.
Definition: CECorrections.cpp:590
CECorrections::SetNutationFile
void SetNutationFile(const std::string &filename)
Sets the name of the nutation corrections file.
Definition: CECorrections.cpp:191
CECorrections::dpsi
double dpsi(const double &mjd) const
Return the offset in longitude correction parameter (radians)
Definition: CECorrections.cpp:143
CECorrections::TtUt1HistFile
std::string TtUt1HistFile(void) const
Returns the name of the historic TT-UT1 corrections file.
Definition: CECorrections.h:119
CECorrections::interp_
bool interp_
Definition: CECorrections.h:104
CECorrections::cache_ttut1_delt_
double cache_ttut1_delt_
Definition: CECorrections.h:115
CECorrections::ttut1_mjd_
std::vector< double > ttut1_mjd_
Definition: CECorrections.h:98
CECorrections::TtUt1PredFile
std::string TtUt1PredFile(void) const
Returns the name of the precited TT-UT1 corrections file.
Definition: CECorrections.h:131
CECorrections::~CECorrections
virtual ~CECorrections()
Definition: CECorrections.h:50
CECorrections::operator=
CECorrections & operator=(const CECorrections &other)
Overloaded assignment operator.
Definition: CECorrections.cpp:175
CECorrections::LoadTtUt1
bool LoadTtUt1(void) const
Loads the TT-UT1 correction values.
Definition: CECorrections.cpp:494
CECorrections::LoadNutation
bool LoadNutation(void) const
Loads the IERS earth orientation correction parameters.
Definition: CECorrections.cpp:404
CECorrections::nutation_yp_
std::vector< double > nutation_yp_
Definition: CECorrections.h:94