import pylab as pl import math import os from convertFiles import parseFileNames, textToArray if __name__ == "__main__": # no parameters for this function # parse names of files phoneFile, arduinoFile, saveDirectory = parseFileNames() # convert data in files to arrays phoneTimes, arduinoTimes, phoneDupes = textToArray(phoneFile, arduinoFile) # ARDUINO RUN TIME # find difference between start and end time, convert form millis to days runTimeArduino = ((float(arduinoTimes[len(arduinoTimes) - 1]) - float(arduinoTimes[0]))/(1000*60*60*24)) # convert from millis epoch to seconds epoch, then to readable format runStartArduino = int(arduinoTimes[0])/1000 readableRunStartArduino = time.strftime('%Y-%m-%d %I:%M %p', time.localtime(runStartArduino)) runEndArduino = int(arduinoTimes[len(arduinoTimes)-1])/1000 readableRunEndArduino = time.strftime('%Y-%m-%d %I:%M %p', time.localtime(runEndArduino)) # PHONE RUN TIME # find difference between start and end time, convert form millis to days runTimePhone = ((float(phoneTimes[len(phoneTimes) - 1]) - float(phoneTimes[0]))/(1000*60*60*24))
if __name__ == "__main__": # your guess is as good as mine as to what this does. Refer to corr.py to look at the unadulterated code #interval = 1.*DAY # millisec resolution = 100. # millisec #phone_rate = 0.0012 # mHz #scint_rate = 30. # mHz #print("generating events...") #p, s, truth = gen_events(interval, resolution, phone_rate, scint_rate) print("getting list of times from text files...") phoneFile, arduinoFile, saveDirectory = parseFileNames() p, s, ignoreMe = textToArray(phoneFile, arduinoFile) print("converting phone timestamps to timestream...") p = make_timestream(p, resolution) print("converting scintillator timestamps to timestream...") s = make_timestream(s, resolution) #gen_dt = truth*resolution print("correlating...") corr, dt = find_shift(saveDirectory, p, s, resolution, width=100000,
# "smallest", "all", and integers are accepted tolerance = 150 normalization = True # uncomment if you want to produce lots of graphs #for i in xrange(100): if (tolerance == "all") or (tolerance == "smallest"): normalization = False startTime = time.time() # parse names of files phoneFile, arduinoFile, saveDirectory = parseFileNames() # convert data in files to arrays phoneTimes, arduinoTimes, phoneDupes = textToArray(phoneFile, arduinoFile) # find the chosen set of deltaTimes (based on parameters) and sum them up offsetValues, sums, numberOfPoints = findSyncWithSums(phoneTimes, arduinoTimes, leftRange, rightRange, offsetIncrement, tolerance, normalization) # print total time endTime = time.time() timeItTook = endTime - startTime print ("finished in", round((timeItTook/60),2), "minutes") # plot the sums over millisecond offset drawSums(offsetValues, sums, numberOfPoints, offsetIncrement, saveDirectory, tolerance, normalization) # also uncomment for lots of graphs # tolerance += 10
if __name__ == "__main__": # your guess is as good as mine as to what this does. Refer to corr.py to look at the unadulterated code #interval = 1.*DAY # millisec resolution = 100. # millisec #phone_rate = 0.0012 # mHz #scint_rate = 30. # mHz #print("generating events...") #p, s, truth = gen_events(interval, resolution, phone_rate, scint_rate) print("getting list of times from text files...") phoneFile, arduinoFile, saveDirectory = parseFileNames() p, s, ignoreMe = textToArray(phoneFile, arduinoFile) print("converting phone timestamps to timestream...") p = make_timestream(p, resolution) print("converting scintillator timestamps to timestream...") s = make_timestream(s, resolution) #gen_dt = truth*resolution print("correlating...") corr, dt = find_shift(saveDirectory, p, s, resolution, width=100000, plot=True) #print("true dt =", (resolution*truth)) print("recovered dt =", dt) print("significance = %g" % ( (corr.max() - corr.mean())/corr.std() ))