CppEphem
cirs2icrs.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  * cirs2icrs.cpp: 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 
26 #include <stdio.h>
27 #include "CEExecOptions.h"
28 
29 #include "CppEphem.h"
30 
31 /**********************************************************************/
35 {
36  CEExecOptions opts("cirs2icrs");
37 
38  // Add version and description
39  opts.AddProgramDescription(std::string() +
40  "Converts from CIRS (Earth centric) coordinates to ICRS (solar " +
41  "system barycentric) coordinates for a given Julian date.");
42 
43  // Set the options
44  opts.AddCirsPars();
45  opts.AddJDPar();
46 
47  return opts;
48 }
49 
50 /**********************************************************************/
53 void PrintResults(const CESkyCoord& input,
54  const CESkyCoord& output,
55  double jd)
56 {
57  std::vector<double> input_hms = input.XCoord().HmsVect();
58  std::vector<double> output_hms = output.XCoord().HmsVect();
59 
60  std::printf("\n") ;
61  std::printf("**********************************************\n") ;
62  std::printf("* Results of CIRS -> ICRS *\n") ;
63  std::printf("**********************************************\n") ;
64  std::printf("ICRS Coordinates (output)\n") ;
65  std::printf(" Julian Date : %f\n", jd) ;
66  std::printf(" Right Ascension: %02dh %02dm %04.1fs (%f deg)\n",
67  int(output_hms[0]), int(output_hms[1]), output_hms[2]+output_hms[3],
68  output.XCoord().Deg()) ;
69  std::printf(" Declination : %+f degrees\n", output.YCoord().Deg()) ;
70  std::printf("CIRS Coordinates (input)\n") ;
71  std::printf(" Right Ascension: %02dh %02dm %04.1fs (%f deg)\n",
72  int(input_hms[0]), int(input_hms[1]), input_hms[2]+input_hms[3],
73  input.XCoord().Deg()) ;
74  std::printf(" Declination : %+f degrees\n", input.YCoord().Deg()) ;
75  std::printf("\n") ;
76 }
77 
78 
79 /**********************************************************************/
82 int main (int argc, char** argv)
83 {
84  // Get the options from the command line
85  CEExecOptions opts = DefineOpts() ;
86  if (opts.ParseCommandLine(argc, argv)) return 0 ;
87 
88  // Create a CECoordinates object
89  CESkyCoord input(CEAngle::Deg(opts.AsDouble("ra")),
90  CEAngle::Deg(opts.AsDouble("dec")),
92 
93  // Get the coordinates as CIRS
94  CESkyCoord output = input.ConvertToICRS(opts.AsDouble("juliandate")) ;
95 
96  // Print the result
97  PrintResults(input, output, opts.AsDouble("juliandate")) ;
98 }
CESkyCoordType::CIRS
RA, Dec (referenced at the center of the Earth)
CESkyCoord
Definition: CESkyCoord.h:49
CEExecOptions.h
CEAngle::HmsVect
std::vector< double > HmsVect(void) const
Return vector of doubles representing the {hours, min, sec, sec-fraction}.
Definition: CEAngle.cpp:199
CppEphem.h
DefineOpts
CEExecOptions DefineOpts()
Define the command line options for this program.
Definition: cirs2icrs.cpp:33
CEAngle::Deg
double Deg(void) const
Return angle in degrees as a double.
Definition: CEAngle.cpp:328
main
int main(int argc, char **argv)
MAIN.
Definition: cirs2icrs.cpp:81
PrintResults
void PrintResults(const CESkyCoord &input, const CESkyCoord &output, double jd)
Print the results of the conversion.
Definition: cirs2icrs.cpp:52
CEAngle::Deg
static CEAngle Deg(const double &angle)
Return angle (radians) constructed from a degree angle.
Definition: CEAngle.cpp:317
CEExecOptions
Definition: CEExecOptions.h:9
CESkyCoord::ConvertToICRS
CESkyCoord ConvertToICRS(const CEDate &date=CEDate(), const CEObserver &observer=CEObserver())
Convert this coordinate to ICRS coordinates.
Definition: CESkyCoord.cpp:854
CESkyCoord::XCoord
virtual CEAngle XCoord(const CEDate &jd=CppEphem::julian_date_J2000()) const
Return x coordinate at given Julian date.
Definition: CESkyCoord.h:227
CESkyCoord::YCoord
virtual CEAngle YCoord(const CEDate &jd=CppEphem::julian_date_J2000()) const
Return y coordinate at given Julian date.
Definition: CESkyCoord.h:240