Exemplo n.º 1
0
void TestSseAstro::testTargetNoPrecessionNoProperMotion()
{
   cout << "testTargetNoPrecessionNoProperMotion" << endl;

   /* Request j2000 epoch for a target with no proper motion.
      There should be no change from the original coordinates */

   double targetRaRads(M_PI);
   double targetDecRads(M_PI/4);
   double pmRaMasYr(0);
   double pmDecMasYr(0);

   double resultRaRads;
   double resultDecRads;

   time_t epochTime(SseAstro::J2000UnixTimeSecs); 
   cout << "j2000 time: " << epochTime << endl;

   SseAstro::positionAtNewEpochAndEquinox(
      epochTime, targetRaRads, targetDecRads,
      pmRaMasYr, pmDecMasYr,
      &resultRaRads, &resultDecRads);

   cout << "Expected RA/Dec: " << endl;
   printRaRadsInHms(targetRaRads);
   printDecRadsInDms(targetDecRads);

   cout << "Got RA/Dec: " << endl;
   printRaRadsInHms(resultRaRads);
   printDecRadsInDms(resultDecRads);

   double tolRads(1e-9);

   assertDoublesEqual(targetRaRads, resultRaRads, tolRads);
   assertDoublesEqual(targetDecRads, resultDecRads, tolRads);
}
Exemplo n.º 2
0
void TestSseAstro::testTargetEpochAndEquinoxChange()
{
   cout << "testTargetEpochAndEquinoxChange" << endl;
   cout.precision(9);
   cout.setf(std::ios::fixed); 

   /*
     From Meeus, Astronomical Alg. 2nd Ed.
     Example 21.b

     Star: Theta Persei
     J2000.0 Equinox and Epoch
     RA hms = 02 44 11.986  (2.736662778 hours)
     Dec dms = +49 13 42.48 (49.228466667 deg)
     PM Ra secs/Yr (Note: *not* arcsecs) = 0.03425
     PM Dec arcsecs/Yr = -0.0895
   */

   // epoch change first (ie, proper motion change only):

   double targetRaHours(SseAstro::hoursToDecimal(02, 44, 11.986));
   double targetRaRads(SseAstro::hoursToRadians(targetRaHours));
   double targetDecDeg(SseAstro::degreesToDecimal(PlusSign, 49, 13, 42.48));
   double targetDecRads(SseAstro::degreesToRadians(targetDecDeg));

   cout << "Start RA/Dec: " << endl;
   printRaRadsInHms(targetRaRads);
   printDecRadsInDms(targetDecRads);

   // convert mu RA from secs to arcdist in mas
   double pmRaSecYr(0.03425);
   double pmRaMasYr(DegPerHour * pmRaSecYr * cos(targetDecRads) * MasPerArcSec);

   cout << "pmRaSecYr: " << pmRaSecYr <<endl;
   cout << "pmRaMasYr: " << pmRaMasYr <<endl;

   double pmDecMasYr(-0.0895 * MasPerArcSec);
   //double parallaxMas(0.0); // unused

   // New epoch: 
   time_t epochTime(1857702816); // 2028-11-13 04:33:36 UTC
   cout << "time: " << epochTime << endl;

   double resultRaRads;
   double resultDecRads;
   SseAstro::positionAtNewEpoch(epochTime, targetRaRads, targetDecRads,
                                pmRaMasYr, pmDecMasYr,
                                &resultRaRads, &resultDecRads);

   double tolRads(1e-7);

   // epoch change only 
   double expectedRaHours(SseAstro::hoursToDecimal(02, 44, 12.975));
   double expectedRaRads(SseAstro::hoursToRadians(expectedRaHours));
   double expectedDecDeg(SseAstro::degreesToDecimal(PlusSign, +49, 13, 39.90));
   double expectedDecRads(SseAstro::degreesToRadians(expectedDecDeg));

   cout << "Expected RA/Dec: " << endl;
   printRaRadsInHms(expectedRaRads);
   printDecRadsInDms(expectedDecRads);

   cout << "Got RA/Dec: " << endl;
   printRaRadsInHms(resultRaRads);
   printDecRadsInDms(resultDecRads);

   cout << "expectedRaRads: " << expectedRaRads
        << " got: " << resultRaRads << endl;

   cout << "expectedDecRads: " << expectedDecRads
        << " got: " << resultDecRads << endl;

   assertDoublesEqual(expectedRaRads, resultRaRads, tolRads);
   assertDoublesEqual(expectedDecRads, resultDecRads, tolRads);

   // New epoch and equinox
   // ----------------------
   expectedRaHours = SseAstro::hoursToDecimal(02, 46, 11.331);
   expectedRaRads = SseAstro::hoursToRadians(expectedRaHours);

   expectedDecDeg = SseAstro::degreesToDecimal(PlusSign, +49, 20, 54.54);
   expectedDecRads = SseAstro::degreesToRadians(expectedDecDeg);

   cout << "Expected RA/Dec: " << endl;
   printRaRadsInHms(expectedRaRads);
   printDecRadsInDms(expectedDecRads);

   SseAstro::positionAtNewEpochAndEquinox(
      epochTime, targetRaRads, targetDecRads,
      pmRaMasYr, pmDecMasYr,
      &resultRaRads, &resultDecRads);

   cout << "Got RA/Dec: " << endl;
   printRaRadsInHms(resultRaRads);
   printDecRadsInDms(resultDecRads);

   assertDoublesEqual(expectedRaRads, resultRaRads, tolRads);
   assertDoublesEqual(expectedDecRads, resultDecRads, tolRads);
}
 inline std::int64_t monthField() const {
   const std::time_t timestamp = epochTime();
   struct tm timeinfo;
   quickstep::gmtime_r(&timestamp, &timeinfo);
   return (timeinfo.tm_mon + 1);
 }
 inline std::int64_t secondField() const {
   const std::time_t timestamp = epochTime();
   struct tm timeinfo;
   quickstep::gmtime_r(&timestamp, &timeinfo);
   return timeinfo.tm_sec;
 }
 inline std::int64_t yearField() const {
   const std::time_t timestamp = epochTime();
   struct tm timeinfo;
   quickstep::gmtime_r(&timestamp, &timeinfo);
   return (timeinfo.tm_year + 1900);
 }