Пример #1
0
def Scan674(filename,dirname,StartF,EndF,ScanPoints,ScanRepeat,us_RedTime,SCloops,BlueLockOn):
# Import functions:
    reload(Stabilization)
    reload(CavityStabilization)
    plot = gui_exports['plot']
    purgatory = gui_exports['purgatory']
    OpenDDS = f_set['DDS_SETPROG']
    RunDDS = f_set['DDS_RUNPROG']
    ReadUnshelved = f_read['DDS_NBRIGHT']
    ReadAvgBright = f_read['DDS_LASTAVG']
    SetParameter  = f_set['DDS_PARAM']
    ReadParameter  = f_read['DDS_PARAM']
    ScanDone = f_set['AudioAlert_scandone']
    Stab = Stabilization.Stabilization(f_set, f_read, gui_exports)
    const = Stab.LoadConstants(DAQ_HOME+'/scripts/StabilizationConstants')
    CavStab = CavityStabilization.CavityStabilization(f_set, f_read, gui_exports)
    const = CavStab.LoadConstants(DAQ_HOME+'/scripts/CavityStabilizationConstants')
    print "Checking power levels of 422 and 1092 MonoLaser."
    CavStab.MonoLaserLockCheck('421')
    CavStab.MonoLaserLockCheck('1091')
    CavStab.MonoLaserLockCheck('674')
    #### Locking #######
    if BlueLockOn==1:
        bluelockrv, BlueCav = Stab.BlueLock()
# Set up plotting:
    try:
        purgatory(plot.clear)
        purgatory(plot.set_mode, pyextfigure.TWODPLOT)  
        purgatory(plot.set_labels, 'DDS0 FREQ [MHz]', 'Shelving rate','<empty>')
    except Exception,e:
        print time.strftime('%H:%M:%S'),__file__,'Exception occured in purgatory when setting up plot'
	print e
Пример #2
0
	def __init__(self,filename,dirname,IntTime=5000,acc=1e-4,delta=0,Beam=45):
                self.Beam=Beam
                self.ScanDone = f_set['AudioAlert_scandone']
		self.plot=gui_exports['plot']
		self.purgatory=gui_exports['purgatory']
		self.MMAmp=f_read['IonPhotonCounter_MMAMP']
		self.TopmidRead=f_read['3631A_topmid_+6V']
		self.CompRead=f_read['3631A_comp_+6V']
		self.BackquarterRead=f_read['3631A_topright_+25V']
		self.TopmidSet=f_set['3631A_topmid_+6V']
		self.BackquarterSet=f_set['3631A_topright_+25V']
		self.CompSet=f_set['3631A_comp_+6V']
#		self.RFSet=f_set['AGfungen1_Freq']
		self.Magic=f_set['IonPhotonCounter_MAGIC']
		self.InttimeSet=f_set['IonPhotonCounter_INTTIME']
		self.InttimeRead=f_read['IonPhotonCounter_INTTIME']
                self.ReadIonPMTALL=f_read['IonPhotonCounter_ALL']
                self.SetDDS_FREQ1=f_set['DDS_FREQ1']
                self.SetDDS_FREQ2=f_set['DDS_FREQ2']
                self.SetDDS_AMP1=f_set['DDS_AMP1']
                self.SetDDS_FREQ0=f_set['DDS_FREQ0']
                self.SetDDS_AMP0=f_set['DDS_AMP0']
                self.SetParameter  = f_set['DDS_PARAM']
                self.ReadParameter  = f_read['DDS_PARAM']
                self.CavStab = CavityStabilization.CavityStabilization(f_set, f_read, gui_exports)
                self.const = self.CavStab.LoadConstants(DAQ_HOME+'/scripts/CavityStabilizationConstants')

	# saving initial values in case something goes wrong:
		self.Topmid_i=self.TopmidRead()
		self.Comp_i=self.CompRead()
		self.Backquarter_i=self.BackquarterRead()
		self.inttime_i=self.InttimeRead()
		self.inttime=int(IntTime)
		self.acc=acc
		if delta==0:
			self.delta=self.acc*30
		else:
			self.delta=delta
		self.InttimeSet(self.inttime)
		self.Magic(1)
                time.sleep(self.inttime/1000.)

                try:
                    self.purgatory(self.plot.clear)
                    self.purgatory(self.plot.set_mode, pyextfigure.THREEDPLOT)  
                    spotsize=0.0003
                    self.purgatory(self.plot.set_spot_shape,spotsize,spotsize)
                    self.purgatory(self.plot.set_labels,'Topmid', 'Comp','MMamp')
                except Exception,e:
                    print time.strftime('%H:%M:%S'),__file__,'Exception occured in purgatory when setting up plot'
                    print e
Пример #3
0
	def __init__(self,filename,dirname,Freq422,IntTime,Threshold,OvenTime,WaitTime,OvenCurrent):
		reload(Stabilization)
                try:
                    self.plot=gui_exports['plot']
                    self.purgatory=gui_exports['purgatory']
                    self.MMAmp=f_read['IonPhotonCounter_MMAMP']
                    self.Counts=f_read['IonPhotonCounter_COUNT']
                    self.TopmidRead=f_read['3631A_topmid_+6V']
                    self.CompRead=f_read['3631A_comp_+6V']
                    self.TopmidSet=f_set['3631A_topmid_+6V']
                    self.Unshut=f_set['PIShutter_unshut']
                    self.Shut=f_set['PIShutter_shut']
                    self.ScanDone = f_set['AudioAlert_scandone']
                    self.CompSet=f_set['3631A_comp_+6V']
                    self.Magic=f_set['IonPhotonCounter_MAGIC']
                    self.InttimeSet=f_set['IonPhotonCounter_INTTIME']
                    self.InttimeRead=f_read['IonPhotonCounter_INTTIME']
                    self.SetParameter=f_set['DDS_PARAM']
                    self.SetDDS_FREQ1=f_set['DDS_FREQ1']
                    self.SetDDS_AMP1=f_set['DDS_AMP1']
                    self.Say = f_set['AudioAlert_say']
                    self.SetDDS_FREQ0=f_set['DDS_FREQ0']
                    self.SetDDS_AMP0=f_set['DDS_AMP0']
                    self.SetDDS_FREQ2=f_set['DDS_FREQ2']
                    self.ReadParameter=f_read['DDS_PARAM']
                    self.OvenVoltage=f_read['PSUP_3633A_V']
                    self.OvenI=f_set['PSUP_3633A_I']
                    self.F422=f_read['WS7_F3']
                    self.F461=f_read['WS7_F1']
                    self.F674=f_read['WS7_F5']
                    self.inttime_i=self.InttimeRead()
                    self.OvenTime=OvenTime
                    self.inttime=int(IntTime)
                    self.InttimeSet(self.inttime)
                    self.MMAmp_i=self.MMAmp()
                    self.OvenThreshold=0.460
                    self.Threshold=Threshold
                    self.OvenCurrent=OvenCurrent                    
                    self.Freq422=Freq422
                    self.WaitTime=WaitTime
                    self.Stab = Stabilization.Stabilization(f_set, f_read, gui_exports)
                    self.const = self.Stab.LoadConstants(DAQ_HOME+'/scripts/StabilizationConstants')
                    self.CavStab = CavityStabilization.CavityStabilization(f_set, f_read, gui_exports)
                    self.const = self.CavStab.LoadConstants(DAQ_HOME+'/scripts/CavityStabilizationConstants')
                except Exception as e:
                    print "Exception occured while instantiating AutoloadIonClass:",e
                    raise e
Пример #4
0
def Scan422(filename, dirname, StartCav, EndCav, FinishCav, ScanPoints,
            ScanRepeat, DDSFREQ, DDSAMP):

    # Import functions:
    reload(Stabilization)
    plot = gui_exports['plot']
    purgatory = gui_exports['purgatory']
    OpenDDS = f_set['DDS_SETPROG']
    RunDDS = f_set['DDS_RUNPROG']
    ReadUnshelved = f_read['DDS_NBRIGHT']
    ReadAvgBright = f_read['DDS_LASTAVG']
    SetBlueCav = f_set['MonoLasers_421']
    ReadBlueCav = f_read['MonoLasers_421']
    SetDDS_FREQ1 = f_set['DDS_FREQ1']
    SetDDS_FREQ2 = f_set['DDS_FREQ2']
    SetDDS_AMP1 = f_set['DDS_AMP1']
    SetDDS_FREQ0 = f_set['DDS_FREQ0']
    SetDDS_AMP0 = f_set['DDS_AMP0']
    SetParameter = f_set['DDS_PARAM']
    ReadParameter = f_read['DDS_PARAM']
    ReadIonPMT = f_read['IonPhotonCounter_COUNT']
    Stab = Stabilization.Stabilization(f_set, f_read, gui_exports)
    const = Stab.LoadConstants(DAQ_HOME + '/scripts/StabilizationConstants')
    CavStab = CavityStabilization.CavityStabilization(f_set, f_read,
                                                      gui_exports)
    const = CavStab.LoadConstants(DAQ_HOME +
                                  '/scripts/CavityStabilizationConstants')
    #### Locking #######
    #if BlueLockOn==1:
    #       bluelockrv, BlueCav = Stab.BlueLock()
    # Set up plotting:
    try:
        #  purgatory(plot.clear)
        purgatory(plot.set_mode, pyextfigure.TWODPLOT)
        purgatory(plot.set_labels, 'BlueCav[DAC2]', 'IonPhotonCounter_COUNTS',
                  '<empty>')
    except Exception, e:
        print time.strftime(
            '%H:%M:%S'
        ), __file__, 'Exception occured in purgatory when setting up plot'
        print e
Пример #5
0
def CavityResonanceScan(filename, dirname, StartF, EndF, ScanPoints,
                        ScanRepeat, ProbePower):

    # Import functions:
    reload(CavityStabilization)
    plot = gui_exports['plot']
    purgatory = gui_exports['purgatory']
    OpenDDS = f_set['DDS_SETPROG']
    RunDDSandReadTotal = f_read['DDS_RUNNTOTAL']
    SetParameter = f_set['DDS_PARAM']
    ReadParameter = f_read['DDS_PARAM']
    CavFreqSet = f_set['DDS_FREQ2']
    CavBeamSet = f_set['3631A_botleft_+25V']
    ProbePowerRead = f_read['3631A_leftmost_+25V']
    ProbePowerSet = f_set['3631A_leftmost_+25V']
    f421quiet = f_set['MonoLasers_Quiet421']

    ReadCavPMT = f_read['CavityPhotonCounter_COUNT']
    beam0 = 24.
    beam90 = 0.
    maxProbePower = 15.
    # Check that Cavity is locked:
    CavStab = CavityStabilization.CavityStabilization(f_set, f_read,
                                                      gui_exports)
    const = CavStab.LoadConstants(DAQ_HOME +
                                  '/scripts/CavityStabilizationConstants')
    CavStab.CavLockCheck()
    # Set up plotting:
    try:
        #        purgatory(plot.clear)
        purgatory(plot.set_mode, pyextfigure.TWODPLOT)
        purgatory(plot.set_labels, 'DDS2 FREQ [MHz]',
                  'Scatter into cavity [photons]', '<empty>')
    except Exception, e:
        print time.strftime(
            '%H:%M:%S'
        ), __file__, 'Exception occured in purgatory when setting up plot'
def RunScript(filename, dirname, Width, ScanPoints, ScanRepeat, ProbePower, WithSC, LockOption, BlueLockOn, CavLockOn, IonLockOn, IonSet):

    # IonSet = 0 locks to the cavity standing wave antinode
    # IonSet = 1 locks halfway between the node and the antinode
    # IonSet = 2 locks to the node
    
    reload(Stabilization)
    reload(CavityStabilization)
    reload(ReadDDSmemory)
    
    plot = gui_exports['plot']
    purgatory = gui_exports['purgatory']
    ReadParameter  = f_read['DDS_PARAM']
    SetParameter  = f_set['DDS_PARAM']
    CavFreqSet = f_set['DDS_FREQ2']
    ReadCavPMT = f_read['CavityPhotonCounter_COUNT']
    OpenDDS = f_set['DDS_SETPROG']
    RunDDS = f_set['DDS_RUNPROG']
    RunDDSandReadTotal = f_read['DDS_RUNNTOTAL']
    f421quiet = f_set['MonoLasers_Quiet421']
    CavBeamRead = f_read['3631A_botleft_+25V']
    CavBeamSet = f_set['3631A_botleft_+25V']
    ProbePowerRead = f_read['3631A_leftmost_+25V']
    ProbePowerSet = f_set['3631A_leftmost_+25V']
    beam0 = 24.
    beam90 = 0.

    try:
        ##################################################
        # Set up locks
        ##################################################
        CavFreqSet(0)
        
        CavStab = CavityStabilization.CavityStabilization(f_set, f_read, gui_exports)
        const = CavStab.LoadConstants(DAQ_HOME+'/scripts/CavityStabilizationConstants')
        
        bluelockrv, BlueCav = CavStab.BlueLock(BlueLockOn, True)
        cavlockrv, CavCenter = CavStab.CavLock(CavLockOn, True)
        ionlockrv, IonPos = CavStab.IonLock(IonLockOn, IonSet, True)
        
        if WithSC:
            LockOption = int(LockOption)
            Stab = Stabilization.Stabilization(f_set, f_read, gui_exports)
            const = Stab.LoadConstants(DAQ_HOME+'/scripts/StabilizationConstants')
            ramseylockrv, RedCenter = Stab.RamseyLock(LockOption, True)

        ##################################################
        # Set up plotting
        ##################################################
        purgatory(plot.clear)
        purgatory(plot.set_mode, pyextfigure.DUALTWODPLOT)  
        purgatory(plot.set_labels, 'Frequency offset [MHz]', 'Average cavity transmission [counts/s]', 'Differential cavity transmission [counts/s]')
        mydb = data.database(filename, dirname, 1, 10, 'Frequency offset [MHz], Cavity transmission due to lock [counts/s], Cavity transmission at IonPos1 [counts/s], Cavity transmission at IonPos2 [counts/s], bluelockrv, BlueCav, cavlockrv, CavCenter, ionlockrv, IonPos')

        ##################################################
        # Perform the experiment
        ##################################################
        print "Running ..."
        
        FreqOffsetVals = (scipy.array(range(int(ScanPoints))) - (ScanPoints - 1.)/2.)/(ScanPoints - 1)*Width
        
        k = 0.
        DiffCavTransMean = 0.
        for i in range(int(ScanRepeat)):
            if __main__.STOP_FLAG: break

            print "Scan %d"%(i)
            for j in range(len(FreqOffsetVals)):
                if __main__.STOP_FLAG: break
                
                k = k + 1.

                ##################################################
                # Lock step
                ##################################################
                bluelockrv, BlueCav = CavStab.BlueLock(BlueLockOn, False)
                cavlockrv, CavCenter = CavStab.CavLock(CavLockOn, False)
                ionlockrv, IonPos = CavStab.IonLock(IonLockOn, IonSet, False)
                
                if WithSC:
                    ramseylockrv, RedCenter = Stab.RamseyLock(LockOption, False)

                if __main__.STOP_FLAG:
                    break
                    
                ##################################################
                # Measurement step
                ##################################################
                CavBeamSet(beam0)
                ProbePowerSet(ProbePower)
                f421quiet(1)
                time.sleep(0.2)
                
                FreqOffset = FreqOffsetVals[j]
                SetParameter('F_CavityOn', ReadParameter('F_CavityCenter') + FreqOffset)
                
                if WithSC:
                    OpenDDS('prog/CavityTransmissionScan_withSC.pp')
                else:
                    OpenDDS('prog/CavityTransmissionScan.pp')
                RunDDS()
                DDSmemory = ReadDDSmemory.ReadDDSmemory()
                CavityTransmission0 = DDSmemory[0]
                CavityTransmission1 = DDSmemory[1]
                CavityTransmission2 = DDSmemory[2]

                CavFreqSet(0)
                f421quiet(0)
                time.sleep(0.2)
                
                mydb.add_data_point([FreqOffset, CavityTransmission0, CavityTransmission1, CavityTransmission2, bluelockrv, BlueCav, cavlockrv, CavCenter, ionlockrv, IonPos], int(i*len(FreqOffsetVals) + j))
                purgatory(plot.add_point, FreqOffset, 0.5*(CavityTransmission1 + CavityTransmission2) - CavityTransmission0, CavityTransmission2 - CavityTransmission1)
                purgatory(plot.repaint)
                
                DiffCavTransMean = DiffCavTransMean*(k - 1.)/k + (CavityTransmission2 - CavityTransmission1)/k
                print "mean(Differential cavity transmission) = %f counts/s"%(DiffCavTransMean)

    except Exception,e:
        print "Exception occurred in RunScript:", e
        traceback.print_exc()
Пример #7
0
 def __init__(self, filename, dirname, Freq422, IntTime, Threshold,
              OvenTime, WaitTime, OvenCurrent, LoadingTime, NumberOfLoads,
              DoScan422):
     reload(Stabilization)
     try:
         self.plot = gui_exports['plot']
         self.purgatory = gui_exports['purgatory']
         self.dirname = dirname
         self.MMAmp = f_read['IonPhotonCounter_MMAMP']
         self.Counts = f_read['IonPhotonCounter_COUNT']
         self.TopmidRead = f_read['3631A_topmid_+6V']
         self.CompRead = f_read['3631A_comp_+6V']
         self.TopmidSet = f_set['3631A_topmid_+6V']
         self.Unshut = f_set['PIShutter_unshut']
         self.Shut = f_set['PIShutter_shut']
         self.ScanDone = f_set['AudioAlert_scandone']
         self.CompSet = f_set['3631A_comp_+6V']
         self.Magic = f_set['IonPhotonCounter_MAGIC']
         self.InttimeSet = f_set['IonPhotonCounter_INTTIME']
         self.InttimeRead = f_read['IonPhotonCounter_INTTIME']
         self.SetParameter = f_set['DDS_PARAM']
         self.SetDDS_FREQ1 = f_set['DDS_FREQ1']
         self.SetDDS_AMP1 = f_set['DDS_AMP1']
         self.Say = f_set['AudioAlert_say']
         self.SetDDS_FREQ0 = f_set['DDS_FREQ0']
         self.SetDDS_AMP0 = f_set['DDS_AMP0']
         self.SetDDS_FREQ2 = f_set['DDS_FREQ2']
         self.ReadParameter = f_read['DDS_PARAM']
         self.OvenVoltage = f_read['PSUP_3633A_V']
         self.OvenI = f_set['PSUP_3633A_I']
         self.F422 = f_read['WS7_F3']
         self.F461 = f_read['WS7_F1']
         self.F674 = f_read['WS7_F5']
         self.ReadBlueCav = f_read['MonoLasers_421']
         self.DoScan422 = DoScan422
         self.inttime_i = self.InttimeRead()
         self.OvenTime = OvenTime
         self.LoadingTime = LoadingTime
         self.inttime = int(IntTime)
         self.InttimeSet(self.inttime)
         self.MMAmp_i = self.MMAmp()
         self.OvenThreshold = 0.460
         self.RFOutput = f_set['AGfungen1_OutPut']
         self.Threshold = Threshold
         self.OvenCurrent = OvenCurrent
         self.Freq422 = Freq422
         self.WaitTime = WaitTime
         self.NumberOfLoads = NumberOfLoads
         self.Stab = Stabilization.Stabilization(f_set, f_read, gui_exports)
         self.const = self.Stab.LoadConstants(
             DAQ_HOME + '/scripts/StabilizationConstants')
         self.CavStab = CavityStabilization.CavityStabilization(
             f_set, f_read, gui_exports)
         self.const = self.CavStab.LoadConstants(
             DAQ_HOME + '/scripts/CavityStabilizationConstants')
         label = 'OvenCurrent=%f, WaitTime=%f, Threshold=%f, Freq422=%f, IntTime=%.f, NumberOfLoads=%f, LoadingTime=%f, OvenTime=%f' % (
             OvenCurrent, WaitTime, Threshold, Freq422, IntTime,
             NumberOfLoads, LoadingTime, OvenTime)
         label = label + '\n#LoadingTime,Probability of ion loading, Oven voltage Start, Oven voltage End'
         self.mydb = data.database(filename, dirname, 1, 2, label)
         self.purgatory(self.plot.clear)
         self.purgatory(self.plot.set_mode, pyextfigure.TWODPLOT)
         self.purgatory(self.plot.set_labels, 'Exp no', 'Ion loaded?',
                        '<empty>')
     except Exception as e:
         print "Exception occured while instantiating AutoloadIonClass:", e
         raise e
Пример #8
0
def CavityCoolRabi_0deg_IONPOS(filename, dirname, StartT, EndT, CavityOnDF,
                               ReadoutDF, ScanPoints, ScanRepeat, LockOption,
                               CavLockOn, ProbeLockOn, ProbeSet, ProbeSet_SB,
                               IonLockOn, IonSet, IonPosition):
    # IonSet = 0 locks to the cavity standing wave antinode
    # IonSet = 1 locks halfway between the node and the antinode
    # IonSet = 2 locks to the node

    reload(Stabilization)
    reload(CavityStabilization)

    plot = gui_exports['plot']
    purgatory = gui_exports['purgatory']
    OpenDDS = f_set['DDS_SETPROG']
    RunDDS = f_set['DDS_RUNPROG']
    ReadUnshelved = f_read['DDS_NBRIGHT']
    ReadAvgBright = f_read['DDS_LASTAVG']
    SetParameter = f_set['DDS_PARAM']
    ReadParameter = f_read['DDS_PARAM']
    LockOption = int(LockOption)
    CavFreqSet = f_set['DDS_FREQ2']
    f421quiet = f_set['MonoLasers_Quiet421']
    CavBeamSet = f_set['3631A_botleft_+25V']
    ProbePowerRead = f_read['3631A_leftmost_+25V']
    ProbePowerSet = f_set['3631A_leftmost_+25V']
    IonCount = 1
    CavLockThreshold = 0.1
    IonPosSet = f_set['3631A_topright_-25V']

    beam0 = 24.
    beam90 = 0.
    maxProbePower = 15.

    try:
        time.strftime("%H:%M:%S: Doing CavityCoolRabi_0deg_Doppler scan")
        saved_redtime = ReadParameter('us_RedTime')

        ##################################################
        # Set up locks
        ##################################################
        CavFreqSet(0)

        Stab = Stabilization.Stabilization(f_set, f_read, gui_exports)
        const = Stab.LoadConstants(DAQ_HOME +
                                   '/scripts/StabilizationConstants')

        bluelockrv, BlueCav = Stab.BlueLock()
        ramseylockrv, RedCenter = Stab.RamseyLock(LockOption, True)
        rabilockrv, RedPiTime = Stab.RabiLock(LockOption, True)

        CavStab = CavityStabilization.CavityStabilization(
            f_set, f_read, gui_exports)
        const = CavStab.LoadConstants(DAQ_HOME +
                                      '/scripts/CavityStabilizationConstants')

        cavlockrv, CavCenter = CavStab.CavLock(CavLockOn, True)
        probelockrv, ProbePower = CavStab.ProbeLock_0deg(
            ProbeLockOn, ProbeSet, True)
        ionlockrv, IonPos = CavStab.IonLock_0deg(IonLockOn, IonSet, True)
        probelockrv, ProbePower = CavStab.ProbeLock_0deg_SB(
            ProbeLockOn, ProbeSet_SB, True)
        ##################################################
        # Set up plotting
        ##################################################
        #        if IonLockOn > 0:
        #            plotLabel = 'IonPos'
        #        elif CavLockOn > 0:
        #            plotLabel = 'CavCenter'
        #        elif ProbeLockOn > 0:
        #            plotLabel = 'ProbePower'
        #       else:
        #           plotLabel = ['BlueCav', 'RedCenter', 'RedPiTime', 'RedCenter'][LockOption]
        plotLabel = ['BlueCav', 'RedCenter', 'RedPiTime',
                     'RedCenter'][LockOption]

        purgatory(plot.clear)
        purgatory(plot.set_mode, pyextfigure.DUALTWODPLOT)
        purgatory(plot.set_labels, 'Rabi pulse length [us]', 'Shelving rate',
                  plotLabel)
        mydb = data.database(
            filename, dirname, 1, 16,
            'Rabi pulse length [us], P[0], P[1], P[2], bluelockrv, BlueCav, ramseylockrv, RedCenter, rabilockrv, RedPiTime, cavlockrv, CavCenter, probelockrv, ProbePower, ionlockrv, IonPos'
        )

        ##################################################
        # Perform the experiment
        ##################################################
        print "Running..."

        timestep = (1.0 * EndT - StartT) / (ScanPoints - 1)

        for i in range(int(ScanRepeat)):
            if __main__.STOP_FLAG: break

            print "Scan %d" % (i)
            j = 0
            while j <= int(ScanPoints):
                if __main__.STOP_FLAG: break

                ##################################################
                # Lock step
                ##################################################

                ramseylockrv, RedCenter = Stab.RamseyLock(LockOption, False)
                rabilockrv, RedPiTime = Stab.RabiLock(LockOption, False)

                cavlockrv, CavCenter = CavStab.CavLock(CavLockOn, False)
                probelockrv, ProbePower = CavStab.ProbeLock_0deg(
                    ProbeLockOn, ProbeSet, False)
                ionlockrv, IonPos = CavStab.IonLock_0deg(
                    IonLockOn, IonSet, False)
                # Inserted extra probelock step with SB probeset:
                probelockrv, ProbePower = CavStab.ProbeLock_0deg_SB(
                    ProbeLockOn, ProbeSet_SB, False)
                IonPosSet(IonPos + IonPosition)
                print "IonPosSet(IonPos+IonPosition)=IonPosSet(%f+%f)" % (
                    IonPos, IonPosition)
                CavStab.CavLockCheck()
                ##################################################
                # Measurement step
                ##################################################
                #CavBeamSet(beam90)
                CavBeamSet(beam0)
                ProbePowerSet(ProbePower)
                f421quiet(1)
                time.sleep(0.2)
                #                time.sleep(2) # Tried this without any remarkable results.

                timeval = StartT + j * timestep
                OpenDDS('prog/CavityCoolShelving.pp')
                SetParameter('F_CavityOn',
                             ReadParameter('F_CavityCenter') + CavityOnDF)
                SetParameter('F_RedOn', RedCenter + ReadoutDF)
                SetParameter('us_RedTime', timeval)
                RunDDS()  # This is where the magic happens!
                isok = 0
                while not isok:
                    try:
                        sciencerv = ReadUnshelved(hist=True)
                        if not len(sciencerv) < 2:
                            isok = 1
                        else:
                            print "[", __file__, time.asctime(
                            ), "] Empty value in sciencerv? = ", sciencerv
                            print "[", __file__, "] Retrying"
                            sys.stdout.flush()
                            time.sleep(0.5)
                    except Exception, inst:
                        print "[", __file__, time.asctime(
                        ), "] Error in ReadUnshelved Exception: ", inst
                        sys.stdout.flush()
                        time.sleep(0.5)
                if ((IonCount == 1) and (sciencerv[2] > 10)):
                    IonCount = 2
                if (IonCount == 2):
                    plotrv = sciencerv[1]
                else:
                    plotrv = sciencerv[0]

                f421quiet(0)

                ##################################################
                # Lock 422 step
                ##################################################
                bluerv, BlueCav = Stab.BlueLockNoDDSRun()

                #checking if cavity is still locked. If so, plot and save.
                #Otherwise, repeat point
                if CavStab.CavLockCheck():
                    ##################################################
                    # Plot and save step
                    ##################################################
                    mydb.add_data_point([
                        timeval, sciencerv[0], sciencerv[1], sciencerv[2],
                        bluelockrv, BlueCav, ramseylockrv, RedCenter,
                        rabilockrv, RedPiTime, cavlockrv, CavCenter,
                        probelockrv, ProbePower, ionlockrv, IonPos
                    ], int(i * ScanPoints + j))
                    purgatory(plot.add_point, timeval, plotrv, eval(plotLabel))
                    purgatory(plot.repaint)
                    j = j + 1
                else:
                    print "Discarding and repeating measurement"
        SetParameter('us_RedTime', saved_redtime)
Пример #9
0
    def __init__(
        self,
        filename,
        dirname,
        Freq422,
        Threshold,
        OvenTime,
        WaitTime,
        OvenCurrent,
        LoadingTime,
        NumberOfLoads,
    ):
        reload(Stabilization)
        try:
            self.plot = gui_exports['plot']
            self.purgatory = gui_exports['purgatory']
            self.Counts = f_read['XEM6001_PhotonCounter_counts']
            self.TopmidRead = f_read['3631A_topmid_+6V']
            self.CompRead = f_read['3631A_comp_+6V']
            self.TopmidSet = f_set['3631A_topmid_+6V']

            self.Unshut422 = lambda: f_set['PIShutter-RedCryo_422_set_open'](1)
            self.Shut422 = lambda: f_set['PIShutter-RedCryo_422_set_open'](0)
            self.Unshut405 = lambda: f_set['PIShutter-RedCryo_405_set_open'](1)
            self.Shut405 = lambda: f_set['PIShutter-RedCryo_405_set_open'](0)
            self.Unshut461 = lambda: f_set['PIShutter-RedCryo_461_set_open'](1)
            self.Shut461 = lambda: f_set['PIShutter-RedCryo_461_set_open'](0)

            # self.Say = f_set['AudioAlert_say']
            # self.ScanDone = f_set['AudioAlert_scandone']

            self.CompSet = f_set['3631A_comp_+6V']

            self.SetParameter = f_set['DDS_PARAM']
            self.SetDDS_FREQ1 = f_set['DDS_FREQ1']
            self.SetDDS_AMP1 = f_set['DDS_AMP1']
            self.SetDDS_FREQ0 = f_set['DDS_FREQ0']
            self.SetDDS_AMP0 = f_set['DDS_AMP0']
            self.SetDDS_FREQ2 = f_set['DDS_FREQ2']
            self.ReadParameter = f_read['DDS_PARAM']

            self.OvenVoltage = f_read['PSUP_3633A_V']
            self.OvenI = f_set['PSUP_3633A_I']

            self.F422 = f_read['WS7_F3']
            self.F461 = f_read['WS7_F1']
            self.F674 = f_read['WS7_F5']

            self.OvenTime = OvenTime
            self.LoadingTime = LoadingTime
            self.OvenThreshold = 0.460

            self.RFFreq = f_set['AG33250ws2_Freq']
            self.RFAmp = f_set['AG33250ws2_Vamp']

            self.Threshold = Threshold
            self.OvenCurrent = OvenCurrent
            self.Freq422 = Freq422
            self.WaitTime = WaitTime
            self.NumberOfLoads = NumberOfLoads
            self.Stab = Stabilization.Stabilization(f_set, f_read, gui_exports)
            self.const = self.Stab.LoadConstants(
                DAQ_HOME + '/scripts/StabilizationConstants')
            self.CavStab = \
                CavityStabilization.CavityStabilization(f_set, f_read,
                    gui_exports)
            self.const = self.CavStab.LoadConstants(
                DAQ_HOME + '/scripts/CavityStabilizationConstants')
            label = \
                'OvenCurrent=%f, WaitTime=%f, Threshold=%f, Freq422=%f, NumberOfLoads=%f, LoadingTime=%f, OvenTime=%f'\
                 % (
                OvenCurrent,
                WaitTime,
                Threshold,
                Freq422,
                NumberOfLoads,
                LoadingTime,
                OvenTime,
                )
            label = label\
                 + '\n#LoadingTime,Probability of ion loading, Oven voltage Start, Oven voltage End'
            self.mydb = data.database(filename, dirname, 1, 2, label)
            self.purgatory(self.plot.clear)
            self.purgatory(self.plot.set_mode, pyextfigure.TWODPLOT)
            self.purgatory(self.plot.set_labels, 'Exp no', 'Ion loaded?',
                           '<empty>')
        except Exception, e:
            print 'Exception occured while instantiating AutoloadIonClass:', \
                e
            raise e
Пример #10
0
        # Set up locks
        ##################################################
        # This one is known to raise errors:
        isok = 0
        while not isok:
            try:
                CavFreqSet(0)
                isok = 1
            except Exception, e:
                print "[", __file__, time.asctime(
                ), "] A time out error occured while calling CavFreqSet(0):", e
                sys.stdout.flush()
                time.sleep(0.5)
                print "Retrying..."

        CavStab = CavityStabilization.CavityStabilization(
            f_set, f_read, gui_exports)
        const = CavStab.LoadConstants(DAQ_HOME +
                                      '/scripts/CavityStabilizationConstants')

        bluelockrv, BlueCav = CavStab.BlueLock(BlueLockOn, True)
        cavlockrv, CavCenter = CavStab.CavLock(CavLockOn, True)
        ionlockrv, IonPos = CavStab.IonLock_0deg(IonLockOn, IonSet, True)

        ##################################################
        # Set up plotting
        ##################################################
        if IonLockOn > 0:
            plotLabel = 'IonPos'
        elif CavLockOn > 0:
            plotLabel = 'CavCenter'
        else:
def RunScript(filename, dirname, ScanRepeat, BlueLockOn):

    reload(CavityStabilization)
    reload(ReadDDSmemory)

    plot = gui_exports['plot']
    purgatory = gui_exports['purgatory']
    ReadParameter = f_read['DDS_PARAM']
    SetParameter = f_set['DDS_PARAM']
    OpenDDS = f_set['DDS_SETPROG']
    RunDDS = f_set['DDS_RUNPROG']
    RunDDSandReadTotal = f_read['DDS_RUNNTOTAL']

    try:
        ##################################################
        # Set up locks
        ##################################################
        CavStab = CavityStabilization.CavityStabilization(
            f_set, f_read, gui_exports)
        const = CavStab.LoadConstants(DAQ_HOME +
                                      '/scripts/CavityStabilizationConstants')

        bluelockrv, BlueCav = CavStab.BlueLock(BlueLockOn, True)

        ##################################################
        # Perform the experiment
        ##################################################
        print "Running ..."

        bins = range(100)
        counts = scipy.zeros(100)

        for i in range(int(ScanRepeat)):
            if __main__.STOP_FLAG: break

            print i

            ##################################################
            # Lock step
            ##################################################
            bluelockrv, BlueCav = CavStab.BlueLock(BlueLockOn, False)

            ##################################################
            # Measurement step
            ##################################################
            # time.sleep(0.2)

            OpenDDS('prog/OpticalPumpingExperiment.pp')
            RunDDS()
            counts = counts + ReadDDSmemory.ReadDDSmemory()

            ##################################################
            # Update the plot
            ##################################################
            purgatory(plot.clear)
            purgatory(plot.set_mode, pyextfigure.TWODPLOT)
            purgatory(plot.set_labels, 'Bin', 'Counts', '')
            for ii in bins:
                purgatory(plot.add_point, bins[ii], counts[ii], 0.0)
            purgatory(plot.repaint)

        ##################################################
        # Store the results
        ##################################################

        mydb = data.database(filename, dirname, 1, 1, 'Counts')
        for ii in bins:
            mydb.add_data_point([counts[ii]], bins[ii])

    except Exception, e:
        print "Exception occurred in RunScript:", e
        traceback.print_exc()
def CavityStandingWaveScan(filename, dirname, StartV, EndV, ScanPoints,
                           ScanRepeat, ProbeLockOn, ProbeSet, BlueLockOn,
                           CavLockOn, IonLockOn, IonSet, SBcool):
    StartV = abs(StartV)
    EndV = abs(EndV)
    if StartV > 19:
        print "V>19 is out of range"
        return
    if EndV > 19:
        print "V>19 is out of range"
        return
    #Width = abs(Width)
    #if Width > 19:
    #   print "Width > 19 V is out of range."
    #  return
    # IonSet = 0 locks to the cavity standing wave antinode
    # IonSet = 1 locks halfway between the node and the antinode
    # IonSet = 2 locks to the node

    reload(CavityStabilization)

    plot = gui_exports['plot']
    purgatory = gui_exports['purgatory']
    OpenDDS = f_set['DDS_SETPROG']
    RunDDSandReadTotal = f_read['DDS_RUNNTOTAL']
    SetParameter = f_set['DDS_PARAM']
    ReadParameter = f_read['DDS_PARAM']
    CavFreqSet = f_set['DDS_FREQ2']
    f421quiet = f_set['MonoLasers_Quiet421']
    CavBeamSet = f_set['3631A_botleft_+25V']
    ProbePowerRead = f_read['3631A_leftmost_+25V']
    ProbePowerSet = f_set['3631A_leftmost_+25V']
    IonPosSet = f_set['3631A_topright_-25V']
    ScanDone = f_set['AudioAlert_scandone']

    beam0 = 24.
    beam90 = 0.
    maxProbePower = 15.

    try:
        ##################################################
        # Set up locks
        ##################################################
        # This one is known to raise errors:
        isok = 0
        while not isok:
            try:
                CavFreqSet(0)
                isok = 1
            except Exception, e:
                print "[", __file__, time.asctime(
                ), "] A time out error occured while calling CavFreqSet(0):", e
                sys.stdout.flush()
                time.sleep(0.5)
                print "Retrying..."

        if not (IonLockOn):
            IonPosSet(0)

        CavStab = CavityStabilization.CavityStabilization(
            f_set, f_read, gui_exports)
        const = CavStab.LoadConstants(DAQ_HOME +
                                      '/scripts/CavityStabilizationConstants')

        bluelockrv, BlueCav = CavStab.BlueLock(BlueLockOn, True)
        CavStab.CavLockCheck()
        cavlockrv, CavCenter = CavStab.CavLock(CavLockOn, True)
        probelockrv, ProbePower = CavStab.ProbeLock(ProbeLockOn, ProbeSet,
                                                    True)
        ionlockrv, IonPos = CavStab.IonLock(IonLockOn, IonSet, True)
        ##################################################
        # Set up plotting
        ##################################################
        if IonLockOn > 0:
            plotLabel = 'IonPos'
        elif CavLockOn > 0:
            plotLabel = 'CavCenter'
        else:
            plotLabel = 'BlueCav'

        purgatory(plot.clear)
        purgatory(plot.set_mode, pyextfigure.DUALTWODPLOT)
        purgatory(plot.set_labels, 'Ion position [V]',
                  'Scatter into cavity [photons]', plotLabel)
        mydb = data.database(
            filename, dirname, 1, 8,
            'Ion position [V], Scatter into cavity [photons], bluelockrv, BlueCav, cavlockrv, CavCenter, ionlockrv, IonPos'
        )

        ##################################################
        # Perform the experiment
        ##################################################
        print "Running CavityStandingWaveScan4: The experiment..."

        #        IonPositionVals = (scipy.array(range(int(ScanPoints))) - (ScanPoints - 1.))/(ScanPoints - 1.)*Width
        IonPositionVals = -(scipy.linspace(StartV, EndV, int(ScanPoints)))

        for i in range(int(ScanRepeat)):
            if __main__.STOP_FLAG: break

            print "Scan %d" % (i)
            j = 0
            #for j in range(len(IonPositionVals)):
            while j < len(IonPositionVals):
                if __main__.STOP_FLAG: break

                ##################################################
                # Lock step
                ##################################################
                # This line does not change the Blue DDS frequency it only reads the IonPMT level:
                bluelockrv, BlueCav = CavStab.BlueLock(BlueLockOn, False)
                cavlockrv, CavCenter = CavStab.CavLock(CavLockOn, False)
                ionlockrv, IonPos = CavStab.IonLock(IonLockOn, IonSet, False)
                probelockrv, ProbePower = CavStab.ProbeLock(
                    ProbeLockOn, ProbeSet, False)
                CavStab.CavLockCheck()
                if __main__.STOP_FLAG:
                    break

                ##################################################
                # Measurement step
                ##################################################
                IonPosition = IonPositionVals[j]
                # The code below used to turn on the CAVPROBEDDS. Now we do this in the pp script! Hans, 2011-04-10
                # This one is know to raise errors: #RENABLED THIS ON 2011-07-12:
                isok = 0
                while not isok:
                    try:
                        CavFreqSet(ReadParameter('F_CavityCenter'))
                        isok = 1
                    except Exception, e:
                        print "[", __file__, time.asctime(
                        ), "] A time out error occured while calling avFreqSet:", e
                        sys.stdout.flush()
                        time.sleep(0.5)
                        print "Retrying..."

            #   We need to add a line that sets F_CavityOn to F_CavityCenter
#                SetParameter('F_CavityOn',ReadParameter('F_CavityCenter'))
                IonPosSet(IonPos + IonPosition)

                CavBeamSet(beam90)
                ProbePowerSet(ProbePower)

                f421quiet(1)
                time.sleep(0.2)
                UseOLDpp = True  #False
                if SBcool == 1:
                    OpenDDS('prog/ReadCavityPMT_SBC.pp')
                else:
                    if UseOLDpp:
                        OpenDDS('prog/ReadCavityPMT_OLD.pp')
                    else:
                        OpenDDS('/prog/ReadCavityPMT_NEW.pp')
#OpenDDS('prog/ReadCavityPMT_OLD.pp')
                try:
                    CavityScatter = RunDDSandReadTotal()
                except Exception, e:
                    time.strftime(
                        '%H:%M:%S'
                    ), __file__, 'Exception occured while trying to read Cavityscatter. Trying again.'
                    CavityScatter = RunDDSandReadTotal()
                IonPosSet(IonPos)
                #
                # The code below used to turn off the CAVPROBEDDS. Now we do this in the pp script! Hans, 2011-04-10
                # This one is know to raise errors:
                #		isok = 0
                #		while not isok:
                #			try:
                #				CavFreqSet(0)
                #				isok = 1
                #			except Exception, e:
                #				print "[",__file__,time.asctime(),"] A time out error occured while calling CavFreqSet(0):",e
                #				sys.stdout.flush()
                #				time.sleep(0.5)
                #				print "Retrying..."

                f421quiet(0)
                if CavStab.CavLockCheck():
                    mydb.add_data_point([
                        IonPosition, CavityScatter, bluelockrv, BlueCav,
                        cavlockrv, CavCenter, ionlockrv, IonPos
                    ], int(i * len(IonPositionVals) + j))
                    purgatory(plot.add_point, IonPosition, CavityScatter,
                              eval(plotLabel))
                    purgatory(plot.repaint)
                    j = j + 1
                    print "IonPosition = %f V, CavityScatter = %f photons" % (
                        IonPosition, CavityScatter)
                else:
                    print "Discarding and repeating measurement."
Пример #13
0
def RunScript(filename, dirname, LoadIon, DoScan422, DoOptimize1092,
              DoMicroMotionMinimization, DoScan674, DoScan1092, DoRabiShort,
              DoSidebandScan, DoRabiLong, DoCavityResonanceScan,
              DoCavityStandingWaveScan, DoCavitySidebandScan,
              DoCavityCoolingDataRun, BlueLockOn, BlueLockLoop, CavLockCheckOn,
              ProbeLockOn, DoFitAll, DoBlogAll):
    timestart = time.time()
    plot = gui_exports['plot']
    purgatory = gui_exports['purgatory']
    dirname_Lazy = dirname + '/' + filename
    print "Welcome to the Lazy Physicist! Your one stop shop for all things automatic."
    print "Saving in:", dirname_Lazy
    # Putting everything in a separate folder:
    if (os.access(dirname, os.F_OK) == 0):
        os.mkdir(dirname)
    if (os.access(dirname_Lazy, os.F_OK) == 0):
        os.mkdir(dirname_Lazy)
    ScanDone = f_set['AudioAlert_scandone']
    Say = f_set['AudioAlert_say']
    SetBlueCav = f_set['MonoLasers_421']
    ReadBlueCav = f_read['MonoLasers_421']
    Set1092Cav = f_set['MonoLasers_1091']
    Read1092Cav = f_read['MonoLasers_1091']
    SetDDS_FREQ1 = f_set['DDS_FREQ1']
    SetDDS_AMP1 = f_set['DDS_AMP1']
    SetParameter = f_set['DDS_PARAM']
    ReadParameter = f_read['DDS_PARAM']
    reload(CavityStabilization)
    reload(Stabilization)
    Stab = Stabilization.Stabilization(f_set, f_read, gui_exports)
    CavStab = CavityStabilization.CavityStabilization(f_set, f_read,
                                                      gui_exports)
    const = CavStab.LoadConstants(DAQ_HOME +
                                  '/scripts/CavityStabilizationConstants')
    success = 1
    ################## List of tasks: ###################

    # LoadIon:
    if LoadIon == 1 and __main__.STOP_FLAG == False:
        AutoloadIon_filename = 'AutoloadIon' + time.strftime('-%H%M')
        __main__.app.wTree.plotframe.set_label(AutoloadIon_filename)
        Freq422 = 710.96304
        IntTime_Autoload = 1000
        Threshold_Autoload = 1500
        OvenTime = 120
        WaitTime = 15
        OvenCurrent = 2.8
        LoadingTime = 10
        NumberOfLoads = 10
        DoScan422 = 1
        deltatime, NumberOfIons = AutoloadIon2(
            AutoloadIon_filename, dirname_Lazy, Freq422, IntTime_Autoload,
            Threshold_Autoload, OvenTime, WaitTime, OvenCurrent, LoadingTime,
            NumberOfLoads, DoScan422)
        if NumberOfIons == 0:
            __main__.STOP_FLAG = True
# DoScan422:
    if DoScan422 == 1 and __main__.STOP_FLAG == False:
        timestamp = time.strftime('%H%M')
        Scan422_filename = 'Scan422-' + timestamp
        __main__.app.wTree.plotframe.set_label(Scan422_filename)
        SetDDS_FREQ1(ReadParameter('F_BlueHi'))
        SetDDS_AMP1(ReadParameter('A_BlueHi'))
        Stab.BlueLockFreq()
        plot.clear()
        BlueCav = ReadBlueCav()
        ScanPoints = 80
        ScanRepeat = 1
        DDSFREQ = [ReadParameter('F_BlueHi'), ReadParameter('F_BlueOn')]
        DDSAMP = [ReadParameter('A_BlueHi'), ReadParameter('A_BlueOn')]
        daccalibration = 149  # MHz/V
        delta = 20. / daccalibration  # approximate calibration of 20 MHz. (to do both 251 and 231 scans)
        Width = 0.70  # To get rigth width of scan
        offset = -0.10  #0.08 # To get right start of scan
        for i in range(len(DDSFREQ)):
            if __main__.STOP_FLAG: break
            StartCav = BlueCav + offset + i * delta
            EndCav = BlueCav + offset - Width + i * delta
            FinishCav = BlueCav + offset + i * delta
            Scan422(Scan422_filename, dirname_Lazy, StartCav, EndCav,
                    FinishCav, ScanPoints, ScanRepeat, DDSFREQ[i], DDSAMP[i])
            time.sleep(1)
        try:
            reload(hansfit)
            fit = hansfit.fitScan422s(dirname_Lazy, timestamp)
        except Exception, e:
            print "Exception occured while doing hansfit.fitScan422s:", e
            traceback.print_exc(file=sys.stdout)
            print "Continuing anyways"
Пример #14
0
def DopplerCoolRabi(filename, dirname, StartT, EndT, ReadoutDF, ScanPoints,
                    ScanRepeat, LockOption, StabCount):

    reload(CavityStabilization)
    reload(Stabilization)

    plot = gui_exports['plot']
    purgatory = gui_exports['purgatory']
    OpenDDS = f_set['DDS_SETPROG']
    RunDDS = f_set['DDS_RUNPROG']
    ReadUnshelved = f_read['DDS_NBRIGHT']
    ReadAvgBright = f_read['DDS_LASTAVG']
    SetParameter = f_set['DDS_PARAM']
    ReadParameter = f_read['DDS_PARAM']
    LockOption = int(LockOption)
    #  CavFreqSet = f_set['DDS_FREQ2']
    f421quiet = f_set['MonoLasers_Quiet421']
    IonCount = 1
    try:
        saved_redtime = ReadParameter('us_RedTime')

        ##################################################
        # Set up locks
        ##################################################

        Stab = Stabilization.Stabilization(f_set, f_read, gui_exports)
        const = Stab.LoadConstants(DAQ_HOME +
                                   '/scripts/StabilizationConstants')

        bluelockrv, BlueCav = Stab.BlueLockCounts(StabCount)
        ramseylockrv, RedCenter = Stab.RamseyLock(LockOption, True)
        rabilockrv, RedPiTime = Stab.RabiLock(LockOption, True)

        CavStab = CavityStabilization.CavityStabilization(
            f_set, f_read, gui_exports)
        const = CavStab.LoadConstants(DAQ_HOME +
                                      '/scripts/CavityStabilizationConstants')

        ##################################################
        # Set up plotting
        ##################################################
        plotLabel = ['BlueCav', 'RedCenter', 'RedPiTime',
                     'RedCenter'][LockOption]

        purgatory(plot.clear)
        purgatory(plot.set_mode, pyextfigure.DUALTWODPLOT)
        purgatory(plot.set_labels, 'Rabi pulse length [us]', 'Shelving rate',
                  plotLabel)
        mydb = data.database(
            filename, dirname, 1, 10,
            'Rabi pulse length [us], P[0], P[1], P[2], bluelockrv, BlueCav, ramseylockrv, RedCenter, rabilockrv, RedPiTime'
        )

        ##################################################
        # Perform the experiment
        ##################################################
        print "Running DopplerCoolRabi.py..."

        timestep = (1.0 * EndT - StartT) / (ScanPoints - 1)
        # Looping over scans i.e. how many times should we measure the same thing.
        for i in range(int(ScanRepeat)):
            if __main__.STOP_FLAG: break

            print "Scan %d" % (i)
            j = 0
            # Looping over pulse lengths:
            while j <= int(ScanPoints):
                if __main__.STOP_FLAG: break

                ##################################################
                # Lock step
                ##################################################

                ramseylockrv, RedCenter = Stab.RamseyLock(LockOption, False)
                rabilockrv, RedPiTime = Stab.RabiLock(LockOption, False)
                CavLockCheckOn = 0
                if CavLockCheckOn == 1:
                    CavStab.CavLockCheck()
                ##################################################
                # Measurement step
                ##################################################
                f421quiet(1)
                time.sleep(0.05)  # FIXME: Did this break everything? was 0.2.

                timeval = StartT + j * timestep
                OpenDDS('prog/DopplerCoolShelving.pp')
                #                SetParameter('F_CavityOn', ReadParameter('F_CavityCenter') + CavityOnDF)
                # To measure temperature we should compare red and blue sideband i.e. do rabi floppings on both.
                SetParameter('F_RedOn', RedCenter + ReadoutDF)
                SetParameter('us_RedTime', timeval)
                # Run DopplerCoolShelving.pp and get a shelving rate:
                RunDDS()
                isok = 0
                while not isok:
                    try:
                        sciencerv = ReadUnshelved(hist=True)
                        if not len(sciencerv) < 2:
                            isok = 1
                        else:
                            print "[", __file__, time.asctime(
                            ), "] Empty value in sciencerv? = ", sciencerv
                            print "[", __file__, "] Retrying"
                            sys.stdout.flush()
                            time.sleep(0.5)
                    except Exception, inst:
                        print "[", __file__, time.asctime(
                        ), "] Error in ReadUnshelved Exception: ", inst
                        sys.stdout.flush()
                        time.sleep(0.5)
#### Weird code for the case that there is more than one ion. Should be safe to ignore?
                if ((IonCount == 1) and (sciencerv[2] > 10)):
                    IonCount = 2
                if (IonCount == 2):
                    plotrv = sciencerv[1]
                else:
                    plotrv = sciencerv[0]

                f421quiet(0)

                ##################################################
                # Lock 422 step
                ##################################################
                bluerv, BlueCav = Stab.BlueLockNoDDSRunCounts(StabCount)

                if not len(sciencerv) < 3:  #CavLockRead() > CavLockThreshold:
                    ##################################################
                    # Plot and save step
                    ##################################################
                    datapoint = [
                        timeval, sciencerv[0], sciencerv[1], sciencerv[2],
                        bluelockrv, BlueCav, ramseylockrv, RedCenter,
                        rabilockrv, RedPiTime
                    ]
                    datapoint_index = int(i * ScanPoints + j)
                    mydb.add_data_point(datapoint, datapoint_index)
                    purgatory(plot.add_point, timeval, plotrv, eval(plotLabel))
                    purgatory(plot.repaint)
                    j = j + 1
                else:
                    print "Something wrong with sciencerv:", sciencerv
        SetParameter('us_RedTime', saved_redtime)
def RunScript(filename, dirname, Width, ScanPoints, ScanRepeat, ProbePower,
              BlueLockOn, CavLockOn, IonLockOn, IonSet, SBcool):

    Width = abs(Width)
    if Width > 19:
        print "Width > 19 V is out of range."
        return

    # IonSet = 0 locks to the cavity standing wave antinode
    # IonSet = 1 locks halfway between the node and the antinode
    # IonSet = 2 locks to the node

    reload(CavityStabilization)

    plot = gui_exports['plot']
    purgatory = gui_exports['purgatory']
    OpenDDS = f_set['DDS_SETPROG']
    RunDDSandReadTotal = f_read['DDS_RUNNTOTAL']
    SetParameter = f_set['DDS_PARAM']
    ReadParameter = f_read['DDS_PARAM']
    CavFreqSet = f_set['DDS_FREQ2']
    f421quiet = f_set['MonoLasers_Quiet421']
    CavBeamSet = f_set['3631A_botleft_+25V']
    ProbePowerRead = f_read['3631A_leftmost_+25V']
    ProbePowerSet = f_set['3631A_leftmost_+25V']
    IonPosSet = f_set['3631A_topright_-25V']

    beam0 = 24.
    beam90 = 0.
    maxProbePower = 15.

    try:
        ##################################################
        # Set up locks
        ##################################################
        # This one is know to raise errors:
        isok = 0
        while not isok:
            try:
                CavFreqSet(0)
                isok = 1
            except Exception, e:
                print "[", __file__, time.asctime(
                ), "] A time out error occured while calling CavFreqSet(0):", e
                sys.stdout.flush()
                time.sleep(0.5)
                print "Retrying..."

        if not (IonLockOn):
            IonPosSet(0)

        CavStab = CavityStabilization.CavityStabilization(
            f_set, f_read, gui_exports)
        const = CavStab.LoadConstants(DAQ_HOME +
                                      '/scripts/CavityStabilizationConstants')

        bluelockrv, BlueCav = CavStab.BlueLock(BlueLockOn, True)
        cavlockrv, CavCenter = CavStab.CavLock(CavLockOn, True)
        ionlockrv, IonPos = CavStab.IonLock(IonLockOn, IonSet, True)

        ##################################################
        # Set up plotting
        ##################################################
        if IonLockOn > 0:
            plotLabel = 'IonPos'
        elif CavLockOn > 0:
            plotLabel = 'CavCenter'
        else:
            plotLabel = 'BlueCav'

        purgatory(plot.clear)
        purgatory(plot.set_mode, pyextfigure.DUALTWODPLOT)
        purgatory(plot.set_labels, 'Ion position [V]',
                  'Scatter into cavity [photons]', plotLabel)
        mydb = data.database(
            filename, dirname, 1, 8,
            'Ion position [V], Scatter into cavity [photons], bluelockrv, BlueCav, cavlockrv, CavCenter, ionlockrv, IonPos'
        )

        ##################################################
        # Perform the experiment
        ##################################################
        print "Running CavityStandingWaveScan3: The experiment..."

        IonPositionVals = (scipy.array(range(int(ScanPoints))) -
                           (ScanPoints - 1.)) / (ScanPoints - 1.) * Width

        for i in range(int(ScanRepeat)):
            if __main__.STOP_FLAG: break

            print "Scan %d" % (i)
            for j in range(len(IonPositionVals)):
                if __main__.STOP_FLAG: break

                ##################################################
                # Lock step
                ##################################################
                bluelockrv, BlueCav = CavStab.BlueLock(BlueLockOn, False)
                cavlockrv, CavCenter = CavStab.CavLock(CavLockOn, False)
                ionlockrv, IonPos = CavStab.IonLock(IonLockOn, IonSet, False)

                if __main__.STOP_FLAG:
                    break

                ##################################################
                # Measurement step
                ##################################################
                IonPosition = IonPositionVals[j]
                # The code below used to turn on the CAVPROBEDDS. Now we do this in the pp script! Hans, 2011-04-10
                # This one is know to raise errors:
                #		isok = 0
                #		while not isok:
                #			try:
                #				CavFreqSet(ReadParameter('F_CavityCenter'))
                #				isok = 1
                #			except Exception, e:
                #				print "[",__file__,time.asctime(),"] A time out error occured while calling CavFreqSet:",e
                #				sys.stdout.flush()
                #				time.sleep(0.5)
                #				print "Retrying..."

                IonPosSet(IonPos + IonPosition)

                CavBeamSet(beam90)
                ProbePowerSet(ProbePower)
                f421quiet(1)
                time.sleep(0.2)

                if SBcool == 1:
                    OpenDDS('prog/ReadCavityPMT_SBC.pp')
                else:
                    OpenDDS('prog/ReadCavityPMT.pp')
                CavityScatter = RunDDSandReadTotal()

                IonPosSet(IonPos)
                #
                # The code below used to turn off the CAVPROBEDDS. Now we do this in the pp script! Hans, 2011-04-10
                # This one is know to raise errors:
                #		isok = 0
                #		while not isok:
                #			try:
                #				CavFreqSet(0)
                #				isok = 1
                #			except Exception, e:
                #				print "[",__file__,time.asctime(),"] A time out error occured while calling CavFreqSet(0):",e
                #				sys.stdout.flush()
                #				time.sleep(0.5)
                #				print "Retrying..."

                f421quiet(0)

                mydb.add_data_point([
                    IonPosition, CavityScatter, bluelockrv, BlueCav, cavlockrv,
                    CavCenter, ionlockrv, IonPos
                ], int(i * len(IonPositionVals) + j))
                purgatory(plot.add_point, IonPosition, CavityScatter,
                          eval(plotLabel))
                purgatory(plot.repaint)

                print "IonPosition = %f V, CavityScatter = %f photons" % (
                    IonPosition, CavityScatter)
Пример #16
0
def CavityCoolRabi3(filename, dirname, StartT, EndT, CavityOnDF, ReadoutDF,
                    ScanPoints, ScanRepeat, LockOption, CavLockOn, ProbeLockOn,
                    ProbeSet, IonLockOn, IonSet):
    # IonSet = 0 locks to the cavity standing wave antinode
    # IonSet = 1 locks halfway between the node and the antinode
    # IonSet = 2 locks to the node

    reload(Stabilization)
    reload(CavityStabilization)

    plot = gui_exports['plot']
    purgatory = gui_exports['purgatory']
    OpenDDS = f_set['DDS_SETPROG']
    RunDDS = f_set['DDS_RUNPROG']
    ReadUnshelved = f_read['DDS_NBRIGHT']
    ReadAvgBright = f_read['DDS_LASTAVG']
    SetParameter = f_set['DDS_PARAM']
    ReadParameter = f_read['DDS_PARAM']
    LockOption = int(LockOption)
    CavFreqSet = f_set['DDS_FREQ2']
    f421quiet = f_set['MonoLasers_Quiet421']
    CavBeamSet = f_set['3631A_botleft_+25V']
    ProbePowerRead = f_read['3631A_leftmost_+25V']
    ProbePowerSet = f_set['3631A_leftmost_+25V']
    IonCount = 1
    CavLockRead = f_read['DMM_top_V']
    CavLockThreshold = 1.0

    beam0 = 24.
    beam90 = 0.
    maxProbePower = 15.

    try:
        saved_redtime = ReadParameter('us_RedTime')

        ##################################################
        # Set up locks
        ##################################################
        CavFreqSet(0)

        Stab = Stabilization.Stabilization(f_set, f_read, gui_exports)
        const = Stab.LoadConstants(DAQ_HOME +
                                   '/scripts/StabilizationConstants')

        bluelockrv, BlueCav = Stab.BlueLock()
        ramseylockrv, RedCenter = Stab.RamseyLock(LockOption, True)
        rabilockrv, RedPiTime = Stab.RabiLock(LockOption, True)

        CavStab = CavityStabilization.CavityStabilization(
            f_set, f_read, gui_exports)
        const = CavStab.LoadConstants(DAQ_HOME +
                                      '/scripts/CavityStabilizationConstants')

        cavlockrv, CavCenter = CavStab.CavLock(CavLockOn, True)
        probelockrv, ProbePower = CavStab.ProbeLock(ProbeLockOn, ProbeSet,
                                                    True)
        ionlockrv, IonPos = CavStab.IonLock(IonLockOn, IonSet, True)

        ##################################################
        # Set up plotting
        ##################################################
        if IonLockOn > 0:
            plotLabel = 'IonPos'
        elif CavLockOn > 0:
            plotLabel = 'CavCenter'
        elif ProbeLockOn > 0:
            plotLabel = 'ProbePower'
        else:
            plotLabel = ['BlueCav', 'RedCenter', 'RedPiTime',
                         'RedCenter'][LockOption]

        purgatory(plot.clear)
        purgatory(plot.set_mode, pyextfigure.DUALTWODPLOT)
        purgatory(plot.set_labels, 'Rabi pulse length [us]', 'Shelving rate',
                  plotLabel)
        mydb = data.database(
            filename, dirname, 1, 16,
            'Rabi pulse length [us], P[0], P[1], P[2], bluelockrv, BlueCav, ramseylockrv, RedCenter, rabilockrv, RedPiTime, cavlockrv, CavCenter, probelockrv, ProbePower, ionlockrv, IonPos'
        )

        ##################################################
        # Perform the experiment
        ##################################################
        print "Running..."

        timestep = (1.0 * EndT - StartT) / (ScanPoints - 1)

        for i in range(int(ScanRepeat)):
            if __main__.STOP_FLAG: break

            print "Scan %d" % (i)
            j = 0
            while j <= int(ScanPoints):
                if __main__.STOP_FLAG: break

                #checking if cavity is locked before measurement:
                #if locked continue with measurement, if not, wait for it
                #to be relocked and then wait 5sec before proceeding with measurement
                CavLockOk = 0
                CavLockPast = 1
                while CavLockOk == 0:
                    if CavLockRead() > CavLockThreshold:
                        CavLockOk = 1
                        if CavLockPast == 0:
                            print "resuming measurement in 5 sec..."
                            time.sleep(1)
                            print "resuming measurement in 4 sec..."
                            time.sleep(1)
                            print "resuming measurement in 3 sec..."
                            time.sleep(1)
                            print "resuming measurement in 2 sec..."
                            time.sleep(1)
                            print "resuming measurement in 1 sec..."
                            time.sleep(1)
                            print "Cavity relocked"
                        else:
                            print "Cavity lock ok"
                    else:
                        print "Cavity unlocked!"
                        CavLockPast = 0

                ##################################################
                # Lock step
                ##################################################

                ramseylockrv, RedCenter = Stab.RamseyLock(LockOption, False)
                rabilockrv, RedPiTime = Stab.RabiLock(LockOption, False)

                cavlockrv, CavCenter = CavStab.CavLock(CavLockOn, False)
                probelockrv, ProbePower = CavStab.ProbeLock(
                    ProbeLockOn, ProbeSet, False)
                ionlockrv, IonPos = CavStab.IonLock(IonLockOn, IonSet, False)

                ##################################################
                # Measurement step
                ##################################################
                CavBeamSet(beam90)
                ProbePowerSet(ProbePower)
                f421quiet(1)
                time.sleep(0.2)

                timeval = StartT + j * timestep
                OpenDDS('prog/CavityCoolShelving.pp')
                SetParameter('F_CavityOn',
                             ReadParameter('F_CavityCenter') + CavityOnDF)
                SetParameter('F_RedOn', RedCenter + ReadoutDF)
                SetParameter('us_RedTime', timeval)
                RunDDS()
                isok = 0
                while not isok:
                    try:
                        sciencerv = ReadUnshelved(hist=True)
                        if not len(sciencerv) < 2:
                            isok = 1
                        else:
                            print "[", __file__, time.asctime(
                            ), "] Empty value in sciencerv? = ", sciencerv
                            print "[", __file__, "] Retrying"
                            sys.stdout.flush()
                            time.sleep(0.5)
                    except Exception, inst:
                        print "[", __file__, time.asctime(
                        ), "] Error in ReadUnshelved Exception: ", inst
                        sys.stdout.flush()
                        time.sleep(0.5)
                if ((IonCount == 1) and (sciencerv[2] > 10)):
                    IonCount = 2
                if (IonCount == 2):
                    plotrv = sciencerv[1]
                else:
                    plotrv = sciencerv[0]

                f421quiet(0)

                ##################################################
                # Lock 422 step
                ##################################################
                bluerv, BlueCav = Stab.BlueLockNoDDSRun()

                #checking if cavity is still locked. If so, plot and save.
                #Otherwise, repeat point
                if CavLockRead() > CavLockThreshold:
                    ##################################################
                    # Plot and save step
                    ##################################################
                    mydb.add_data_point([
                        timeval, sciencerv[0], sciencerv[1], sciencerv[2],
                        bluelockrv, BlueCav, ramseylockrv, RedCenter,
                        rabilockrv, RedPiTime, cavlockrv, CavCenter,
                        probelockrv, ProbePower, ionlockrv, IonPos
                    ], int(i * ScanPoints + j))
                    purgatory(plot.add_point, timeval, plotrv, eval(plotLabel))
                    purgatory(plot.repaint)
                    j = j + 1
                else:
                    print "cavity unlocked - discarding and repeating measurement"
        SetParameter('us_RedTime', saved_redtime)
Пример #17
0
def RunScript(filename, dirname, PARAMETERS, ScanPoints, ScanRepeat, LockOption):

    reload(Stabilization)
    reload(CavityStabilization)

    plot = gui_exports['plot']
    purgatory = gui_exports['purgatory']
    LockOption = int(LockOption)
    IonCount = 1
    CavLockRead = f_read['DMM_top_V']
    CavLockTreshold = 1.0
    try:
        Stab = Stabilization.Stabilization(f_set, f_read, gui_exports)
        const = Stab.LoadConstants(DAQ_HOME+'/scripts/StabilizationConstants')

        CavStab = CavityStabilization.CavityStabilization(f_set, f_read, gui_exports)
        const = CavStab.LoadConstants(DAQ_HOME+'/scripts/CavityStabilizationConstants')
        
        plotLabels = ['BlueCav', 'CavOffset', 'RedPiTime', 'RedPiTime']

        # Locking step

        # set up plotting
        print "Running..."
        purgatory(plot.clear)
        purgatory(plot.set_mode, pyextfigure.DUALTWODPLOT)  
        ## label the x-axis as appropriate
        purgatory(plot.set_labels, 'XLABEL', 'Shelving Rate', plotLabels[LockOption & 3])


        # Perform the experiment
        ## define local variables etc as needed
        ## save and then set some global parameters that aren't changed during scan
             
        for i in range(int(ScanRepeat)):
            if __main__.STOP_FLAG: break
            
            print "Scan %d"%(i)
            time.sleep(1)
            CavLockOk=0
            CavLockPast=1
            #        print "CavLockRead()"
            while CavLockOk==0:
                if CavLockRead() > CavLockTreshold:
                    CavLockOk=1
                    if CavLockPast==0:
                        print "resuming measurement in 5 sec..."
                        time.sleep(1)
                        print "resuming measurement in 4 sec..."
                        time.sleep(1)
                        print "resuming measurement in 3 sec..."
                        time.sleep(1)
                        print "resuming measurement in 2 sec..."
                        time.sleep(1)
                        print "resuming measurement in 1 sec..."
                        time.sleep(1)
                        print "Cavity relocked"
                    else:
                        print "Cavity lock ok"
                else:
                    print "Cavity unlocked!"
                    CavLockPast=0
                
            for j in range(int(ScanPoints)*3):
                if __main__.STOP_FLAG: break


                # Science step
                ## more local var defs, iterators etc
                ## open the desired pulse sequence, e.g. Shelving.pp
                ## set some parameters



                ## identify the x-variable to plot

                ## anything else: fitting, etc

        ## restore global parameters and any other changed parameters to reasonable values

    except Exception,e:
        print "Exception occurred in RunScript:", e
        traceback.print_exc()
def RunScript(filename, dirname, Width, ScanPoints, ScanRepeat, ProbePower, BlueLockOn, CavLockOn, IonLockOn, IonSet):
    
    Width = abs(Width)
    if Width > 19:
        print "Width > 19 V is out of range."
        return

    # IonSet = 0 locks to the cavity standing wave antinode
    # IonSet = 1 locks halfway between the node and the antinode
    # IonSet = 2 locks to the node
    
    reload(CavityStabilization)
    
    
    plot = gui_exports['plot']
    purgatory = gui_exports['purgatory']
    OpenDDS = f_set['DDS_SETPROG']
    RunDDSandReadTotal = f_read['DDS_RUNNTOTAL']
    SetParameter  = f_set['DDS_PARAM']
    ReadParameter  = f_read['DDS_PARAM']
    CavFreqSet = f_set['DDS_FREQ2']
    f421quiet = f_set['MonoLasers_Quiet421']
    CavBeamSet = f_set['3631A_botleft_+25V']
    ProbePowerRead = f_read['3631A_leftmost_+25V']
    ProbePowerSet = f_set['3631A_leftmost_+25V']
    IonPosSet = f_set['3631A_topright_-25V']
    
    beam0 = 24.
    beam90 = 0.
    maxProbePower = 15.

    try:
        ##################################################
        # Set up locks
        ##################################################
        CavFreqSet(0)
        if not(IonLockOn):
            IonPosSet(0)
            
        CavStab = CavityStabilization.CavityStabilization(f_set, f_read, gui_exports)
        const = CavStab.LoadConstants(DAQ_HOME+'/scripts/CavityStabilizationConstants')
        
        bluelockrv, BlueCav = CavStab.BlueLock(BlueLockOn, True)
        cavlockrv, CavCenter = CavStab.CavLock(CavLockOn, True)
        ionlockrv, IonPos = CavStab.IonLock(IonLockOn, IonSet, True)

        ##################################################
        # Set up plotting
        ##################################################
        if IonLockOn > 0:
            plotLabel = 'IonPos'
        elif CavLockOn > 0:
            plotLabel = 'CavCenter'
        else:
            plotLabel = 'BlueCav'
        
        purgatory(plot.clear)
        purgatory(plot.set_mode, pyextfigure.DUALTWODPLOT)  
        purgatory(plot.set_labels, 'Ion position [V]', 'Scatter into cavity [photons]', plotLabel)
        mydb = data.database(filename, dirname, 1, 8, 'Ion position [V], Scatter into cavity [photons], bluelockrv, BlueCav, cavlockrv, CavCenter, ionlockrv, IonPos')

        ##################################################
        # Perform the experiment
        ##################################################
        print "Running ..."
        
        IonPositionVals = (scipy.array(range(int(ScanPoints))) - (ScanPoints - 1.))/(ScanPoints - 1.)*Width
        
        for i in range(int(ScanRepeat)):
            if __main__.STOP_FLAG: break

            print "Scan %d"%(i)
            for j in range(len(IonPositionVals)):
                if __main__.STOP_FLAG: break

                ##################################################
                # Lock step
                ##################################################
                bluelockrv, BlueCav = CavStab.BlueLock(BlueLockOn, False)
                cavlockrv, CavCenter = CavStab.CavLock(CavLockOn, False)
                ionlockrv, IonPos = CavStab.IonLock(IonLockOn, IonSet, False)

                if __main__.STOP_FLAG:
                    break
                    
                ##################################################
                # Measurement step
                ##################################################
                IonPosition = IonPositionVals[j]
                CavFreqSet(ReadParameter('F_CavityCenter'))
                IonPosSet(IonPos + IonPosition)
                
                CavBeamSet(beam90)
                ProbePowerSet(ProbePower)
                f421quiet(1)
                time.sleep(0.2)
                
                OpenDDS('prog/ReadCavityPMT.pp')
                CavityScatter = RunDDSandReadTotal()

                IonPosSet(IonPos)
                CavFreqSet(0)
                f421quiet(0)

                mydb.add_data_point([IonPosition, CavityScatter, bluelockrv, BlueCav, cavlockrv, CavCenter, ionlockrv, IonPos], int(i*len(IonPositionVals) + j))
                purgatory(plot.add_point, IonPosition, CavityScatter, eval(plotLabel))
                purgatory(plot.repaint)

                print "IonPosition = %f V, CavityScatter = %f photons"%(IonPosition, CavityScatter)

    except Exception,e:
        print "Exception occurred in RunScript:", e
        traceback.print_exc()
Пример #19
0
def twoDMicroMotionScan(filename, dirname, StartX, EndX, FinishX, StartY, EndY,
                        FinishY, StepsX, StepsY, Pause, Beam):

    # Import functions:
    reload(Stabilization)
    Beam = int(Beam)
    plot = gui_exports['plot']
    purgatory = gui_exports['purgatory']
    ScanDone = f_set['AudioAlert_scandone']
    OpenDDS = f_set['DDS_SETPROG']
    RunDDS = f_set['DDS_RUNPROG']
    ReadUnshelved = f_read['DDS_NBRIGHT']
    ReadAvgBright = f_read['DDS_LASTAVG']
    SetBlueCav = f_set['MonoLasers_421']
    ReadBlueCav = f_read['MonoLasers_421']
    Quiet = f_set['MonoLasers_Quiet421']
    SetDDS_FREQ1 = f_set['DDS_FREQ1']
    SetDDS_FREQ2 = f_set['DDS_FREQ2']
    SetDDS_AMP1 = f_set['DDS_AMP1']
    SetDDS_FREQ0 = f_set['DDS_FREQ0']
    SetDDS_AMP0 = f_set['DDS_AMP0']
    SetParameter = f_set['DDS_PARAM']
    ReadParameter = f_read['DDS_PARAM']
    ReadIonPMT = f_read['IonPhotonCounter_COUNT']
    ReadMMAMP = f_read['IonPhotonCounter_MMAMP']
    ReadIonPMTALL = f_read['IonPhotonCounter_ALL']
    InttimeSet = f_set['IonPhotonCounter_INTTIME']
    InttimeRead = f_read['IonPhotonCounter_INTTIME']
    inttime_i = InttimeRead()
    Magic = f_set['IonPhotonCounter_MAGIC']
    #####
    #    xlabel='3631A_topright_+25V' # Back quarter
    xlabel = '3631A_topmid_+6V'  # Top mid
    ylabel = '3631A_comp_+6V'  # Comp
    print time.strftime("%H:%M:%S"), "Scanning", xlabel, " and ", ylabel
    #####
    SetX = f_set[xlabel]
    SetY = f_set[ylabel]
    Stab = Stabilization.Stabilization(f_set, f_read, gui_exports)
    const = Stab.LoadConstants(DAQ_HOME + '/scripts/StabilizationConstants')
    plotlabelz = 'fftmax'
    #### Locking #######
    BlueLockOn = 0
    if BlueLockOn == 1:
        bluelockrv, BlueCav = Stab.BlueLock()

    CavStab = CavityStabilization.CavityStabilization(f_set, f_read,
                                                      gui_exports)
    const = CavStab.LoadConstants(DAQ_HOME +
                                  '/scripts/CavityStabilizationConstants')
    # Set up plotting:
    try:
        purgatory(plot.clear)
        purgatory(plot.set_mode, pyextfigure.THREEDPLOT)
        purgatory(plot.set_labels, xlabel, ylabel, plotlabelz)
        StepSizeX = (EndX - StartX) / (StepsX)
        StepSizeY = (EndY - StartY) / (StepsY)
        purgatory(plot.set_spot_shape, abs(StepSizeX), abs(StepSizeY))
    except Exception, e:
        print time.strftime(
            '%H:%M:%S'
        ), __file__, 'Exception occured in purgatory when setting up plot'
        print e