def get_background(self, bg_file): x = numpy.linspace(self.parameters['REF_START_BETA'], self.parameters['REF_STOP_BETA'], self.parameters['N_REF_PTS']) y = [] ch = raw_input('Please disconnect light source. Press Enter to continue :') for b in x: print b self.inst_suite.motor.goto(b) time.sleep(self.parameters['SETTLE_TIME']) y.append(self.inst_suite.srs.measure_const_SNR(self.SNR)) self.background = [x, y] IGRINS_util.save_figure([x], [zip(*y)[0]], [zip(*y)[1]], ['Background Signal'], 'Background', 'Angle (degrees)', 'Signal (V)', bg_file+'.png') with open(bg_file, 'a') as f: for angle, reading, dreading in zip(x, zip(*y)[0], zip(*y)[1]): f.write(str(angle)+', '+str(reading)+', '+str(dreading)+'\n') ch = raw_input('Replace light source. Press Enter to continue :')
def get_PSF(self, psf_file): x = numpy.linspace(self.parameters['REF_START_BETA'], self.parameters['REF_STOP_BETA'], self.parameters['N_REF_PTS']) xpts = [] ypts = [] dypts = [] names = [] retval = [] self.inst_suite.mono.goto_wavelength(self.wl[0]) y = [] print "Starting PSF Scan" for b, y_bkgnd in zip(self.background[0], self.background[1]): self.inst_suite.motor.goto(b) time.sleep(self.parameters['SETTLE_TIME']) y.append(self.inst_suite.srs.measure_const_SNR(self.SNR) - y_bkgnd[0]) retval.append([x, y]) # Find the maximum value of y, go to that beta angle print y print self.background[0] order = numpy.array(zip(*y)[0]).argsort() self.inst_suite.motor.goto(self.background[0][order[-1]]) bkgnd = self.background[1][order[-1]] for wl in self.wl: print "wavelength = "+str(wl)+"\n" self.inst_suite.mono.goto_wavelength(wl) time.sleep(self.parameters['SETTLE_TIME']) reading = self.inst_suite.srs.measure_const_SNR(self.SNR) retval.append([wl, reading[0]-bkgnd[0], (reading[1]**2.0+bkgnd[1]**2.0)**(0.5)]) with open(psf_file, 'a') as f: for angle, reading in zip(*retval[0]): f.write(str(angle)+', '+str(reading[0])+', '+str(reading[1])+'\n') for wavelength, reading, dreading in retval[1:]: f.write(str(wavelength)+ ', '+str(reading)+', '+str(dreading)+'\n') IGRINS_util.save_figure([retval[0][0]], [zip(*retval[0][1])[0]], [zip(*retval[0][1])[1]], [str(self.wl[0])], 'Background Subtracted Reference PSF', 'Angle (degrees)', 'Signal (V)', psf_file+'.png') return retval
print "Monochromator, please go to ", wl, " nanometers" self.inst_suite.mono.goto_wavelength(wl) time.sleep(10.0) while (self.inst_suite.mono.read_wavelength() != wl): time.sleep(2.0) print "Motor Controller, please go to ", beta+self.alpha, " degrees" coeff, x, y, dy = self.sweep(beta+self.alpha, psfs[0], (psf_scale_factor[1]/psfs[1][1]), wl, raw_file) self.readings.append(coeff) xpts.append(x) ypts.append(y) dypts.append(dy) names.append(str(wl)) with open(data_file, 'a') as f: f.write(str(wl)+', '+str(beta)+', '+str(coeff)+'\n') print self.readings[-1] IGRINS_util.save_figure(xpts, ypts, dypts, names, 'Raw Data', 'Angle (degrees)', 'Signal (V)', raw_file+'.png') print "Done!" class ScatteredLight( Mode ): """ """ def __init__( self, inst_suite ): """Sets up the scatter-scan mode""" self.inst_suite = inst_suite self.wl = [] self.beta = [] self.nwl = len(self.wl) self.nbeta = len(self.beta) def setup(self): wl_start = -1.0 while (wl_start < 0):