test_EO_SOFA.cpp
Go to the documentation of this file.
1 //==============================================================================
2 //
3 // This file is part of GNSSTk, the ARL:UT GNSS Toolkit.
4 //
5 // The GNSSTk is free software; you can redistribute it and/or modify
6 // it under the terms of the GNU Lesser General Public License as published
7 // by the Free Software Foundation; either version 3.0 of the License, or
8 // any later version.
9 //
10 // The GNSSTk is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU Lesser General Public License for more details.
14 //
15 // You should have received a copy of the GNU Lesser General Public
16 // License along with GNSSTk; if not, write to the Free Software Foundation,
17 // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
18 //
19 // This software was developed by Applied Research Laboratories at the
20 // University of Texas at Austin.
21 // Copyright 2004-2022, The Board of Regents of The University of Texas System
22 //
23 //==============================================================================
24 
25 //==============================================================================
26 //
27 // This software was developed by Applied Research Laboratories at the
28 // University of Texas at Austin, under contract to an agency or agencies
29 // within the U.S. Department of Defense. The U.S. Government retains all
30 // rights to use, duplicate, distribute, disclose, or release this software.
31 //
32 // Pursuant to DoD Directive 523024
33 //
34 // DISTRIBUTION STATEMENT A: This software has been approved for public
35 // release, distribution is unlimited.
36 //
37 //==============================================================================
38 
43 
44 // system includes
45 #include <string>
46 // gnsstk
47 #include "Exception.hpp"
48 #include "GNSSconstants.hpp"
49 #include "Matrix.hpp"
50 // geomatics
51 #include "EphTime.hpp"
52 #include "CommandLine.hpp"
53 #include "SolarSystem.hpp"
54 #include "EarthOrientation.hpp"
55 #include "logstream.hpp"
56 
57 using namespace std;
58 using namespace gnsstk;
59 using namespace StringUtils;
60 
61 
62 
63 static const string testVersion("1.0 5/19/17");
64 
65 
66 
67 
68 
69 int main(int argc, char **argv)
70 {
71  try
72 {
73  int i;
74  EarthOrientation nGF96;
75  EarthOrientation nGF03;
76  EarthOrientation nGF10;
77  nGF96.convention = IERSConvention::IERS1996;
78  nGF03.convention = IERSConvention::IERS2003;
79  nGF10.convention = IERSConvention::IERS2010;
80 
81  // sofa example section 5 of "SOFA Tools for Earth Attitude"
82 
83  // turn on debug7 so we get output of intermediate quantities
84  // from within class EO
85  LOGlevel = ConfigureLOG::Level("DEBUG7");
86 
87  // define input
88  //ttag.setYMDHMS(2007,4,5,12,0,0.0,TimeSystem::UTC);
89  double mjd = 54195.5; // UTC
90  EphTime ttag;
91  ttag.setMJD(static_cast<long double>(54195.5));
92  ttag.setTimeSystem(TimeSystem::UTC);
93  double UT1mUTC,xp,yp;
94  UT1mUTC = -0.072073685; // sec
95  xp = 0.0349282; // arcsec
96  yp = 0.4833163; // arcsec
97 
98  LOG(INFO) << "Test EarthOrientation";
99  LOG(INFO) << "Epoch 2007/ 4/ 5 12: 0:0.000 UTC";
100  LOG(INFO) << "Polar angles xp yp = " << fixed << setprecision(7)
101  << xp << " " << yp << " arcsec";
102  LOG(INFO) << "UT1-UTC = " << fixed << setprecision(9) << UT1mUTC;
103 
104  // units - don't do this, ARL:UT code takes them in arcsec
105  //xp *= EarthOrientation::ARCSEC_TO_RAD; // rad
106  //yp *= EarthOrientation::ARCSEC_TO_RAD; // rad
107 
108  // time tags
109  double UT1=mjd+UT1mUTC/SEC_PER_DAY;
110  double dt = getTimeSystemCorrection(TimeSystem::UTC,TimeSystem::TAI,2007,
111  4,5.5);
112  double TAI=mjd+dt/SEC_PER_DAY;
113  dt = getTimeSystemCorrection(TimeSystem::UTC,TimeSystem::TT,2007,4,5.5);
114  double TT =mjd+dt/SEC_PER_DAY;
115  LOG(INFO) << fixed
116  << setprecision(1) << "Times: UTC " << MJD_TO_JD << " + "
117  << setprecision(15) << setw(21) << mjd << endl
118  << setprecision(1) << " TAI " << MJD_TO_JD << " + "
119  << setprecision(15) << setw(21) << TAI << endl
120  << setprecision(1) << " TT " << MJD_TO_JD << " + "
121  << setprecision(15) << setw(21) << TT << endl
122  << setprecision(1) << " UT1 " << MJD_TO_JD << " + "
123  << setprecision(15) << setw(21) << UT1;
124 
125  Matrix<double> M;
126 
127  LOG(INFO) << "\nIERS 1996 / IAU 1976/1980 "
128  << "------------------------------------------"
129  << "\n\nNO Adjustments made";
130  nGF96.xp = xp; nGF96.yp = yp; nGF96.UT1mUTC = UT1mUTC;
131  M = nGF96.ECEFtoInertial(ttag);
132  LOG(INFO) << "\ncelestial-to-terrestrial matrix:\n" << showpos << fixed
133  << setprecision(15) << setw(18) << transpose(M);
134 
135  LOG(INFO) << "\nIERS 2003 / IAU 2000A, CIO "
136  << "-----------------------------------------"
137  << "\n\nNO Adjustments made";
138  nGF03.xp = xp; nGF03.yp = yp; nGF03.UT1mUTC = UT1mUTC;
139  M = nGF03.ECEFtoInertial(ttag);
140  LOG(INFO) << "\ncelestial-to-terrestrial matrix:\n" << showpos << fixed
141  << setprecision(15) << setw(18) << transpose(M);
142 
143  LOG(INFO) << "\nIERS 2010 / IAU 2000A, CIO "
144  << "-----------------------------------------\n"
145  << "\nUsing XY series\n"
146  << "\nNO Adjustments made\n";
147  nGF10.xp = xp; nGF10.yp = yp; nGF10.UT1mUTC = UT1mUTC;
148  M = nGF10.ECEFtoInertial(ttag);
149  LOG(INFO) << "\ncelestial-to-terrestrial matrix:\n" << showpos << fixed
150  << setprecision(15) << setw(18) << transpose(M);
151 
152  return 0;
153  }
154  catch(Exception& e)
155  {
156  cerr << "Exception: " << e;
157  }
158  catch (...)
159  {
160  cerr << "Unknown exception. Abort." << endl;
161  }
162  return 1;
163 } // end main()
164 
gnsstk::TimeSystem::TT
@ TT
Terrestrial time (used in IERS conventions)
example6.mjd
mjd
Definition: example6.py:102
CommandLine.hpp
EphTime.hpp
gnsstk::SEC_PER_DAY
const long SEC_PER_DAY
Seconds per day.
Definition: TimeConstants.hpp:63
gnsstk::EphTime::setTimeSystem
void setTimeSystem(TimeSystem sys)
Definition: EphTime.hpp:141
gnsstk::TimeSystem::TAI
@ TAI
International Atomic Time.
logstream.hpp
GNSSconstants.hpp
gnsstk
For Sinex::InputHistory.
Definition: BasicFramework.cpp:50
LOGlevel
#define LOGlevel
Definition: logstream.hpp:323
gnsstk::EarthOrientation::yp
double yp
Polar motion angle yp, in arcseconds.
Definition: EarthOrientation.hpp:100
gnsstk::MJD_TO_JD
const double MJD_TO_JD
Add this offset to convert Modified Julian Date to Julian Date.
Definition: TimeConstants.hpp:51
gnsstk::Exception
Definition: Exception.hpp:151
main
int main(int argc, char **argv)
Definition: test_EO_SOFA.cpp:69
gnsstk::transpose
SparseMatrix< T > transpose(const SparseMatrix< T > &M)
transpose
Definition: SparseMatrix.hpp:829
gnsstk::Matrix< double >
testVersion
static const string testVersion("1.0 5/19/17")
gnsstk::EphTime
Definition: EphTime.hpp:67
LOG
#define LOG(level)
define the macro that is used to write to the log stream
Definition: logstream.hpp:315
SolarSystem.hpp
Exception.hpp
EarthOrientation.hpp
std
Definition: Angle.hpp:142
gnsstk::INFO
@ INFO
Definition: logstream.hpp:57
gnsstk::EarthOrientation::convention
IERSConvention convention
IERS convention appropriate for this data.
Definition: EarthOrientation.hpp:106
gnsstk::EarthOrientation::ECEFtoInertial
Matrix< double > ECEFtoInertial(const EphTime &t, bool reduced=false)
Definition: EarthOrientation.cpp:1247
Matrix.hpp
gnsstk::getTimeSystemCorrection
double getTimeSystemCorrection(const TimeSystem inTS, const TimeSystem outTS, const int year, const int month, const double day)
Definition: TimeSystem.cpp:181
gnsstk::EarthOrientation
Definition: EarthOrientation.hpp:93
gnsstk::EphTime::setMJD
void setMJD(long double mjd)
Definition: EphTime.hpp:155
gnsstk::EarthOrientation::xp
double xp
Polar motion angle xp, in arcseconds.
Definition: EarthOrientation.hpp:97
gnsstk::EarthOrientation::UT1mUTC
double UT1mUTC
Time offset UT1 minus UTC, in seconds.
Definition: EarthOrientation.hpp:103


gnsstk
Author(s):
autogenerated on Wed Oct 25 2023 02:40:41