REM Program to calculate the new ephemeris for a binary star system. REM (Basically a linear least squares fit adapted for this program set.) REM By James Marshall (class of 1996), summer 1995, Villanova University REM Last updated June 4, 1996 REM CLS PRINT "Ephemeris Calculator" PRINT "~~~~~~~~~~~~~~~~~~~~" PRINT PRINT "This program will calculate a new ephemeris for both primary and secondary" PRINT "minima of an eclipsing binary system by performing a least squares fit" PRINT "on the data. In addition to calculating the new values, it will also" PRINT "find the standard deviation of the new time of minimum and period which" PRINT "is useful in the analysis of the data." PRINT PRINT "It is best if you run the O-C program on the data first and then use" PRINT "that output file (.o-c) as the input for this program. However, the" PRINT "option to input data by hand is still given." PRINT PRINT "" DO: anykey$ = INKEY$: LOOP WHILE anykey$ = "" CLS PRINT "Data Input" PRINT "~~~~~~~~~~" PRINT PRINT "File name and path (no extension) of the .o-c input file (ENTER for none):" INPUT " "; inpfile1$ IF inpfile1$ <> "" THEN inpfile1$ = inpfile1$ + ".o-c" OPEN inpfile1$ FOR INPUT AS #1 LINE INPUT #1, name$ starname$ = "" WHILE LEFT$(name$, 1) <> "'" starname$ = starname$ + LEFT$(name$, 1) name$ = MID$(name$, 2) WEND LINE INPUT #1, none$ LINE INPUT #1, tmin1$ tmin1# = VAL(MID$(tmin1$, 21)) LINE INPUT #1, p1$ p1# = VAL(MID$(p1$, 21)) LINE INPUT #1, numtmin1$ numtmin1% = VAL(MID$(numtmin1$, 21)) LINE INPUT #1, tmin2$ tmin2# = VAL(MID$(tmin2$, 21)) LINE INPUT #1, p2$ p2# = VAL(MID$(p2$, 21)) LINE INPUT #1, numtmin2$ numtmin2% = VAL(MID$(numtmin2$, 21)) LINE INPUT #1, none$ LINE INPUT #1, by$ LINE INPUT #1, none$ LINE INPUT #1, none$ LINE INPUT #1, none$ LINE INPUT #1, none$ DIM tminprim#(numtmin1%), tminsec#(numtmin2%), oc1#(numtmin1%) DIM oc2#(numtmin2%), epoch1#(numtmin1%), epoch2#(numtmin2%), day#(numtmin2%) FOR i = 1 TO numtmin1% INPUT #1, tminprim#(i), oc1#(i), epoch1#(i) NEXT i INPUT #1, none$ INPUT #1, none$ INPUT #1, none$ INPUT #1, none$ FOR i = 1 TO numtmin2% INPUT #1, tminsec#(i), oc2#(i), day#(i), epoch2#(i) NEXT i CLOSE #1 ELSE CLS PRINT "Input Data By Hand" PRINT "~~~~~~~~~~~~~~~~~~" PRINT entry1: 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 REM *** *** END IF PRINT PRINT "Thank you. Press any key to continue." DO: anykey$ = INKEY$: LOOP WHILE anykey$ = "" CLS REM epoch = x, tmin = y; period = slope, newtmin = y intercept REM Find the new ephemeris (do the fit) and get errors REM Primary sumxy1# = sumx1# = sumy1# = sumx21# = sumy21# = 0! FOR i = 1 TO numtmin1% sumxy1# = sumxy1# + (epoch1#(i) * tminprim#(i)) sumx1# = sumx1# + epoch1#(i) sumy1# = sumy1# + tminprim#(i) sumx21# = sumx21# + (epoch1#(i) * epoch1#(i)) sumy21# = sumy21# + (tminprim#(i) * tminprim#(i)) NEXT i delta1# = numtmin1% * sumx21# - sumx1# * sumx1# period1# = (numtmin1% * sumxy1# - sumx1# * sumy1#) / delta1# newtmin1# = (sumx21# * sumy1# - sumx1# * sumxy1#) / delta1# sum2line1# = 0! FOR i = 1 TO numtmin1% term1# = (tminprim#(i) - newtmin1# - period1# * epoch1#(i)) sum2line1# = sum2line1# + (term1# * term1#) NEXT i sigmay21# = (1 / (numtmin1% - 2)) * sum2line1# sigmatmin1# = SQR(sigmay21# * sumx1# / delta1#) sigmaper1# = SQR(numtmin1% * sigmay21# / delta1#) REM Secondary sumxy2# = sumx2# = sumy2# = sumx22# = sumy22# = 0! FOR i = 1 TO numtmin2% sumxy2# = sumxy2# + (epoch2#(i) * tminsec#(i)) sumx2# = sumx2# + epoch2#(i) sumy2# = sumy2# + tminsec#(i) sumx22# = sumx22# + (epoch2#(i) * epoch2#(i)) sumy22# = sumy22# + (tminsec#(i) * tminsec#(i)) NEXT i delta2# = numtmin2% * sumx22# - sumx2# * sumx2# period2# = (numtmin2% * sumxy2# - sumx2# * sumy2#) / delta2# newtmin2# = (sumx22# * sumy2# - sumx2# * sumxy2#) / delta2# sum2line2# = 0! FOR i = 1 TO numtmin2% term2# = (tminsec#(i) - newtmin2# - period2# * epoch2#(i)) sum2line2# = sum2line2# + (term2# * term2#) NEXT i sigmay22# = (1 / (numtmin2% - 2)) * sum2line2# sigmatmin2# = SQR(sigmay22# * sumx2# / delta2#) sigmaper2# = SQR(numtmin2% * sigmay22# / delta2#) REM Results CLS PRINT "Results" PRINT "~~~~~~~" PRINT PRINT "For primary eclipse:" PRINT " Tmin (I) = "; USING "#######.#######"; newtmin1# PRINT " Uncertainty = "; USING "#######.#######"; sigmatmin1# PRINT " Period (I) = "; USING "##.#######"; period1# PRINT " Uncertainty = "; USING "##.#######"; sigmaper1# PRINT PRINT "For secondary eclipse:" PRINT " Tmin (II) = "; USING "#######.#######"; newtmin2# PRINT " Uncertainty = "; USING "#######.#######"; sigmatmin2# PRINT " Period (II) = "; USING "##.#######"; period2# PRINT " Uncertainty = "; USING "##.#######"; sigmaper2# PRINT PRINT "Press any key to continue" DO: anykey$ = INKEY$: LOOP WHILE anykey$ = "" REM END IF REM print to file CLS PRINT "Thank you for using this ephemeris 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 (.eph extension automatic): " PRINT " "; : INPUT file$ OPEN file$ + ".eph" FOR OUTPUT AS #1 PRINT #1, starname$; "'s Ephemeris Information" PRINT #1, "" PRINT #1, "For primary eclipse:" PRINT #1, " Tmin (I) = "; USING "#######.#######"; newtmin1# PRINT #1, " Uncertainty = "; USING "#######.#######"; sigmatmin1# PRINT #1, " Period (I) = "; USING "##.#######"; period1# PRINT #1, " Uncertainty = "; USING "##.#######"; sigmaper1# PRINT #1, "" PRINT #1, "For secondary eclipse:" PRINT #1, " Tmin (II) = "; USING "#######.#######"; newtmin2# PRINT #1, " Uncertainty = "; USING "#######.#######"; sigmatmin2# PRINT #1, " Period (II) = "; USING "##.#######"; period2# PRINT #1, " Uncertainty = "; USING "##.#######"; sigmaper2# CLOSE #1 skipit: PRINT PRINT "Have a nice day! :)" END