def onLoadClicked(): dir, filePrefix = filenameGen() dir = join(POOHDATAPATH,dir) refFileName = QtGui.QFileDialog.getOpenFileName(self,'select file', dir,"CSV Files (*.csv)") rData = np.loadtxt(open(refFileName[0],"rb"),delimiter=",") name = refFileName[0].rpartition('/')[2] color = QtGui.QColorDialog.getColor() if 'matrix' in refFileName[0]: xVals = rData[:,0] yVals = [] errVals = [] for rowNum in range(len(xVals)): thisYList = rData[rowNum,1:] yVals.append(np.mean(thisYList)) errVals.append(np.std(thisYList)/np.sqrt(len(thisYList))) self.refData[name] = { 'color': color, 'data': [xVals, yVals, errVals] } else: self.refData[name] = { 'color': color, 'data': [rData[:,0], rData[:,1], rData[:,2]] } updatePlot()
def onRecordStartRequested(): for channel in channels: item = items[channel] if item.checkState() is QtCore.Qt.CheckState.Checked: recording.append(channel) item.setForeground( QtGui.QBrush( QtGui.QColor('red') ) ) relPath, fileName = filenameGen(self.MEASUREMENT_TYPE) absPath = os.path.join(POOHDATAPATH,relPath) checkPath(absPath) self.fileName = os.path.join(absPath,fileName+'.txt') with open(self.fileName,'w+') as file: file.write( '%s\n' % '\t'.join( ['time'] + [ items[channel].text().replace('\t','_') for channel in recording ] ) ) recordToggle.toggle()
def saveFile(dataToSave,prefix): dir, filePrefix = filenameGen() dir = join(POOHDATAPATH,dir) checkPath(dir) subDir = QtGui.QFileDialog.getExistingDirectory(self,'select folder', dir) desc, valid = QtGui.QInputDialog.getText(self, 'enter file description','description' ) if not valid: desc = None else: saveCSV(dataToSave, subDir=subDir, description=prefix+'_'+desc)
def onRecordStartRequested(): for channel in channels: item = items[channel] if item.checkState() is QtCore.Qt.CheckState.Checked: recording.append(channel) item.setForeground(QtGui.QBrush(QtGui.QColor('red'))) relPath, fileName = filenameGen(self.MEASUREMENT_TYPE) absPath = os.path.join(POOHDATAPATH, relPath) checkPath(absPath) self.fileName = os.path.join(absPath, fileName + '.txt') with open(self.fileName, 'w+') as file: file.write('%s\n' % '\t'.join(['time'] + [ items[channel].text().replace('\t', '_') for channel in recording ])) recordToggle.toggle()
def onReady(): vm_prot = yield getProtocol(VOLTMETER_SERVER) sm_prot = yield getProtocol(STEPPER_MOTOR_SERVER) dg_prot = yield getProtocol(DELAY_GENERATOR_SERVER) vm = VoltMeterClient(vm_prot) sm = StepperMotorClient(sm_prot,POL) dg = DelayGeneratorClient(dg_prot) delays = yield dg.getDelays() pumpTime = delays[MAV_PUMP_QSW] times = np.arange(TIME_START+pumpTime,TIME_STOP+pumpTime+TIME_STEP,TIME_STEP) angles = np.arange(ANGLE_START,ANGLE_STOP+ANGLE_STEP,ANGLE_STEP) channels = yield vm.getChannels() channel = yield selectFromList(channels,'pick the mcp channel') trans = yield selectFromList(['Q3','S3','Q1'],'pick the transition you are at') bsang = yield selectFromList(['020','110'],'pick the angle of the beam splitter') for i in range(REPEAT): for angle in np.concatenate((angles,angles[::-1])): yield sm.setPosition(int(degrees_to_steps(angle))) angleStr = str(angle).zfill(3) relPath, fileName = filenameGen(path.join(trans,'TimeOfFlight','BS'+str(bsang),'HWP'+angleStr)) absPath = path.join(POOHDATAPATH,relPath) checkPath(absPath) logName = path.join(absPath,fileName+'.tsv') thisLog = LogFile(logName) for time in times[::-1]: yield dg.setPartnerDelay(MAV_PROBE_QSW, int(time)) voltage, std = yield vm.getNVoltages(channel,SHOTS) stdom = std/np.sqrt(SHOTS) print (angle,time-pumpTime,voltage,stdom) thisLog.update([time,voltage,stdom]) thisLog.close() print BELL if WAIT_FOR_TUNE: pause(None,None) reactor.stop()
def onReady(): vm_prot = yield getProtocol(VOLTMETER_SERVER) sm_prot = yield getProtocol(STEPPER_MOTOR_SERVER) vm = VoltMeterClient(vm_prot) sm = StepperMotorClient(sm_prot,POL) channels = yield vm.getChannels() channel = yield selectFromList(channels,'pick the mcp channel') trans = yield selectFromList(['Q3','S3','Q1'],'pick the transition you are at') bsang = yield selectFromList(['020','110'],'pick the angle of the beam splitter') # #suffix = yield selectFromList(['pump','unpump'],'are you pumping?') suffix = 'mBeamOff_diffZeroed' numPoints = (ANGLE_STOP-ANGLE_START+1)/ANGLE_STEP totalAcqTime = SWEEPS*2*(SHOTS/10.)*numPoints totalStepTime = ((ANGLE_STEP*SLOPE)/500.)*numPoints print 'ETA is: '+str((totalAcqTime + totalStepTime)/60.)+' minutes.' for sweep in range(SWEEPS): for direction in (FORWARDS,BACKWARDS): relPath, fileName = filenameGen(trans) absPath = path.join(POOHDATAPATH,relPath) checkPath(absPath) logName = path.join(absPath,fileName+'_pol_sweep_'+bsang+'_'+suffix+'.tsv') thisLog = LogFile(logName) for angle in { FORWARDS:forwards, BACKWARDS:backwards }[direction]: yield sm.setPosition(int(degrees_to_steps(angle))) voltage, std = yield vm.getNVoltages(channel,SHOTS) stdom = std/np.sqrt(SHOTS) print (sweep,angle,voltage, stdom) thisLog.update([angle,voltage,stdom]) thisLog.close() reactor.stop()
def onRecordStartRequested(): # build a list of selected channels, record only those, set text color to red for channel in channels: tile = tiles[channel] if tile.checkState() is QtCore.Qt.CheckState.Checked: recording.append(channel) tile.setForeground( QtGui.QBrush( QtGui.QColor('red') ) ) # initialize logfile in today's folder / voltmeter / start time relPath, fileName = filenameGen(self.MEASUREMENT_TYPE) absPath = os.path.join(POOHDATAPATH,relPath) checkPath(absPath) logName = os.path.join(absPath,fileName+'.txt') self.LogFile = LogFile(logName) headerLine = [] for channel in recording: headerLine.append(tiles[channel].text().replace('\t','_')) self.LogFile.update(headerLine) recordToggle.toggle()