def check_offset(highFile, lowFile, plot=False): highData, lowData = dataSet(), dataSet() highData.parseFile(highFile) lowData.parseFile(lowFile) channels = np.asarray(highData.findData("channel").getData()) low_channels = np.asarray(lowData.findData("channel").getData()) for channel in channels: if np.where(low_channels == channel)[0]: cutoff_high = find_parabola_min(highData, np.where(channels == channel)[0]) cutoff_low = find_parabola_min(lowData, np.where(low_channels == channel)[0]) print channel, cutoff_high, cutoff_low, (cutoff_low - cutoff_high) if plot == True: plot_curves(highData, lowData, channel)
def flagBadFits(dataFile): fileData = dataSet() fileData.parseFile(dataFile) ipw_ChiSq = np.asarray(fileData.findData("ipwChi2").getData()) pin_ChiSq = np.asarray(fileData.findData("pinChi2").getData()) meanChiIPW = np.mean(ipw_ChiSq) stdChiIPW = np.std(ipw_ChiSq) meanChiPIN = np.nanmean(pin_ChiSq) stdChiPIN = np.nanstd(pin_ChiSq) for i in range(len(ipw_ChiSq)): if ipw_ChiSq[i] > meanChiIPW+stdChiIPW: print "Channel %d failed IPW fit test: " %(i+1) if pin_ChiSq[i] > meanChiPIN+stdChiPIN: print "Channel %d failed pin fit test: " %(i+1)
from channelPlot import data from channelPlot import dataSet import numpy as np import matplotlib.pyplot as plt if __name__ == "__main__": fileData = dataSet() fileData.parseFile("results/resultsOverview.csv") ipw_p0 = np.asarray(fileData.findData("ipw_p0").getData()) ipw_p1 = np.asarray(fileData.findData("ipw_p1").getData()) ipw_p2 = np.asarray(fileData.findData("ipw_p2").getData()) ipw_p0_mean = np.mean(ipw_p0) ipw_p1_mean = np.mean(ipw_p1) ipw_p2_mean = np.mean(ipw_p2) x = np.linspace(0000, 19000, 18000) total_F = np.zeros((len(ipw_p0), len(x)), dtype=np.float64) for i in range(len(ipw_p0)): trial_F = ipw_p0[i] + (ipw_p1[i] * x) + (ipw_p2[i] * x**2) minIndex = np.argmin(trial_F) minY = trial_F[minIndex] minX = x[minIndex] offset = minX - 5000 shiftUpwards = 0 if minY > 1000: print "Channel %d is above 1000 photons minimum" % (i + 1) if minY < 0: shiftUpwards = -minY trial_F_shifted = ipw_p0[i] + shiftUpwards + ( ipw_p1[i] * (x + offset)) + (ipw_p2[i] * (x + offset)**2)
from channelPlot import data from channelPlot import dataSet import numpy as np import matplotlib.pyplot as plt if __name__ == "__main__": fileData = dataSet() fileData.parseFile("results/resultsOverview.csv") ipw_p0 = np.asarray(fileData.findData("ipw_p0").getData()) ipw_p1 = np.asarray(fileData.findData("ipw_p1").getData()) ipw_p2 = np.asarray(fileData.findData("ipw_p2").getData()) ipw_p0_mean = np.mean(ipw_p0) ipw_p1_mean = np.mean(ipw_p1) ipw_p2_mean = np.mean(ipw_p2) x = np.linspace(0000,19000,18000) total_F = np.zeros((len(ipw_p0),len(x)),dtype=np.float64) for i in range(len(ipw_p0)): trial_F = ipw_p0[i]+(ipw_p1[i]*x)+(ipw_p2[i]*x**2) minIndex = np.argmin(trial_F) minY = trial_F[minIndex] minX = x[minIndex] offset = minX-5000 shiftUpwards = 0 if minY>1000: print "Channel %d is above 1000 photons minimum" % (i+1) if minY<0: shiftUpwards = -minY trial_F_shifted = ipw_p0[i]+shiftUpwards+(ipw_p1[i]*(x+offset))+(ipw_p2[i]*(x+offset)**2) plt.plot(x,trial_F_shifted,label="Channel %d shifted" %(i+1))