c----------------------------------------------------------------------- c 04-10-04 c Ruth A. Juarez c Independent Study Spring 2004 c Dr. Bill Ryan c Program to convert data collected from observations into a light c curve. Will use to test another program's output as check on reults. c test1.f implicit none c----------------------------------------------------------------------- c Parameters c----------------------------------------------------------------------- integer maxobjs parameter (maxobjs = 20) c----------------------------------------------------------------------- c Variables c----------------------------------------------------------------------- character*11 chartime character*5 imagename real exptime, time, obstime,deltamag,avg real sigavg, sigdeltamag, sum, xairm real mag(maxobjs),merr(maxobjs) integer nobj, i, j, k, iobject,image,itemp integer iplot, idel, ncomps, id c----------------------------------------------------------------------- c Data to be read into program plus output file c----------------------------------------------------------------------- open (21, file='results2.dat') open (22, file='lightcurve2.dat') c----------------------------------------------------------------------- c Getting input from the user re: how many objects they observed per c screen in 'read' the '5' refers to reading the input from the c keyboard (screen) c----------------------------------------------------------------------- print *,"Enter the number of objects per screen" read(5,*) nobj print *,"Enter the object number to plot" read(5,*) iplot print *, "Enter the object number to delete or 0 not to delete" read(5,*) idel c----------------------------------------------------------------------- c Read in the data from the results.dat file c Print objects to the screen so that I know they are being read in c correctly. Perform calculations on each image c----------------------------------------------------------------------- do 200 image = 1, 200 print *, " " do 190 iobject = 1, nobj read(21,*, end = 300) & imagename,id,chartime,mag(iobject),merr(iobject),exptime,xairm print *, & imagename," ",id," ",chartime,mag(iobject),merr(iobject), & exptime,xairm 190 continue c----------------------------------------------------------------------- c Call to subroutine to get change the time to a decimal string c----------------------------------------------------------------------- call decimaltime(chartime,exptime,0.0,obstime) c----------------------------------------------------------------------- c Do calculation for this image c----------------------------------------------------------------------- sum = 0.0 sigavg = 0.0 avg = 0.0 ncomps = 0 do 40 itemp = 2, nobj IF (itemp .ne. idel) THEN ncomps = ncomps + 1; sum = sum + mag(itemp) sigavg = sigavg + merr(itemp)**2 END IF 40 continue avg = sum/real(ncomps) sigavg = sqrt(sigavg/real(ncomps)) deltamag = mag(iplot) - avg sigdeltamag = sqrt((merr(iplot)**2 + sigavg**2)/2.0) write(22,195), obstime,deltamag,sigdeltamag print *, obstime, deltamag, sigdeltamag 195 format (f12.4, 3x, f8.3, 3x, f8.3) 200 continue 300 continue stop end c%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% c this subroutine reads the time and converts it to time in decimal form c this subroutine used with permission of author Carlos T. Martinez c*********************************************************************** c subroutine decimaltime (ctime,timeint,corrtime,time) c c*********************************************************************** c c calculate time in decimal form c c Input: c ctime : the characters read in by readimg c timeint : integration time (seconds) c corrtime: the corcection time (minutes) c Output: c time : the decimal time the image was taken (hours) c c character*11 ctime real corrtime, timeint, time c c read and calculate time from filelist info c hours kbegin = 1 kend = index (ctime(kbegin:),':') - 1 read (ctime(kbegin:kend),*) hour c minutes kbegin = kend + 2 kend = index (ctime(kbegin:),':') - 2 + kbegin read (ctime(kbegin:kend),*) min c seconds kbegin = kend + 2 read (ctime(kbegin:),*) sec c c calculate decimal time c time = real(hour) + real(min)/60.0 + real(sec)/3600.0 c c Add the correction for the integration time time = time + timeint /(2.0 * 3600.0) c c option to correction of time c time = time + corrtime/60.0 c c return end c c%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% c