REM Program to calculate the O-C for any star. REM By James Marshall (class of 1996), summer 1995, Villanova University CLS PRINT "O-C Calculator" PRINT "~~~~~~~~~~~~~~" PRINT PRINT "This program will calculate the O-C's for any star. I will prompt" PRINT "you for the appropriate inputs when necessary. You will need to know" PRINT "a T_min and the period for both primary and secondary eclipse, and" PRINT "of course, a series of T_mins for which you wish to calculate the" PRINT "O-C's. If you do not have the T_min for the secondary eclipse, use" PRINT "the primary's T_min + 0.5*phase and the same period. The program also" PRINT "calculates the D value of the secondary eclipses." PRINT PRINT "Please note that the normal units are Julian Date for all T_min's" PRINT "and days for periods, O-C's, and D's. Cycle number is unitless." PRINT PRINT "" DO: anykey$ = INKEY$: LOOP WHILE anykey$ = "" CLS PRINT "INSTRUCTIONS" PRINT "~~~~~~~~~~~~" PRINT PRINT "You may elect to have your input values read from a file for either or" PRINT "both of the 2 main input sections -- the ephemeris information and the" PRINT "times of minima. You may choose to use files for both, or only one" PRINT "of the data input sections." PRINT PRINT "To use a file for the first section, the following information must be" PRINT "in the file, in this order, one to a line: star name, T_min (I), " PRINT "P (I), number of T_min I's, T_min (II), P (II), number of T_min II's, " PRINT "person(s) who calculated the ephemeris." PRINT PRINT "To use a file for the first section, you must put the exact number of" PRINT "times of minima specified from the first section, one on each line," PRINT "with all of the primary minima first, followed by all of the secondary" PRINT "minima. Do not put any blank lines between the two sections of data." PRINT PRINT "" DO: anykey$ = INKEY$: LOOP WHILE anykey$ = "" entry1: CLS PRINT "Input Data for the System" PRINT "~~~~~~~~~~~~~~~~~~~~~~~~~" PRINT PRINT "Full path and name of input file (ENTER for none): " INPUT " "; inpfile1$ IF inpfile1$ <> "" THEN OPEN inpfile1$ FOR INPUT AS #1 LINE INPUT #1, starname$ LINE INPUT #1, tmin1$ tmin1# = VAL(tmin1$) LINE INPUT #1, p1$ p1# = VAL(p1$) LINE INPUT #1, numtmin1$ numtmin1 = VAL(numtmin1$) LINE INPUT #1, tmin2$ tmin2# = VAL(tmin2$) LINE INPUT #1, p2$ p2# = VAL(p2$) LINE INPUT #1, numtmin2$ numtmin2 = VAL(numtmin2$) LINE INPUT #1, ephem$ CLOSE #1 ELSE REM enter data by hand PRINT INPUT " Star Name: ", starname$ INPUT " T_min (I): ", tmin1# INPUT " P (I): ", p1# INPUT " # of T_min I's: ", numtmin1 INPUT " T_min (II): ", tmin2# INPUT " P (II): ", p2# INPUT " # of T_min II's: ", numtmin2 PRINT INPUT "Emphemeris calculated by: ", ephem$ PRINT INPUT "Are all the values correct (Y/N)"; ans$ IF (ans$ = "N" OR ans$ = "n") THEN GOTO entry1 END IF PRINT PRINT "Thank you. Press any key to continue." DO: anykey$ = INKEY$: LOOP WHILE anykey$ = "" REM get t_mins CLS DIM tminprim#(numtmin1), tminsec#(numtmin2), e1(numtmin1), e2(numtmin2) DIM phi1#(numtmin1), phi2#(numtmin2), oc1#(numtmin1), oc2#(numtmin2) DIM e3(numtmin2), phi3#(numtmin2), d#(numtmin2) PRINT "Entering T_mins" PRINT "~~~~~~~~~~~~~~~" PRINT PRINT "Full path and name of input file (ENTER for none): " INPUT " "; inpfile2$ IF inpfile2$ <> "" THEN OPEN inpfile2$ FOR INPUT AS #2 FOR i = 1 TO numtmin1 LINE INPUT #2, temp$ tminprim#(i) = VAL(temp$) NEXT i FOR j = 1 TO numtmin2 LINE INPUT #2, temp$ tminsec#(j) = VAL(temp$) NEXT j CLOSE #2 ELSE CLS PRINT "Enter T_min(s) for Primary Eclipse" PRINT "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" PRINT FOR i = 1 TO numtmin1 INPUT " T_min I: ", tminprim#(i) NEXT i CLS PRINT "Enter T_min(s) for Secondary Eclipse" PRINT "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" PRINT FOR j = 1 TO numtmin2 INPUT "T_min II: ", tminsec#(j) NEXT j END IF REM make calculations REM o-c for primary FOR i = 1 TO numtmin1 e1(i) = FIX((tminprim#(i) - tmin1#) / p1#) phi1#(i) = ((tminprim#(i) - tmin1#) / p1#) - e1(i) IF phi1#(i) > .9 THEN phi1#(i) = phi1#(i) - 1 e1(i) = e1(i) + 1 END IF IF phi1#(i) < -.9 THEN phi1#(i) = phi1#(i) + 1 e1(i) = e1(i) - 1 END IF oc1#(i) = phi1#(i) * p1# NEXT i REM o-c for secondary FOR j = 1 TO numtmin2 e2(j) = FIX((tminsec#(j) - tmin2#) / p2#) phi2#(j) = ((tminsec#(j) - tmin2#) / p2#) - e2(j) IF phi2#(j) > .9 THEN phi2#(j) = phi2#(j) - 1 e2(j) = e2(j) + 1 END IF IF phi2#(j) < -.9 THEN phi2#(j) = phi2#(j) + 1 e2(j) = e2(j) - 1 END IF oc2#(j) = phi2#(j) * p2# NEXT j REM d for secondary FOR k = 1 TO numtmin2 e3(k) = FIX((tminsec#(k) - tmin1#) / p1#) phi3#(k) = ((tminsec#(k) - tmin1#) / p1#) - e3(k) IF phi3#(k) < 0 THEN phi3#(k) = phi3#(k) + 1 e3(k) = e3(k) - 1 END IF d#(k) = (phi3#(k) - .5) * p1# NEXT k REM output REM print to screen CLS IF numtmin1 <> 0 THEN PRINT starname$; "'s O-C Information" PRINT PRINT "For Primary Eclipse:" PRINT PRINT "JD O-C Cycle" FOR i = 1 TO numtmin1 PRINT USING "#######.#### "; tminprim#(i); PRINT USING "+##.##### "; oc1#(i); PRINT USING "+####"; e1(i) NEXT i PRINT PRINT "Press any key to continue" DO: anykey$ = INKEY$: LOOP WHILE anykey$ = "" END IF CLS IF numtmin2 <> 0 THEN PRINT starname$; "'s O-C Information" PRINT PRINT "For Secondary Eclipse:" PRINT PRINT "JD O-C D Cycle" FOR j = 1 TO numtmin2 PRINT USING "#######.#### "; tminsec#(j); PRINT USING "+##.##### "; oc2#(j); PRINT USING "##.##### "; d#(j); PRINT USING "+####"; e3(j) NEXT j PRINT PRINT "Press any key to continue" DO: anykey$ = INKEY$: LOOP WHILE anykey$ = "" END IF REM print to file CLS PRINT "Thank you for using this O-C calculator." PRINT INPUT "Would you like to save the results to a file (Y/N)"; ans$ IF (ans$ = "N" OR ans$ = "n") THEN GOTO skipit PRINT "Enter the filename with path (.o-c extension automatic): " PRINT " "; : INPUT file$ OPEN file$ + ".o-c" FOR OUTPUT AS #1 PRINT #1, starname$; "'s O-C Information" PRINT #1, "" PRINT #1, " T_min (I) = "; USING "#######.#####"; tmin1# PRINT #1, " P (I) = "; USING "###.#########"; p1# PRINT #1, "T_min (II) = "; USING "#######.#####"; tmin2# PRINT #1, " P (II) = "; USING "###.#########"; p2# PRINT #1, "" PRINT #1, "Ephemeris calculated by: "; ephem$ PRINT #1, "" PRINT #1, "For Primary Eclipse:" PRINT #1, "" PRINT #1, "Julian Date O-C (day) Cycle #" FOR i = 1 TO numtmin1 PRINT #1, USING "#######.######## "; tminprim#(i); PRINT #1, USING "+##.######### "; oc1#(i); PRINT #1, USING "+####"; e1(i) NEXT i PRINT #1, "" PRINT #1, "For Secondary Eclipse:" PRINT #1, "" PRINT #1, "Julian Date O-C (day) D (day) Cycle #" FOR j = 1 TO numtmin2 PRINT #1, USING "#######.######## "; tminsec#(j); PRINT #1, USING "+##.######### "; oc2#(j); PRINT #1, USING "##.######### "; d#(j); PRINT #1, USING "+####"; e3(j) NEXT j CLOSE #1 skipit: PRINT PRINT "Have a nice day! :)" END