CppEphem
CENamespace.h
Go to the documentation of this file.
1 /***************************************************************************
2  * CENamespace.h: 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 #ifndef CENamespace_h
23 #define CENamespace_h
24 
25 #include <cmath>
26 #include <map>
27 #include <sofa.h>
28 #include <memory>
29 #include "CECorrections.h"
30 
31 
32 // Create a namespace with some useful stuff
33 namespace CppEphem {
34  // Define an angle type so that we can differentiate between degrees or radians
35 
36  // Approximate temperature at sea-level in Kelvin
37  inline double SeaLevelTemp_K() {return 288.2 ;}
38  inline double SeaLevelTemp_C() {return SeaLevelTemp_K()-273.15 ;}
39  inline double SeaLevelTemp_F() {return (1.8*SeaLevelTemp_C())+32.0 ;}
40 
41  // Temperature conversion methods
42  inline double Temp_C2F(const double& temp_C) {return (1.8 * temp_C) + 32.0;}
43  inline double Temp_C2K(const double& temp_C) {return temp_C+273.15;}
44  inline double Temp_F2C(const double& temp_F) {return (temp_F - 32.0)/1.8;}
45  inline double Temp_F2K(const double& temp_F) {return Temp_C2K(Temp_F2C(temp_F));}
46  inline double Temp_K2C(const double& temp_K) {return temp_K - 273.15;}
47  inline double Temp_K2F(const double& temp_K) {return 1.8*temp_K-459.67;}
48 
49  // Some constants taken from the sofa dictionary, but with some more discriptive names
50  inline double julian_date_J2000() {return DJ00 ;}
51  inline double c() {return DC * DAU / DAYSEC ;}
52  inline double c_au_per_day() {return DC ;}
53  inline double m_per_au() {return DAU ;}
54  inline double sec_per_day() {return DAYSEC;}
55 
56  /*********************************************
57  * Return the 'dut1' value which represents
58  * 'UT1-UTC' for a given MJD or it's error
59  *********************************************/
60  double dut1(const double& mjd) ;
61  double dut1Error(const double& mjd=51544.5) ;
62  double dut1Calc(const double& mjd) ;
63 
64  /*********************************************
65  * Polar Motion methods
66  * For the moment, 0.0 should be sufficient. This
67  * assumption may need to be revisited
68  *********************************************/
69  double xp(const double& mjd);
70  double yp(const double& mjd);
71 
72  /*********************************************
73  * Earth longitude & obliquity correction
74  *********************************************/
75  double deps(const double& mjd);
76  double dpsi(const double& mjd);
77 
78  /*********************************************
79  * TT-UT1 correction
80  *********************************************/
81  double ttut1(const double& mjd);
82 
84  inline double EstimateAltitude_m(double pressure_hPa)
85  {return -29.3 * SeaLevelTemp_K() * std::log(pressure_hPa/1013.25) ;}
87  inline double EstimatePressure_hPa(double elevation_m)
88  {return 1013.25 * std::exp(-elevation_m / (29.3*SeaLevelTemp_K() )) ;}
89 
90  // Methods for getting the corrections values
91  std::string NutationFile(void);
92  std::string TtUt1HistFile(void);
93  std::string TtUt1PredFile(void);
94  void SetNutationFile(const std::string& filename);
95  void SetTtUt1HistFile(const std::string& filename);
96  void SetTtUt1PredFile(const std::string& filename);
97  void CorrectionsInterp(bool set_interp);
99 
100  namespace StrOpt {
101  // Method for splitting a string based on some delimiter into a vector of strings
102  void split(const std::string& s,
103  const char& delim,
104  std::vector<std::string>* elems);
105  std::vector<std::string> split(const std::string& s,
106  const char& delim);
107 
108  // Join strings using a set delimiter
109  template<typename T>
110  std::string join(const std::vector<T>& values,
111  const char& delim);
112  std::string join_angle(const std::vector<double>& values,
113  const char& delim);
114  }
115 }
116 
117 #endif /* CENamespace_h */
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
CppEphem
Definition: CENamespace.h:32
CppEphem::yp
double yp(const double &mjd)
Polar motion (x) for a given modified julian date (radians)
Definition: CENamespace.cpp:160
CppEphem::Temp_C2F
double Temp_C2F(const double &temp_C)
Definition: CENamespace.h:59
CppEphem::c
double c()
speed of light (meters/second)
Definition: CENamespace.h:68
CECorrections
Definition: CECorrections.h:28
CppEphem::deps
double deps(const double &mjd)
Earth obliquity correction for a given modified julian date (radians)
Definition: CENamespace.cpp:172
CppEphem::sec_per_day
double sec_per_day()
Seconds per day.
Definition: CENamespace.h:71
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
CppEphem::SeaLevelTemp_C
double SeaLevelTemp_C()
Definition: CENamespace.h:55
CppEphem::Temp_F2K
double Temp_F2K(const double &temp_F)
Definition: CENamespace.h:62
CppEphem::julian_date_J2000
double julian_date_J2000()
Julian Date corresponding to J2000.
Definition: CENamespace.h:67
CppEphem::SeaLevelTemp_K
double SeaLevelTemp_K()
Definition: CENamespace.h:54
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
CppEphem::Temp_F2C
double Temp_F2C(const double &temp_F)
Definition: CENamespace.h:61
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
CppEphem::Temp_K2C
double Temp_K2C(const double &temp_K)
Definition: CENamespace.h:63
CppEphem::EstimatePressure_hPa
double EstimatePressure_hPa(double elevation_m)
Method for estimating atmospheric pressure (in hPa) from altitude (in meters)
Definition: CENamespace.h:100
CppEphem::c_au_per_day
double c_au_per_day()
speed of light (astronomical units)/day
Definition: CENamespace.h:69
CppEphem::Temp_K2F
double Temp_K2F(const double &temp_K)
Definition: CENamespace.h:64
CppEphem::CorrectionsInterp
void CorrectionsInterp(bool set_interp)
Set the corrections object to use interpolation.
Definition: CENamespace.cpp:99
CppEphem::SeaLevelTemp_F
double SeaLevelTemp_F()
Definition: CENamespace.h:56
CppEphem::dut1
double dut1(const double &mjd)
Return dut1 based on a given modified julian date (seconds)
Definition: CENamespace.cpp:111
CppEphem::m_per_au
double m_per_au()
meters per astronomical unit
Definition: CENamespace.h:70
CppEphem::Temp_C2K
double Temp_C2K(const double &temp_C)
Definition: CENamespace.h:60
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
CECorrections.h
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
CppEphem::EstimateAltitude_m
double EstimateAltitude_m(double pressure_hPa)
Method for estimating altitude (in meters) from atmospheric pressure (in hPa)
Definition: CENamespace.h:97