Exemplo n.º 1
0
 def prepareTaskStart(self):
     ## check power before starting task.
     if self.ui.checkPowerCheck.isChecked():
         power, valid = self.dev.outputPower()  ## request current power from laser
         if power is None:
             raise HelpfulException("The current laser power for '%s' is unknown." % self.dev.name)
         if not valid:
             powerStr = siFormat(power, suffix='W')
             raise HelpfulException("The current laser power for '%s' (%s) is outside the expected range." % (self.dev.name, powerStr))
Exemplo n.º 2
0
 def outputPowerChanged(self, power, valid):
     if power is None:
         self.ui.outputPowerLabel.setText("?")
     else:
         self.ui.outputPowerLabel.setText(siFormat(power, suffix='W'))
         
     if not valid:
         self.ui.outputPowerLabel.setStyleSheet("QLabel {color: #B00}")
     else:
         self.ui.outputPowerLabel.setStyleSheet("QLabel {color: #000}")
Exemplo n.º 3
0
    def outputPowerChanged(self, power, valid):
        if power is None:
            self.ui.outputPowerLabel.setText("?")
        else:
            self.ui.outputPowerLabel.setText(siFormat(power, suffix='W'))

        if not valid:
            self.ui.outputPowerLabel.setStyleSheet("QLabel {color: #B00}")
        else:
            self.ui.outputPowerLabel.setStyleSheet("QLabel {color: #000}")
Exemplo n.º 4
0
    def calibrate(self, powerMeter, mTime, sTime):
        #meter = str(self.ui.meterCombo.currentText())
        #obj = self.manager.getDevice(scope).getObjective()['name']
        opticState = self.getDeviceStateKey()
        #print "Laser.calibrate() opticState:", opticState
        wavelength = siFormat(self.getWavelength(), suffix='m')
        date = time.strftime('%Y.%m.%d %H:%M', time.localtime())
        index = self.getCalibrationIndex()

        ## Run calibration
        if not self.hasPCell:
            power, transmission = self.runCalibration(powerMeter=powerMeter,
                                                      measureTime=mTime,
                                                      settleTime=sTime)
            #self.setParam(currentPower=power, scopeTransmission=transmission)  ## wrong--power is samplePower, not outputPower.
        else:
            raise Exception("Pockel Cell calibration is not yet implented.")
            #if index.has_key('pCellCalibration') and not self.ui.recalibratePCellCheck.isChecked():
            #power, transmission = self.runCalibration() ## need to tell it to run with open pCell
            #else:
            #minVal = self.ui.minVSpin.value()
            #maxVal = self.ui.maxVSpin.value()
            #steps = self.ui.stepsSpin.value()
            #power = []
            #arr = np.zeros(steps, dtype=[('voltage', float), ('trans', float)])
            #for i,v in enumerate(np.linspace(minVal, maxVal, steps)):
            #p, t = self.runCalibration(pCellVoltage=v) ### returns power at sample(or where powermeter was), and transmission through whole system
            #power.append(p)
            #arr[i]['trans']= t
            #arr[i]['voltage']= v
            #power = (min(power), max(power))
            #transmission = (arr['trans'].min(), arr['trans'].min())
            #arr['trans'] = arr['trans']/arr['trans'].max()
            #minV = arr['voltage'][arr['trans']==arr['trans'].min()]
            #maxV = arr['voltage'][arr['trans']==arr['trans'].max()]
            #if minV < maxV:
            #self.dev.pCellCurve = arr[arr['voltage']>minV * arr['voltage']<maxV]
            #else:
            #self.dev.pCellCurve = arr[arr['voltage']<minV * arr['voltage']>maxV]

            #index['pCellCalibration'] = {'voltage': list(self.dev.pCellCurve['voltage']),
            #'trans': list(self.dev.pCellCurve['trans'])}

        #if scope not in index:
        #index[scope] = {}
        if opticState not in index:
            index[opticState] = {}
        index[opticState][wavelength] = {
            'power': power,
            'transmission': transmission,
            'date': date
        }

        self.writeCalibrationIndex(index)
        self.updateSamplePower()
Exemplo n.º 5
0
 def updateCalibrationList(self):
     self.ui.calibrationList.clear()
     for opticState, wavelength, trans, power, date in self.dev.getCalibrationList(
     ):
         item = QtGui.QTreeWidgetItem([
             str(opticState),
             str(wavelength),
             '%.2f' % (trans * 100) + '%',
             siFormat(power, suffix='W'), date
         ])
         item.key = opticState
         self.ui.calibrationList.addTopLevelItem(item)
Exemplo n.º 6
0
    def calibrate(self, powerMeter, mTime, sTime):
        #meter = str(self.ui.meterCombo.currentText())
        #obj = self.manager.getDevice(scope).getObjective()['name']
        opticState = self.getDeviceStateKey()
        #print "Laser.calibrate() opticState:", opticState
        wavelength = siFormat(self.getWavelength(), suffix='m')
        date = time.strftime('%Y.%m.%d %H:%M', time.localtime())
        index = self.getCalibrationIndex()
        
        ## Run calibration
        if not self.hasPCell:
            power, transmission = self.runCalibration(powerMeter=powerMeter, measureTime=mTime, settleTime=sTime)
            #self.setParam(currentPower=power, scopeTransmission=transmission)  ## wrong--power is samplePower, not outputPower.
        else:
            raise Exception("Pockel Cell calibration is not yet implented.")
            #if index.has_key('pCellCalibration') and not self.ui.recalibratePCellCheck.isChecked():
                #power, transmission = self.runCalibration() ## need to tell it to run with open pCell
            #else:
                #minVal = self.ui.minVSpin.value()
                #maxVal = self.ui.maxVSpin.value()
                #steps = self.ui.stepsSpin.value()
                #power = []
                #arr = np.zeros(steps, dtype=[('voltage', float), ('trans', float)])
                #for i,v in enumerate(np.linspace(minVal, maxVal, steps)):
                    #p, t = self.runCalibration(pCellVoltage=v) ### returns power at sample(or where powermeter was), and transmission through whole system
                    #power.append(p)
                    #arr[i]['trans']= t
                    #arr[i]['voltage']= v
                #power = (min(power), max(power))
                #transmission = (arr['trans'].min(), arr['trans'].min())
                #arr['trans'] = arr['trans']/arr['trans'].max()
                #minV = arr['voltage'][arr['trans']==arr['trans'].min()]
                #maxV = arr['voltage'][arr['trans']==arr['trans'].max()]
                #if minV < maxV:
                    #self.dev.pCellCurve = arr[arr['voltage']>minV * arr['voltage']<maxV]
                #else:
                    #self.dev.pCellCurve = arr[arr['voltage']<minV * arr['voltage']>maxV]
                    
                #index['pCellCalibration'] = {'voltage': list(self.dev.pCellCurve['voltage']), 
                                             #'trans': list(self.dev.pCellCurve['trans'])}
                
            
              
        #if scope not in index:
            #index[scope] = {}
        if opticState not in index:
            index[opticState] = {}
        index[opticState][wavelength] = {'power': power, 'transmission':transmission, 'date': date}

        self.writeCalibrationIndex(index)
        self.updateSamplePower()
Exemplo n.º 7
0
 def prepareTaskStart(self):
     ## check power before starting task.
     if self.ui.checkPowerCheck.isChecked():
         power = self.dev.outputPower()  ## request current power from laser
         valid = self.dev.checkPowerValidity(power)
         if power is None:
             raise HelpfulException(
                 "The current laser power for '%s' is unknown." %
                 self.dev.name)
         if not valid:
             powerStr = siFormat(power, suffix='W')
             raise HelpfulException(
                 "The current laser power for '%s' (%s) is outside the expected range."
                 % (self.dev.name(), powerStr))
Exemplo n.º 8
0
    def laserPowerChanged(self, power, valid):
        #samplePower = self.dev.samplePower(power)  ## we should get another signal for this later..
        #samplePower = power*self.dev.getParam('scopeTransmission')

        ## update label
        if power is None:
            self.ui.outputPowerLabel.setText("?")
        else:
            self.ui.outputPowerLabel.setText(siFormat(power, suffix='W'))

        if not valid:
            self.ui.outputPowerLabel.setStyleSheet("QLabel {color: #B00}")
        else:
            self.ui.outputPowerLabel.setStyleSheet("QLabel {color: #000}")
Exemplo n.º 9
0
 def laserPowerChanged(self, power, valid):
     #samplePower = self.dev.samplePower(power)  ## we should get another signal for this later..
     #samplePower = power*self.dev.getParam('scopeTransmission')
         
     
     ## update label
     if power is None:
         self.ui.outputPowerLabel.setText("?")
     else:
         self.ui.outputPowerLabel.setText(siFormat(power, suffix='W'))
         
     if not valid:
         self.ui.outputPowerLabel.setStyleSheet("QLabel {color: #B00}")
     else:
         self.ui.outputPowerLabel.setStyleSheet("QLabel {color: #000}")
Exemplo n.º 10
0
    def samplePowerChanged(self, power):
        if power is None:
            self.ui.samplePowerLabel.setText("?")
            return
        else:
            self.ui.samplePowerLabel.setText(siFormat(power, suffix='W'))

        if self.dev.hasPCell:
            raise Exception('stub')
        else:
            ## adjust length of pulse to correct for new power
            if self.ui.adjustLengthCheck.isChecked():
                en = {}
                for param in self.powerWidget.ui.waveGeneratorWidget.stimParams:
                    en[param.name()] = param['sum']
                self.powerWidget.setMeta('y', value=power, readonly=True)
                for param in self.powerWidget.ui.waveGeneratorWidget.stimParams:
                    param['sum'] = en[param.name()]
            else:
                self.powerWidget.setMeta('y', value=power, readonly=True)
Exemplo n.º 11
0
    def samplePowerChanged(self, power):
        if power is None:
            self.ui.samplePowerLabel.setText("?")
            return
        else:
            self.ui.samplePowerLabel.setText(siFormat(power, suffix='W'))

        if self.dev.hasPCell:
            raise Exception('stub')
        else:
            ## adjust length of pulse to correct for new power
            if self.ui.adjustLengthCheck.isChecked():
                en = {}
                for param in self.powerWidget.ui.waveGeneratorWidget.stimParams:
                    en[param.name()] = param['sum']
                self.powerWidget.setMeta('y', value=power, readonly=True)
                for param in self.powerWidget.ui.waveGeneratorWidget.stimParams:
                    param['sum'] = en[param.name()]
            else:
                self.powerWidget.setMeta('y', value=power, readonly=True)
Exemplo n.º 12
0
    def getCalibration(self, opticState=None, wavelength=None):
        """Return the calibrated laser transmission for the given objective and wavelength.
        If either argument is None, then it will be replaced with the currently known value.
        Returns None if there is no calibration."""

        if opticState is None:
            opticState = self.getDeviceStateKey()

        if wavelength is None:
            wl = self.getWavelength()
        else:
            wl = wavelength

        ## look up transmission value for this objective in calibration list
        index = self.getCalibrationIndex()
        vals = index.get(opticState, None)
        if vals is None:
            return None
        wl = siFormat(wl, suffix='m')
        vals = vals.get(wl, None)
        if vals is None:
            return None

        return vals['transmission']
Exemplo n.º 13
0
    def getCalibration(self, opticState=None, wavelength=None):
        """Return the calibrated laser transmission for the given objective and wavelength.
        If either argument is None, then it will be replaced with the currently known value.
        Returns None if there is no calibration."""
        
        if opticState is None:
            opticState = self.getDeviceStateKey()
            
        if wavelength is None:
            wl = self.getWavelength()
        else:
            wl = wavelength

        ## look up transmission value for this objective in calibration list
        index = self.getCalibrationIndex()
        vals = index.get(opticState, None)
        if vals is None:
            return None
        wl = siFormat(wl, suffix='m')
        vals = vals.get(wl, None)
        if vals is None:
            return None
        
        return vals['transmission']
Exemplo n.º 14
0
 def updateCalibrationList(self):
     self.ui.calibrationList.clear()
     for opticState, wavelength, trans, power, date in self.dev.getCalibrationList():
         item = QtGui.QTreeWidgetItem([str(opticState), str(wavelength), '%.2f' %(trans*100) + '%', siFormat(power, suffix='W'), date])
         item.key = opticState
         self.ui.calibrationList.addTopLevelItem(item)
Exemplo n.º 15
0
 def samplePowerChanged(self, power):
     if power is None:
         self.ui.samplePowerLabel.setText("?")
     else:
         self.ui.samplePowerLabel.setText(siFormat(power, suffix='W'))
Exemplo n.º 16
0
 def samplePowerChanged(self, power):
     if power is None:
         self.ui.samplePowerLabel.setText("?")
     else:
         self.ui.samplePowerLabel.setText(siFormat(power, suffix='W'))