1 #include <libnova/solar.h> 2 #include <libnova/lunar.h> 3 #include <libnova/rise_set.h> 4 #include <libnova/transform.h> 42 const double JD = time.
JD();
44 ln_lnlat_posn observer;
49 ln_get_lunar_rst(JD-0.5, &observer, &moon);
51 fRise =
Time(moon.rise);
52 fTransit =
Time(moon.transit);
53 fSet =
Time(moon.set);
59 const bool is_up = JD>moon.rise;
60 const bool is_sinking = JD>moon.transit;
61 const bool is_dn = JD>moon.set;
63 ln_get_lunar_rst(JD+0.5, &observer, &moon);
65 fRise =
Time(moon.rise);
67 fTransit =
Time(moon.transit);
69 fSet =
Time(moon.set);
72 ln_get_lunar_equ_coords(JD, &pos);
75 ln_get_hrz_from_equ (&pos, &observer, JD, &hrz);
82 disk = ln_get_lunar_disk(JD)*100;
84 if (fRise <fTransit && fRise <fSet) state = 0;
85 if (fTransit<fSet && fTransit<fRise) state = 1;
86 if (fSet <fRise && fSet <fTransit) state = 2;
95 double Angle(
double r,
double d)
const 97 const double theta0 = M_PI/2-d*M_PI/180;
98 const double phi0 = r*M_PI/12;
100 const double theta1 = M_PI/2-dec*M_PI/180;
101 const double phi1 = ra*M_PI/12;
103 const double x0 = sin(theta0) * cos(phi0);
104 const double y0 = sin(theta0) * sin(phi0);
105 const double z0 = cos(theta0);
107 const double x1 = sin(theta1) * cos(phi1);
108 const double y1 = sin(theta1) * sin(phi1);
109 const double z1 = cos(theta1);
111 double arg = x0*x1 + y0*y1 + z0*z1;
112 if(arg > 1.0) arg = 1.0;
113 if(arg < -1.0) arg = -1.0;
115 return acos(arg) * 180/M_PI;
125 po::options_description control(
"Smart FACT");
126 control.add_options()
127 (
"ra", var<double>(),
"Source right ascension")
128 (
"dec", var<double>(),
"Source declination")
129 (
"date-time", var<string>()
130 #
if BOOST_VERSION >= 104200
136 po::positional_options_description p;
137 p.add(
"date-time", 1);
146 "moon - The moon calculator\n" 148 "Usage: moon sql-datetime [--ra={ra} --dec={dec}]\n";
152 int main(
int argc,
const char* argv[])
161 if (conf.
Has(
"ra")^conf.
Has(
"dec"))
163 cout <<
"ERROR - Either --ra or --dec missing." << endl;
170 ln_lnlat_posn observer;
171 observer.lng = -(17.+53./60+26.525/3600);
172 observer.lat = 28.+45./60+42.462/3600;
174 Moon moon(observer.lng, observer.lat, time);
176 cout << setprecision(15);
181 ln_get_solar_equ_coords(time.
JD(), &pos);
182 ln_get_hrz_from_equ(&pos, &observer, time.
JD(), &hrz);
183 cout << 90-hrz.alt <<
'\n';
185 const double kSynMonth = 29.53058868;
186 const double kEpoch0 = 44240.37917;
187 const double kInstall = 393;
188 const uint32_t
period = floor(((time.
Mjd()-kEpoch0)/kSynMonth-kInstall));
190 cout << period <<
'\n';
192 cout << moon.
disk <<
'\n';
193 cout << moon.
zd <<
'\n';
195 if (conf.
Has(
"ra") && conf.
Has(
"dec"))
197 pos.ra = conf.
Get<
double>(
"ra")*15;
198 pos.dec = conf.
Get<
double>(
"dec");
200 cout << moon.
Angle(pos.ra/15, pos.dec) <<
'\n';
207 cout << moon.
Angle(pos.ra/15, pos.dec) <<
'\n';
void SetupConfiguration(Configuration &conf)
Adds some functionality to boost::posix_time::ptime for our needs.
void SetPrintUsage(const std::function< void(void)> &func)
T Get(const std::string &var)
int main(int argc, const char *argv[])
void SetArgumentPositions(const po::positional_options_description &desc)
bool Has(const std::string &var)
void AddOptions(const po::options_description &opt, bool visible=true)
Warning because the service this data corrsponds to might have been last updated longer ago than Local time
Commandline parsing, resource file parsing and database access.
void SetFromStr(const std::string &str, const char *fmt="%Y-%m-%d %H:%M:%S")
Moon(double lon, double lat, const Time &t=Time())
double Angle(double r, double d) const
std::string GetAsStr(const char *fmt="%Y-%m-%d %H:%M:%S") const
bool DoParse(int argc, const char **argv, const std::function< void()> &func=std::function< void()>())