Changeset 18966 for trunk/FACT++/src/Time.cc
- Timestamp:
- 04/04/18 17:53:02 (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/FACT++/src/Time.cc
r18820 r18966 27 27 #include "Time.h" 28 28 29 #ifdef HAVE_LIBNOVA30 #include "../externals/nova.h"31 #endif32 33 29 using namespace std; 34 30 using namespace boost::posix_time; 31 32 #ifdef HAVE_LIBNOVA 33 #include "externals/nova.h" 34 #endif 35 35 36 36 const boost::gregorian::date Time::fUnixOffset(1970, 1, 1); … … 303 303 //! @returns 304 304 //! The time of the previous sun-rise, relative to given horizon in degree, 305 //! for the coordinates of the ORM, La Palma. 306 //! if libnova was not compiled in, it will return the next noon. 305 //! for the observatory location given (see nova.h). 306 //! If the sun is circumpolar, it simply return the intgeral fraction of 307 //! the current MJD. 308 //! If libnova was not compiled in, it will return the next noon. 307 309 //! 308 310 //! @throws 309 //! a runtime_error exception is thrown if the calculation of the sun-rise 310 //! by libnova fails (this would happen if libnova thinks the sun is 311 //! circumpolar which should never happen at La Palma) 312 // 313 Time Time::GetPrevSunRise(double horizon) const 311 //! A runtime_error exception is thrown if the observatory location 312 //! is not defined (see nova.h) 313 // 314 Time Time::GetPrevSunRise(double horizon, const string &obs) const 314 315 { 315 316 #ifdef HAVE_LIBNOVA 316 Nova::LnLatPosn obs = Nova::kORM; 317 const Nova::LnLatPosn posn(obs); 318 if (!posn.isValid()) 319 throw runtime_error("Observatory location '"+obs+"' unknown."); 317 320 318 321 ln_rst_time sun_day; 319 if (ln_get_solar_rst_horizon(JD()-0.5, &obs, horizon, &sun_day)==1)320 throw runtime_error("ln_get_solar_rst_horizon reported the sun to be circumpolar at the coordinates of La Palma!");322 if (ln_get_solar_rst_horizon(JD()-0.5, const_cast<Nova::LnLatPosn*>(&posn), horizon, &sun_day)==1) 323 return Time(floor(Mjd())); 321 324 322 325 if (Time(sun_day.rise)<*this) 323 326 return Time(sun_day.rise); 324 327 325 if (ln_get_solar_rst_horizon(JD()-1.5, &obs, horizon, &sun_day)==1)326 throw runtime_error("ln_get_solar_rst_horizon reported the sun to be circumpolar at the coordinates of La Palma!");328 if (ln_get_solar_rst_horizon(JD()-1.5, const_cast<Nova::LnLatPosn*>(&posn), horizon, &sun_day)==1) 329 return Time(floor(Mjd())); 327 330 328 331 return Time(sun_day.rise); … … 336 339 //! @returns 337 340 //! The time of the next sun-rise, relative to given horizon in degree, 338 //! for the coordinates of the ORM, La Palma. 339 //! if libnova was not compiled in, it will return the next noon. 341 //! for the observatory location given (see nova.h). 342 //! If the sun is circumpolar, it simply return the intgeral fraction of 343 //! the current MJD+1. 344 //! If libnova was not compiled in, it will return the next noon. 340 345 //! 341 346 //! @throws 342 //! a runtime_error exception is thrown if the calculation of the sun-rise 343 //! by libnova fails (this would happen if libnova thinks the sun is 344 //! circumpolar which should never happen at La Palma) 345 // 346 Time Time::GetNextSunRise(double horizon) const 347 //! A runtime_error exception is thrown if the observatory location 348 //! is not defined (see nova.h) 349 // 350 Time Time::GetNextSunRise(double horizon, const string &obs) const 347 351 { 348 352 #ifdef HAVE_LIBNOVA 349 Nova::LnLatPosn obs = Nova::kORM; 353 const Nova::LnLatPosn posn(obs); 354 if (!posn.isValid()) 355 throw runtime_error("Observatory location '"+obs+"' unknown."); 350 356 351 357 ln_rst_time sun_day; 352 if (ln_get_solar_rst_horizon(JD()-0.5, &obs, horizon, &sun_day)==1)353 throw runtime_error("ln_get_solar_rst_horizon reported the sun to be circumpolar at the coordinates of La Palma!");358 if (ln_get_solar_rst_horizon(JD()-0.5, const_cast<Nova::LnLatPosn*>(&posn), horizon, &sun_day)==1) 359 return Time(floor(Mjd())+1); 354 360 355 361 if (Time(sun_day.rise)>=*this) 356 362 return Time(sun_day.rise); 357 363 358 if (ln_get_solar_rst_horizon(JD()+0.5, &obs, horizon, &sun_day)==1)359 throw runtime_error("ln_get_solar_rst_horizon reported the sun to be circumpolar at the coordinates of La Palma!");364 if (ln_get_solar_rst_horizon(JD()+0.5, const_cast<Nova::LnLatPosn*>(&posn), horizon, &sun_day)==1) 365 return Time(floor(Mjd())+1); 360 366 361 367 return Time(sun_day.rise); 362 368 #else 363 return Time(floor(Mjd()+0.5) )+0.5;369 return Time(floor(Mjd()+0.5)+0.5); 364 370 #endif 365 371 } … … 369 375 //! Calls GetPrevSunRise(LN_SOLAR_STANDART_HORIZON) 370 376 // 371 Time Time::GetPrevSunRise() const 372 { 373 return GetPrevSunRise(LN_SOLAR_STANDART_HORIZON); 377 Time Time::GetPrevSunRise(const string &obs) const 378 { 379 #ifdef HAVE_LIBNOVA 380 return GetPrevSunRise(LN_SOLAR_STANDART_HORIZON, obs); 381 #else 382 return GetPrevSunRise(-0.8333, obs); 383 #endif 374 384 } 375 385 … … 378 388 //! Calls GetNextSunRise(LN_SOLAR_STANDART_HORIZON) 379 389 // 380 Time Time::GetNextSunRise() const 381 { 382 return GetNextSunRise(LN_SOLAR_STANDART_HORIZON); 390 Time Time::GetNextSunRise(const string &obs) const 391 { 392 #ifdef HAVE_LIBNOVA 393 return GetNextSunRise(LN_SOLAR_STANDART_HORIZON, obs); 394 #else 395 return GetNextSunRise(-0.8333, obs); 396 #endif 383 397 } 384 398 … … 395 409 //! 24h period between two noon's. 396 410 // 397 uint32_t Time::NightAsInt( ) const398 { 399 const Time tm = GetPrevSunRise( );411 uint32_t Time::NightAsInt(const string &obs) const 412 { 413 const Time tm = GetPrevSunRise(obs); 400 414 return tm.Y()*10000 + tm.M()*100 + tm.D(); 401 415 }
Note:
See TracChangeset
for help on using the changeset viewer.