def find_offset_old(self,datafile, nonlinmin, nonlinmax, exclude, threshold): '''find_offset is used to determine the systematic offset present in the experimental setup that causes data to not be symmetric about zero input angle. It reads in the output of laserBench and returns the offset (in degrees)''' input_a, output_a = np.loadtxt(datafile,usecols=(0,1),unpack=True) for e in exclude: did = np.where(input_a == e) output_a = np.delete(output_a, did) input_a = np.delete(input_a, did) pidx = np.where(input_a > nonlinmax) nidx = np.where(input_a < nonlinmin) in_a = np.append(input_a[nidx],input_a[pidx]) out_a = np.append(-1*output_a[nidx],output_a[pidx]) error = np.zeros(in_a.size)+1 b = 1000. offset = 0. while abs(b) > threshold: m, b = ADE.fit_line(in_a,out_a,error) offset += b in_a += b return offset
def ratio_test(t_file,data_path): T = thePot(t_file) fits_list = glob(data_path+'/*.FIT') volts = np.array([]) counts = np.array([]) for fits in fits_list: print fits, HDU = pyfits.open(fits)[0] exptime = HDU.header['EXPTIME'] timestr = HDU.header['TIME-OBS'] obstime = np.float(timestr[6:])\ + np.float(timestr[3:5])*60.\ + np.float(timestr[0:2])*3600. voltage = T.get_voltage(obstime,obstime+exptime,'V') r, sb, e = ADE.fast_annulize(HDU.data,300) r *= 0.024 flux = np.cumsum(sb) rate = flux/exptime ADU = np.interp(54/10.,r,rate) print voltage, ADU volts = np.append(volts,voltage) counts = np.append(counts,ADU) fit = ADE.fit_line(volts,counts,np.ones(counts.shape)) print fit fig = plt.figure() ax = fig.add_subplot(111) ax.plot(volts,counts,'.') ax.set_xlabel('Voltage') ax.set_ylabel('ADU/s') fig.show()
def find_offset(self,datafile, nonlinmin, nonlinmax, exclude, threshold): input_a, output_a = np.loadtxt(datafile,usecols=(0,1),unpack=True) for e in exclude: did = np.where(input_a == e) output_a = np.delete(output_a, did) input_a = np.delete(input_a, did) pidx = np.where(input_a > nonlinmax) nidx = np.where(input_a < nonlinmin) in_a = np.append(input_a[nidx],input_a[pidx]) out_a = np.append(-1*output_a[nidx],output_a[pidx]) e = np.zeros(in_a.size)+1 b = 1000. offset = 0. while abs(b) > threshold: m, b = ADE.fit_line(in_a,out_a,e) offset += b in_a += b return offset