CppEphem
icrs2cirs.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  * icrs2cirs.cpp: CppEphem *
3  * ----------------------------------------------------------------------- *
4  * Copyright © 2017-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("icrs2cirs");
37 
38  // Add version and description
39  opts.AddProgramDescription(std::string() +
40  "Converts from ICRS (solar system barycentric) coordinates to CIRS " +
41  "(Earth centric) coordinates for a given Julian date.");
42 
43  // Set the options
44  opts.AddIcrsPars();
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 ICRS -> CIRS *\n") ;
63  std::printf("**********************************************\n") ;
64  std::printf("CIRS 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("ICRS 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 CESkyCoord object
89  CESkyCoord icrs_coords(CEAngle::Deg(opts.AsDouble("ra")),
90  CEAngle::Deg(opts.AsDouble("dec")),
92 
93  // Get the coordinates as CIRS
94  CESkyCoord cirs_coords = icrs_coords.ConvertToCIRS(opts.AsDouble("juliandate"));
95 
96  // Print the result
97  PrintResults(icrs_coords, cirs_coords, opts.AsDouble("juliandate")) ;
98 
99  return 0;
100 }
main
int main(int argc, char **argv)
MAIN.
Definition: icrs2cirs.cpp:81
CESkyCoordType::ICRS
RA, Dec (referenced at the barycenter of the solarsystem)
CESkyCoord::ConvertToCIRS
CESkyCoord ConvertToCIRS(const CEDate &date=CEDate(), const CEObserver &observer=CEObserver())
Convert this coordinate to CIRS coordinates.
Definition: CESkyCoord.cpp:817
DefineOpts
CEExecOptions DefineOpts()
Define the command line options for this program.
Definition: icrs2cirs.cpp:33
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
PrintResults
void PrintResults(const CESkyCoord &input, const CESkyCoord &output, double jd)
Print the results of the conversion.
Definition: icrs2cirs.cpp:52
CppEphem.h
CEAngle::Deg
double Deg(void) const
Return angle in degrees as a double.
Definition: CEAngle.cpp:328
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::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