resultsList = [] boxes = return_boxes("%s/broad_sweep/" % rootDirec) for box in boxes: broadFiles = return_files("%s/broad_sweep" % rootDirec, box) lowFiles = return_files("%s/low_intensity" % rootDirec, box) for j in range(len(lowFiles)): broadVals = check_data(plot_ipw.read_scope_scan(broadFiles[j])) lowVals = check_data(plot_ipw.read_scope_scan(lowFiles[j])) # Creat plots photonVsPIN_broad = ROOT.TGraphErrors() photonVsIPW_broad = ROOT.TGraphErrors() photonVsPIN_low = ROOT.TGraphErrors() photonVsIPW_low = ROOT.TGraphErrors() print len(broadVals), len(lowVals), broadFiles[j], lowFiles[j] for i in range(len(broadVals)): photonBroad = plot_ipw.get_photons(broadVals[i]["area"], 0.5) photonErrBroad = plot_ipw.get_photons(broadVals[i]["area_err"], 0.5) # Fill plots with data # Note: Data points are returned as mean and stdev(rms) # for fitting, uncertainties should be given as standard error. photonVsPIN_broad.SetPoint(i, broadVals[i]["pin"], photonBroad) photonVsPIN_broad.SetPointError( i, broadVals[i]["pin_err"] / np.sqrt(100), photonErrBroad / np.sqrt(100)) #photonVsPIN_broad.SetPointError(i,0,photonErrBroad/np.sqrt(1)) photonVsIPW_broad.SetPoint(i, broadVals[i]["ipw"], photonBroad) photonVsIPW_broad.SetPointError(i, 0, photonErrBroad / np.sqrt(100)) if i < len(lowVals):
channelDate = [] ratios = [] for directory in directoryArray: PINValues = [] PhotonValues = [] PINErrors = [] PhotonErrors = [] lowFiles = glob.glob(directory + "/*.dat") dict1 = createDictionaryFromFile(lowFiles[0]) channel, date1 = getDateAndChannel(lowFiles[0]) dict2 = createDictionaryFromFile(lowFiles[1]) channel, date2 = getDateAndChannel(lowFiles[1]) #max_index = returnFirstZeroIndex(dict1["area"],dict2["area"]) PhotonValues.append([plot_ipw.get_photons(x, 0.7) for x in dict1["area"]]) PhotonValues.append([plot_ipw.get_photons(x, 0.7) for x in dict2["area"]]) max_index = returnFirstLessThanValueIndex(PhotonValues[0], PhotonValues[1], 10000) del PhotonValues[:] PhotonValues.append( [plot_ipw.get_photons(x, 0.7) for x in dict1["area"][:max_index]]) PhotonValues.append( [plot_ipw.get_photons(x, 0.7) for x in dict2["area"][:max_index]]) relative_photon_error_1 = np.divide(dict1["area_error"][:max_index], dict1["area"][:max_index]) relative_photon_error_2 = np.divide(dict2["area_error"][:max_index], dict2["area"][:max_index]) relative_ratio_error = np.sqrt( np.power(relative_photon_error_1, 2) + np.power(relative_photon_error_2, 2))
if firstIter: for key in row.keys(): file1Dict[key] = [float(row[key])] firstIter = False else: for key in row.keys(): file1Dict[key].append(float(row[key])) reader = csv.DictReader(file2,delimiter="\t") firstIter = True for row in reader: if firstIter: for key in row.keys(): file2Dict[key] = [float(row[key])] firstIter = False else: for key in row.keys(): file2Dict[key].append(float(row[key])) photonCounts1 = plot_ipw.get_photons(file1Dict["AREA"],0.7) photonCountsError1 = plot_ipw.get_photons(file1Dict["AREA Error"],0.7) photonCounts2 = plot_ipw.get_photons(file2Dict["AREA"],0.7) photonCountsError2 = plot_ipw.get_photons(file2Dict["AREA Error"],0.7) plt.errorbar(file1Dict["#PWIDTH"],np.subtract(photonCounts2,photonCounts1),yerr=np.sqrt(np.power(photonCountsError2,2)+np.power(photonCountsError1,2))) plt.show()
resultsList = [] boxes = return_boxes("%s/broad_sweep/"%rootDirec) for box in boxes: broadFiles = return_files("%s/broad_sweep"%rootDirec, box) lowFiles = return_files("%s/low_intensity"%rootDirec, box) for j in range(len(lowFiles)): broadVals = check_data(plot_ipw.read_scope_scan(broadFiles[j])) lowVals = check_data(plot_ipw.read_scope_scan(lowFiles[j])) # Creat plots photonVsPIN_broad = ROOT.TGraphErrors() photonVsIPW_broad = ROOT.TGraphErrors() photonVsPIN_low = ROOT.TGraphErrors() photonVsIPW_low = ROOT.TGraphErrors() print len(broadVals), len(lowVals), broadFiles[j], lowFiles[j] for i in range(len(broadVals)): photonBroad = plot_ipw.get_photons(broadVals[i]["area"], 0.5) photonErrBroad = plot_ipw.get_photons(broadVals[i]["area_err"], 0.5) # Fill plots with data # Note: Data points are returned as mean and stdev(rms) # for fitting, uncertainties should be given as standard error. photonVsPIN_broad.SetPoint(i,broadVals[i]["pin"],photonBroad) photonVsPIN_broad.SetPointError(i,broadVals[i]["pin_err"]/np.sqrt(100),photonErrBroad/np.sqrt(100)) #photonVsPIN_broad.SetPointError(i,0,photonErrBroad/np.sqrt(1)) photonVsIPW_broad.SetPoint(i,broadVals[i]["ipw"],photonBroad) photonVsIPW_broad.SetPointError(i,0,photonErrBroad/np.sqrt(100)) if i < len(lowVals): photonLow = plot_ipw.get_photons(lowVals[i]["area"], 0.7) photonErrLow = plot_ipw.get_photons(lowVals[i]["area_err"], 0.7) photonVsPIN_low.SetPoint(i,lowVals[i]["pin"],photonLow) photonVsPIN_low.SetPointError(i,lowVals[i]["pin_err"]/np.sqrt(100),photonErrLow/np.sqrt(100))
resultsList = [] boxes = return_boxes("%s/low_intensity/"%rootDirec) for box in boxes: #lowFiles = return_all_files("%s/low_intensity"%rootDirec, box) lowFiles = return_files("%s/low_intensity"%rootDirec, box) for j in range(len(lowFiles)): lowVals = check_data(plot_ipw.read_scope_scan(lowFiles[j])) # Creat plots photonVsPIN_low = ROOT.TGraphErrors() photonVsIPW_low = ROOT.TGraphErrors() print len(lowVals), lowFiles[j] for i in range(len(lowVals)): # Fill plots with data # Note: Data points are returned as mean and stdev(rms) # for fitting, uncertainties should be given as standard error. photonLow = plot_ipw.get_photons(lowVals[i]["area"], 0.7) photonErrLow = plot_ipw.get_photons(lowVals[i]["area_err"], 0.7) photonVsPIN_low.SetPoint(i,lowVals[i]["pin"],photonLow) photonVsPIN_low.SetPointError(i,lowVals[i]["pin_err"]/np.sqrt(100),photonErrLow/np.sqrt(100)) #photonVsPIN_broad.SetPointError(i,0,photonErrBroad/np.sqrt(1)) photonVsIPW_low.SetPoint(i,lowVals[i]["ipw"],photonLow) photonVsIPW_low.SetPointError(i,0,photonErrLow/np.sqrt(100)) # Add titles, labels and styling logical_channel = (int(lowFiles[j][-33:-31])-1)*8 + int(lowFiles[j][-26:-24]) time_str = lowFiles[j][-16:-4] photonVsPIN_low.SetName("Chan%02d_PIN_%s"%(logical_channel, time_str)) photonVsPIN_low.GetXaxis().SetTitle("PIN reading (16 bit)") photonVsPIN_low.GetYaxis().SetTitle("No. photons")
channelDate = [] ratios = [] for directory in directoryArray: PINValues = [] PhotonValues = [] PINErrors = [] PhotonErrors = [] lowFiles = glob.glob(directory+"/*.dat") dict1 = createDictionaryFromFile(lowFiles[0]) channel, date1 = getDateAndChannel(lowFiles[0]) dict2 = createDictionaryFromFile(lowFiles[1]) channel, date2 = getDateAndChannel(lowFiles[1]) #max_index = returnFirstZeroIndex(dict1["area"],dict2["area"]) PhotonValues.append([plot_ipw.get_photons(x,0.7) for x in dict1["area"]]) PhotonValues.append([plot_ipw.get_photons(x,0.7) for x in dict2["area"]]) max_index = returnFirstLessThanValueIndex(PhotonValues[0],PhotonValues[1],10000) del PhotonValues[:] PhotonValues.append([plot_ipw.get_photons(x,0.7) for x in dict1["area"][:max_index]]) PhotonValues.append([plot_ipw.get_photons(x,0.7) for x in dict2["area"][:max_index]]) relative_photon_error_1 = np.divide(dict1["area_error"][:max_index],dict1["area"][:max_index]) relative_photon_error_2 = np.divide(dict2["area_error"][:max_index],dict2["area"][:max_index]) relative_ratio_error = np.sqrt(np.power(relative_photon_error_1,2)+np.power(relative_photon_error_2,2)) ratio_photon = (np.divide(dict1["area"][:max_index],dict2["area"][:max_index])) mean_ratio_photon = np.mean(ratio_photon) print "The ratio of photon count between "+str(lowFiles[0])+" and "+str(lowFiles[1])+" is "+str(mean_ratio_photon) plt.errorbar(dict1["ipw"][:max_index],ratio_photon,yerr=np.multiply(ratio_photon,relative_ratio_error),label=str(channel+" "+date1+"/"+date2)) PINValues.append(dict1["PIN"][:max_index]) PINValues.append(dict2["PIN"][:max_index]) PINErrors.append(dict1["PIN_error"][:max_index])
resultsList = [] boxes = return_boxes("%s/low_intensity/" % rootDirec) for box in boxes: #lowFiles = return_all_files("%s/low_intensity"%rootDirec, box) lowFiles = return_files("%s/low_intensity" % rootDirec, box) for j in range(len(lowFiles)): lowVals = check_data(plot_ipw.read_scope_scan(lowFiles[j])) # Creat plots photonVsPIN_low = ROOT.TGraphErrors() photonVsIPW_low = ROOT.TGraphErrors() print len(lowVals), lowFiles[j] for i in range(len(lowVals)): # Fill plots with data # Note: Data points are returned as mean and stdev(rms) # for fitting, uncertainties should be given as standard error. photonLow = plot_ipw.get_photons(lowVals[i]["area"], 0.7) photonErrLow = plot_ipw.get_photons(lowVals[i]["area_err"], 0.7) photonVsPIN_low.SetPoint(i, lowVals[i]["pin"], photonLow) photonVsPIN_low.SetPointError( i, lowVals[i]["pin_err"] / np.sqrt(100), photonErrLow / np.sqrt(100)) #photonVsPIN_broad.SetPointError(i,0,photonErrBroad/np.sqrt(1)) photonVsIPW_low.SetPoint(i, lowVals[i]["ipw"], photonLow) photonVsIPW_low.SetPointError(i, 0, photonErrLow / np.sqrt(100)) # Add titles, labels and styling logical_channel = (int(lowFiles[j][-33:-31]) - 1) * 8 + int(
firstIter = False else: for key in row.keys(): file1Dict[key].append(float(row[key])) reader = csv.DictReader(file2, delimiter="\t") firstIter = True for row in reader: if firstIter: for key in row.keys(): file2Dict[key] = [float(row[key])] firstIter = False else: for key in row.keys(): file2Dict[key].append(float(row[key])) photonCounts1 = plot_ipw.get_photons(file1Dict["AREA"], 0.7) photonCountsError1 = plot_ipw.get_photons(file1Dict["AREA Error"], 0.7) photonCounts2 = plot_ipw.get_photons(file2Dict["AREA"], 0.7) photonCountsError2 = plot_ipw.get_photons(file2Dict["AREA Error"], 0.7) plt.errorbar(file1Dict["#PWIDTH"], np.subtract(photonCounts2, photonCounts1), yerr=np.sqrt( np.power(photonCountsError2, 2) + np.power(photonCountsError1, 2))) plt.show()