MCPcopy Create free account
hub / github.com/CruiserOne/Astrolog / init_dt

Function init_dt

swephlib.cpp:3094–3138  ·  view source on GitHub ↗

Read delta t values from external file. * record structure: year(whitespace)delta_t in 0.01 sec. */

Source from the content-addressed store, hash-verified

3092* record structure: year(whitespace)delta_t in 0.01 sec.
3093*/
3094static int init_dt(void)
3095{
3096FILE *fp;
3097int year;
3098int tab_index;
3099int tabsiz;
3100int i;
3101char s[AS_MAXCH];
3102char *sp;
3103if (!swed.init_dt_done) {
3104 swed.init_dt_done = TRUE;
3105 /* no error message if file is missing */
3106 if ((fp = swi_fopen(-1, "swe_deltat.txt", swed.ephepath, NULL)) == NULL
3107 && (fp = swi_fopen(-1, "sedeltat.txt", swed.ephepath, NULL)) == NULL)
3108 return TABSIZ;
3109 while(fgets(s, AS_MAXCH, fp) != NULL) {
3110 sp = s;
3111 while (strchr(" \t", *sp) != NULL && *sp != '\0')
3112 sp++; /* was *sp++ fixed by Alois 2-jul-2003 */
3113 if (*sp == '#' || *sp == '\n')
3114 continue;
3115 year = atoi(s);
3116 tab_index = year - TABSTART;
3117 /* table space is limited. no error msg, if exceeded */
3118 if (tab_index >= TABSIZ_SPACE)
3119 continue;
3120 sp += 4;
3121 while (strchr(" \t", *sp) != NULL && *sp != '\0')
3122 sp++; /* was *sp++ fixed by Alois 2-jul-2003 */
3123 /*dt[tab_index] = (short) (atof(sp) * 100 + 0.5);*/
3124 dt[tab_index] = atof(sp);
3125 }
3126 fclose(fp);
3127}
3128/* find table size */
3129tabsiz = 2001 - TABSTART + 1;
3130for (i = tabsiz - 1; i < TABSIZ_SPACE; i++) {
3131 if (dt[i] == 0)
3132 break;
3133 else
3134 tabsiz++;
3135}
3136tabsiz--;
3137return tabsiz;
3138}
3139
3140/* Astronomical Almanac table is corrected by adding the expression
3141 * -0.000091 (ndot + 26)(year-1955)^2 seconds

Callers 1

deltat_aaFunction · 0.85

Calls 1

swi_fopenFunction · 0.85

Tested by

no test coverage detected