/*********************************************************************** Description: This function gets the tdt (Terrestrial Dynamic Time, or TT time) Julian Date at the time desired. Outputs: tdt_julian_date - The tdt date is returned here, corresponding to the desired time. Inputs: desired_time - The time in UT1 (UTC) to get julian date for. Can use time(NULL) to get the UTC time on an RDA DELTA_T - The difference between TT and UT1, maintain from Navy data reports. Currently about 67 seconds difference between the time scales. ***********************************************************************/ static void Get_tdt_julian_date_at_time( double *tdt_julian_date, time_t desired_time, double DELTA_T ){ /* result (struct tm) - broken down time */ struct tm result; /* Get TDT date for the input time using NOVAS */ /* time_in is in the UT1 time system (UT1 is approximately UTC) Since TT = UT1 + DELTAT. Correct the input desired time, to be on the TT time scale. */ desired_time += DELTA_T; /* Now get broken down time on TT time scale. */ gmtime_r(&desired_time, &result); /* Use the NOVAS routine to get the julian date on TT time scale. TT is approximately TDT. */ *tdt_julian_date = julian_date( result.tm_year + 1900, result.tm_mon + 1, result.tm_mday, (double) result.tm_hour + ((double) result.tm_min) / 60.0 + ((double) result.tm_sec) / (3600.0)); } /* End of Get_tdt_julian_date_at_time(). */
/* * compute greenwich mean sidereal time (GST) corresponding to a given * number of seconds since the unix epoch * (after duffett-smith, section 12) */ static double GST(time_t ssue) //time_t ssue; /* seconds since unix epoch */ { double JD; double T, T0; double UT; struct tm *tm; tm = gmtime(&ssue); JD = julian_date(tm->tm_year+1900, tm->tm_mon+1, tm->tm_mday); T = (JD - 2451545) / 36525; T0 = ((T + 2.5862e-5) * T + 2400.051336) * T + 6.697374558; T0 = fmod(T0, 24.0); if (T0 < 0) T0 += 24; UT = tm->tm_hour + (tm->tm_min + tm->tm_sec / 60.0) / 60.0; T0 += UT * 1.002737909; T0 = fmod(T0, 24.0); if (T0 < 0) T0 += 24; return T0; }
void main() { time_t t = time(NULL); double jd0 = julian_date(1272672000); // 1271474022); // jd -= 10.0; double i; for (i = 0.0; i < 300; i += 0.01) { double jd = jd0 + i; double io[3]; get_io_parent_coordsv(jd, io); double europa[3]; get_europa_parent_coordsv(jd, europa); double ganymede[3]; get_ganymede_parent_coordsv(jd, ganymede); double calisto[3]; get_callisto_parent_coordsv(jd, calisto); double ioy = compute_delta(jd, io); double europay = compute_delta(jd, europa); double ganymedey = compute_delta(jd, ganymede); double calistoy = compute_delta(jd, calisto); /* printf("%10.10f %10.10f %10.10f\n", earth[0], earth[1], earth[2]); */ /* printf("%10.10f %10.10f %10.10f\n", jupiter[0], jupiter[1], jupiter[2]); */ /* printf("%10.10f %10.10f %10.10f\n", calisto[0], calisto[1], calisto[2]); */ /* printf("A = %10.10f, B = %10.10f, C = %10.10f, y = %10.10f\n", A, B, C, y); */ printf("%10.10f %10.10f %10.10f %10.10f %10.10f \n", jd, ioy, europay, ganymedey, calistoy); } // printf("pow(A,2) = %10.10f, B = %10.10f, C = %10.10f, y = %10.10f\n", pow(A,2), (pow(C,2) + pow(A,2) - pow(B,2)) / C, ((pow(C,2) + pow(A,2) - pow(B,2))/(2*C)), y); /* for (i = 0.0; i < 30; i += 0.01) { */ /* double j = jd + i; */ /* // printf("JD = %f\n", jd); */ /* double xyz1[3]; */ /* double xyz2[3]; */ /* double xyz3[3]; */ /* double xyz4[3]; */ /* GetL1Coor(j, 0, xyz1); */ /* GetL1Coor(j, 1, xyz2); */ /* GetL1Coor(j, 2, xyz3); */ /* GetL1Coor(j, 3, xyz4); */ /* // printf("x: %10.10f, y: %10.10f, z: %10.10f\n", xyz[0], */ /* // xyz[1], xyz[2]); */ /* // printf("%10.10f %10.10f %10.10f %10.10f %10.10f\n", j, -1.0 * xyz1[1], -1.0 * xyz2[1], -1.0 * xyz3[1], -1.0 * xyz4[1]); */ /* printf("%10.10f %10.10f %10.10f %10.10f %10.10f\n", j, -1.0 * xyz1[0], -1.0 * xyz1[1], -1.0 * xyz4[0], -1.0 * xyz4[1]); */ /* } */ }
double obliquity_of_ecliptic(date d) { double t; // Julian centuries from a given to the beginning of the epoch J2000 double e; // result obliquity of the ecliptic (ε) // computing time from the beginning of the epoch J2000 to a given date measured in Julian centuries t = (julian_date(d) - J2000) / DAYS_IN_JULIAN_CENTURY; // computing obliquity of the ecliptic (ε) using formula adopted by IAU; constants are measured in arcseconds // Source: J.H. Lieske, T. Lederle, W. Fricke and B. Morando. Expressions for the precession Quantities Based upon // the IAU (1976) System of Astronomical Constants, Astronomy ans Astrophysics, vol. 58, 1977, p. 15. e = 84381.448 - 46.8150 * t - 0.00059 * t * t + 0.001813 * t * t * t; // converting arcseconds to radians (π = 648000") e *= M_PI / 648000.0; return e; }
double nutation_in_obliquity(date d) { double t; // time measured in Julian centuries between given date and the beggingig of the epoch J2000 double da[TOTAL_DELAUNAY_ARGUMENTS]; // array holding Delaunay arguments double lan; // longitude of lunar ascending node (☊) referred to the mean equinox of date int i; // loop index variable double a; // argument of each term of the serie double n; // result nutation in obliquity value // computing time since the beginning of the epoch J2000 to the given measured in Julian centuries t = (julian_date(d) - J2000) / DAYS_IN_JULIAN_CENTURY; // computing Delaunay arguments as given by semi-analytic lunar theory ELP compute_delaunay_arguments(t, FULL_SERIES_TOTAL_TERMS, da); // computing longitude of the lunar ascending node (☊) // Source: P.K. Seidelman. 1980 IAU Theory of Nutation: The Final Report of the IAU Working Group on Nutation, // Celestial Mechanics, vol. 27, May 1982, p. 20. lan = 450160.28 - 6962890.539 * t + 7.455 * t * t + 0.008 * t * t * t; // computing nutation serie (see top comment for more information) for (i = 0, n = 0.0; i < TOTAL_NUTATION_TERMS; i++) { // computing argument of the term of the serie a = nutation_multipliers[i][0] * da[L]; a += nutation_multipliers[i][1] * da[LP]; a += nutation_multipliers[i][2] * da[F]; a += nutation_multipliers[i][3] * da[D]; a += nutation_multipliers[i][4] * lan; // converting argument from arcseconds to radians (π = 648000") a *= M_PI / 648000.0; // accumulation nutation values n += (nutation_coefficients[i][3] + nutation_coefficients[i][4] * t) * cos(a); } // coefficients are given in 10⁻⁵", converting to degrees (1° = 36000000×10⁻⁵") n /= 36000000.0; // converting nutation values from arcseconds to radians (π = 180°) n *= M_PI / 180.0; return n; }
char * conv_date_pict ( long date, const char *picture) { static char *month_name [] = { "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" }, *day_name [] = { "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" }, formatted [FORMAT_MAX + 1]; /* Formatted return string */ int century, /* Century component of date */ year, /* Year component of date */ month, /* Month component of date */ day, /* Day component of date */ cursize; /* Size of current component */ char *dest, /* Store formatted data here */ ch, /* Next character in picture */ lastch = '0'; /* Last character we output */ long full_date = date; conv_reason = 0; /* No conversion errors so far */ /* Zero date is returned as empty string */ if (date == 0) { strclr (formatted); return (formatted); } default_century (&full_date); century = GET_CENTURY (full_date); year = GET_YEAR (full_date); month = GET_MONTH (full_date); day = GET_DAY (full_date); ASSERT (month > 0 && month <= 12); ASSERT (day > 0 && day <= 31); /* Scan through picture, converting each component */ dest = formatted; *dest = 0; /* string is empty */ while (*picture) { /* Get character and count number of occurences */ ch = *picture++; for (cursize = 1; *picture == ch; cursize++) picture++; switch (ch) { /* cc century 2 digits, 01-99 */ case 'c': if (cursize == 2) sprintf (dest, "%02d", century); break; /* y day of year, 1-366 */ /* yy year 2 digits, 00-99 */ /* yyyy year 4 digits, 0100-9999 */ case 'y': /* y = day of year */ if (cursize == 1) sprintf (dest, "%d", julian_date (full_date)); else if (cursize == 2) sprintf (dest, "%02d", year); else if (cursize == 4) sprintf (dest, "%02d%02d", century, year); break; /* m month, 1-12 */ /* mm month, 01-12 */ /* mmm month, 3 letters */ /* mmmm month, full name */ case 'm': if (cursize == 1) sprintf (dest, (isdigit (lastch)? "%2d": "%d"), month); else if (cursize == 2) sprintf (dest, "%02d", month); else if (cursize == 3) { memcpy (dest, month_name [month - 1], 3); dest [3] = 0; } else if (cursize == 4) strcpy (dest, month_name [month - 1]); break; /* MMM month, 3-letters, ucase */ /* MMMM month, full name, ucase */ case 'M': if (cursize == 3) { memcpy (dest, month_name [month - 1], 3); dest [3] = 0; strupc (dest); } else if (cursize == 4) { strcpy (dest, month_name [month - 1]); strupc (dest); } break; /* d day, 1-31 */ /* dd day, 01-31 */ /* ddd day of week, Sun-Sat */ /* dddd day of week, Sunday-Saturday */ case 'd': if (cursize == 1) sprintf (dest, (isdigit (lastch)? "%2d": "%d"), day); else if (cursize == 2) sprintf (dest, "%02d", day); else if (cursize == 3) { memcpy (dest, day_name [day_of_week (full_date)], 3); dest [3] = 0; } else if (cursize == 4) strcpy (dest, day_name [day_of_week (full_date)]); break; /* DDD day of week, SUN-SAT */ /* DDDD day of week, SUNDAY-SATURDAY */ case 'D': if (cursize == 3) { memcpy (dest, day_name [day_of_week (full_date)], 3); dest [3] = 0; strupc (dest); } else if (cursize == 4) { strcpy (dest, day_name [day_of_week (full_date)]); strupc (dest); } break; /* w day of week, 1-7 (1=Sunday) */ /* ww week of year, 1-53 */ case 'w': if (cursize == 1) sprintf (dest, "%d", day_of_week (full_date) + 1); else if (cursize == 2) sprintf (dest, "%d", week_of_year (full_date)); break; /* q year quarter, 1-4 */ case 'q': if (cursize == 1) sprintf (dest, "%d", year_quarter (full_date)); break; /* \x literal character x */ case '\\': ch = *picture++; } if (*dest) /* If something was output, */ while (*dest) /* skip to end of string */ dest++; else while (cursize--) /* Else output ch once or more */ *dest++ = ch; /* and bump dest pointer */ lastch = *(dest - 1); /* Get previous character */ *dest = 0; /* Terminate the string nicely */ } return (formatted); }