CppEphem
CENamespace.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  * CENamespace.cpp: CppEphem *
3  * ----------------------------------------------------------------------- *
4  * Copyright © 2016-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 #include <cmath>
23 #include <iomanip>
24 #include <stdio.h>
25 #include <sstream>
26 #include "CENamespace.h"
27 
28 
29 /**********************************************************************/
34 std::string CppEphem::NutationFile(void)
35 {
37 }
38 
39 
40 /**********************************************************************/
45 std::string CppEphem::TtUt1HistFile(void)
46 {
48 }
49 
50 
51 /**********************************************************************/
56 std::string CppEphem::TtUt1PredFile(void)
57 {
59 }
60 
61 
62 /**********************************************************************/
67 void CppEphem::SetNutationFile(const std::string& filename)
68 {
70 }
71 
72 
73 /**********************************************************************/
78 void CppEphem::SetTtUt1HistFile(const std::string& filename)
79 {
81 }
82 
83 
84 /**********************************************************************/
89 void CppEphem::SetTtUt1PredFile(const std::string& filename)
90 {
92 }
93 
94 
95 /**********************************************************************/
100 void CppEphem::CorrectionsInterp(bool set_interp)
101 {
102  CppEphem::corrections.SetInterp(set_interp);
103 }
104 
105 
106 /**********************************************************************/
112 double CppEphem::dut1(const double& mjd)
113 {
114  double dut1(0.0);
115 
116  // Fill dut1 if support dir has been defined
118 
119  return dut1;
120 }
121 
122 /**********************************************************************/
124 double CppEphem::dut1Error(const double& mjd)
125 {
126  return 0.0;
127 }
128 
129 /**********************************************************************/
134 double CppEphem::dut1Calc(const double& mjd)
135 {
136  // There's a formula that could be used for calculating this value,
137  // but I'm a bit lazy at the moment and since the correction is
138  // very small, I'm just going to return 0 for the time being.
139  return 0.0 ;
140 }
141 
142 
143 /**********************************************************************/
149 double CppEphem::xp(const double& mjd)
150 {
151  return corrections.xpolar(mjd) ;
152 }
153 
154 
155 /**********************************************************************/
161 double CppEphem::yp(const double& mjd)
162 {
163  return corrections.ypolar(mjd);
164 }
165 
166 
167 /**********************************************************************/
173 double CppEphem::deps(const double& mjd)
174 {
175  return corrections.deps(mjd);
176 }
177 
178 
179 /**********************************************************************/
185 double CppEphem::dpsi(const double& mjd)
186 {
187  return corrections.dpsi(mjd);
188 }
189 
190 
191 /**********************************************************************/
197 double CppEphem::ttut1(const double& mjd)
198 {
199  return corrections.ttut1(mjd);
200 }
201 
202 
203 /**********************************************************************/
210 void CppEphem::StrOpt::split(const std::string& s,
211  const char& delim,
212  std::vector<std::string>* elems)
213 {
214  std::stringstream ss(s);
215  std::string item=std::string();
216  while (std::getline(ss, item, delim)) {
217  elems->push_back(item);
218  }
219 }
220 
221 
222 /**********************************************************************/
225 std::vector<std::string> CppEphem::StrOpt::split(const std::string& s,
226  const char& delim)
227 {
228  std::vector<std::string> elems;
229  split(s, delim, &elems);
230  return elems;
231 }
232 
233 
234 /**********************************************************************/
240 template <typename T>
241 std::string CppEphem::StrOpt::join(const std::vector<T>& values,
242  const char& delim)
243 {
244  // Assemble the first value in the string
245  std::ostringstream ss;
246  if (values.size() > 0) {
247  ss << values[0];
248  }
249 
250  // Now append the rest
251  for (int i=1; i<values.size(); i++) {
252  ss << delim << values[i];
253  }
254 
255  return ss.str();
256 }
257 // Define the typical use cases of CppEphem::StrOpt::join
258 template std::string CppEphem::StrOpt::join<std::string>(
259  const std::vector<std::string>&, const char&);
260 template std::string CppEphem::StrOpt::join<double>(
261  const std::vector<double>&, const char&);
262 
263 
264 
265 /**********************************************************************/
268 std::string CppEphem::StrOpt::join_angle(const std::vector<double>& values,
269  const char& delim)
270 {
271  // Make sure there are only three values
272  double sec = values[2];
273  if (values.size() == 4) {
274  sec += values[3];
275  }
276 
277  // Assemble the string using the specified delimiter
278  std::ostringstream ss;
279  ss << std::setfill('0') << std::setw(2) << int(values[0]);
280  ss << delim;
281  ss << std::setfill('0') << std::setw(2) << int(values[1]);
282  ss << delim;
283  ss << std::setfill('0') << std::setw(11) << std::fixed
284  << std::setprecision(8) << sec;
285 
286  return std::string(ss.str());
287 }
CppEphem::SetNutationFile
void SetNutationFile(const std::string &filename)
Set the name of the file to use for defining the nutation corrections.
Definition: CENamespace.cpp:66
CppEphem::NutationFile
std::string NutationFile(void)
Return the name of the file used for defining the corrections.
Definition: CENamespace.cpp:33
CppEphem::StrOpt::join
std::string join(const std::vector< T > &values, const char &delim)
Method for joining a vector of values based on some delimiter into a string.
Definition: CENamespace.cpp:240
CECorrections::dut1
double dut1(const double &mjd) const
Return the DUT1 correction parameter (represents UT1 - UTC in seconds)
Definition: CECorrections.cpp:79
CENamespace.h
CECorrections::SetTtUt1PredFile
void SetTtUt1PredFile(const std::string &filename)
Sets the name of the predicted values TT-UT1 corrections file.
Definition: CECorrections.cpp:213
CppEphem::yp
double yp(const double &mjd)
Polar motion (x) for a given modified julian date (radians)
Definition: CENamespace.cpp:160
CppEphem::deps
double deps(const double &mjd)
Earth obliquity correction for a given modified julian date (radians)
Definition: CENamespace.cpp:172
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
CppEphem::TtUt1HistFile
std::string TtUt1HistFile(void)
Return the name of the file used for defining the corrections.
Definition: CENamespace.cpp:44
CppEphem::StrOpt::join_angle
std::string join_angle(const std::vector< double > &values, const char &delim)
Method for splitting a string based on some delimiter into a vector of strings.
Definition: CENamespace.cpp:267
CppEphem::dpsi
double dpsi(const double &mjd)
Earth longitude correction for a given modified julian date (radians)
Definition: CENamespace.cpp:184
CECorrections::xpolar
double xpolar(const double &mjd) const
Return the x-polar motion correction parameter (radians)
Definition: CECorrections.cpp:95
CECorrections::ttut1
double ttut1(const double &mjd) const
Return the TT-UT1 correction at a given date (in seconds)
Definition: CECorrections.cpp:159
CppEphem::SetTtUt1PredFile
void SetTtUt1PredFile(const std::string &filename)
Set the name of the file to use for defining the predicted TT-UT1 corrections.
Definition: CENamespace.cpp:88
CppEphem::dut1Calc
double dut1Calc(const double &mjd)
Set the time from a vector representing Greenwich Apparent Sidereal Time.
Definition: CENamespace.cpp:133
CECorrections::SetTtUt1HistFile
void SetTtUt1HistFile(const std::string &filename)
Sets the name of the historic values TT-UT1 corrections file.
Definition: CECorrections.cpp:202
CppEphem::dut1Error
double dut1Error(const double &mjd=51544.5)
Definition: CENamespace.cpp:123
CppEphem::TtUt1PredFile
std::string TtUt1PredFile(void)
Return the name of the file used for defining the corrections.
Definition: CENamespace.cpp:55
CECorrections::NutationFile
std::string NutationFile(void) const
Returns the name of the nutation corrections file.
Definition: CECorrections.h:107
CECorrections::ypolar
double ypolar(const double &mjd) const
Return the y-polar motion correction parameter (radians)
Definition: CECorrections.cpp:111
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
CppEphem::CorrectionsInterp
void CorrectionsInterp(bool set_interp)
Set the corrections object to use interpolation.
Definition: CENamespace.cpp:99
CECorrections::TtUt1HistFile
std::string TtUt1HistFile(void) const
Returns the name of the historic TT-UT1 corrections file.
Definition: CECorrections.h:119
CppEphem::dut1
double dut1(const double &mjd)
Return dut1 based on a given modified julian date (seconds)
Definition: CENamespace.cpp:111
CECorrections::TtUt1PredFile
std::string TtUt1PredFile(void) const
Returns the name of the precited TT-UT1 corrections file.
Definition: CECorrections.h:131
CppEphem::StrOpt::split
void split(const std::string &s, const char &delim, std::vector< std::string > *elems)
Method for splitting a string based on some delimiter into a vector of strings.
Definition: CENamespace.cpp:209
CppEphem::ttut1
double ttut1(const double &mjd)
TT-UT1 correction for a given MJD (seconds)
Definition: CENamespace.cpp:196
CppEphem::SetTtUt1HistFile
void SetTtUt1HistFile(const std::string &filename)
Set the name of the file to use for defining the historic TT-UT1 corrections.
Definition: CENamespace.cpp:77
CppEphem::xp
double xp(const double &mjd)
Polar motion (x) for a given modified julian date (radians)
Definition: CENamespace.cpp:148
CppEphem::corrections
static CECorrections corrections
Definition: CENamespace.h:111