示例#1
0
    def initialize(self, cxn, context, ident):
        self.ident = ident
        self.cxn = labrad.connect(name = 'High Fidelity')
        self.cxnwlm = labrad.connect(multiplexer_config.ip, name = 'High Fidelity', password = '******')


        self.wm = self.cxnwlm.multiplexerserver
        self.pulser = self.cxn.pulser
        self.grapher = self.cxn.grapher
        self.dv = self.cxn.data_vault
        self.HPA = self.cxn.hp8672a_server
        self.HPB = self.cxn.hp8657b_server
        self.pv = self.cxn.parametervault
        self.shutter = self.cxn.arduinottl
        self.pb = self.cxn.protectionbeamserver

        # Define variables to be used
        self.p = self.parameters
        self.cycles = self.p.HighFidelity.Sequences_Per_Point
        self.dc_thresh = self.p.HighFidelity.dc_threshold
        self.correct_ML = self.p.HighFidelity.MaximumLikelihood
        self.disc = self.pv.get_parameter('StateReadout','state_readout_threshold')
        self.state_detection = self.p.RabiFlopping.State_Detection
        self.m_sequence = self.p.RabiFlopping.microwave_pulse_sequence
        self.shelve_time = self.p.Shelving133_Sub.shelving_duration

        if self.m_sequence == 'single':
            self.LO_freq = self.p.Microwaves133.LO_frequency
            self.pi_time = self.p.Microwaves133.microwave_duration
            self.microwave_power = self.p.Microwaves133.amplitude_microwaves
        elif self.m_sequence == 'composite_1':
            self.LO_freq = self.p.Composite1.LO_frequency
            self.pi_time = self.p.Composite1.microwave_duration
            self.microwave_power = self.p.Composite1.amplitude_microwaves

        self.total_exps = 0
        #print self.disc
        # Define contexts for saving data sets
        self.c_prob = self.cxn.context()
        self.c_hist_bright = self.cxn.context()
        self.c_hist_dark = self.cxn.context()
        self.c_time_tags_bright = self.cxn.context()
        self.c_time_tags_dark = self.cxn.context()
        self.c_ML_prob = self.cxn.context()
        self.c_ML_hist_dark = self.cxn.context()
        self.c_ML_hist_bright = self.cxn.context()

        # Need to map the gpib address to the labrad conection
        self.device_mapA = {}
        self.device_mapB = {}
        self.get_device_map()
        self.HPA.select_device(self.device_mapA['GPIB0::19'])

        if self.correct_ML == 'True':
            self.ML = MaximumLikelihood()
            self.ML.detection_time = self.p.ShelvingStateDetection.state_detection_duration['s']
            self.ML.mean_dark = self.p.HighFidelity.Mean_Dark
            self.ML.mean_bright = self.p.HighFidelity.Mean_Bright

        self.set_up_datavault()
示例#2
0
    def connect(self):

        # otherwise, prompt user for password
        import labrad
        firstAttempt=True
        success=connect=False

        # check to see if the password has been set in the environment
        try:
            pwd = os.environ["LABRADPASSWORD"]
            if pwd == None:
                print("Warning: environment variable <LABRADPASSWORD> has not yet been set")
                raise
            self.connection = labrad.connect(password = pwd)
            success = True
            connect = True
        except:
            print("Error: LabRAD is not running properly.")


        while not success:
            if firstAttempt:pwd,ok=gui.QInputDialog.getText(self,"Password","Enter LabRAD password")
            else:pwd,ok=gui.QInputDialog.getText(self,"Password","Something went wrong. Either thepassword\nwas incorrect or LabRAD isn't running.")
            try:
                self.connection = labrad.connect(password = str(pwd))
                success=True;connect=True
            except:
                if pwd=='exit':success=True
            firstAttempt=False
        if connect:
            self.password = str(pwd)
            self.doUI()
        else:
            gui.qApp.quit()
示例#3
0
    def initialize(self, cxn, context, ident):
        self.ident = ident
        self.cxn = labrad.connect(name = 'Filament Loading')
        #self.cxnwlm = labrad.connect('10.97.111.8', name = 'Linescan Camera', password = '******')
        self.cxnHP = labrad.connect('bender', name = 'filament loading', password = '******')
        self.trap = self.cxn.trap_server
        self.hp = self.cxnHP.hp6033a_server
        self.hp.select_device(0)
        self.dv = self.cxn.data_vault
        self.hpa = self.cxnHP.hp8672a_server
        #self.cam = self.cxn.andor_server

        self.current = self.parameters.Filament_Loading.Loading_Current
        self.voltage = self.parameters.Filament_Loading.Loading_Voltages
        self.load_time = self.parameters.Filament_Loading.Loading_Time

        self.toggle_rf = self.parameters.Filament_Loading.Toggle_RF
        self.a_ramp = self.parameters.Filament_Loading.A_Ramp
        self.a_ramp_voltage = self.parameters.Filament_Loading.A_Ramp_Voltage
        self.a_ramp_time = self.parameters.Filament_Loading.A_Ramp_Time
        self.heating = self.parameters.Filament_Loading.Even_Isotope_Heating_While_Loading

        # Need to map the gpib address to the labrad context number
        self.device_mapA = {}
        self.get_device_map()
示例#4
0
 def __init__(self, seqParams, exprtParams):
     #connect and define servers we'll be using
     self.cxn = labrad.connect()
     self.cxnlab = labrad.connect('192.168.169.49') #connection to labwide network
     self.dv = self.cxn.data_vault
     self.pulser = self.cxn.pulser
     self.seqP = Bunch(**seqParams)
     self.expP = Bunch(**exprtParams)
 def initialize(self, cxn, context, ident):
     self.ident = ident
     self.laserport = 8
     self.cxn = labrad.connect(name = '369 Wavemeter Line Scan')
     self.cxnwlm = labrad.connect('10.97.112.2', name = '369 Scan')
     self.wm = self.cxnwlm.multiplexerserver  
     self.dv = self.cxn.data_vault      
     self.pv = self.cxn.parametervault
     self.pmt = self.cxn.normalpmtflow
 def __init__(self, seqParams, exprmtParams):
     self.cxn = labrad.connect()
     self.cxnlab = labrad.connect('192.168.169.49') # labwide network
     
     self.dv = self.cxn.data_vault
     self.pulser = self.cxn.pulser
     self.seqP = Bunch(**seqParams)
     self.expP = Bunch(**exprtParams)
     self.Binner = None
示例#7
0
 def import_labrad(self):
     import labrad
     self.cxn = cxn = labrad.connect()
     self.cxnlab = labrad.connect('192.168.169.49') #connection to labwide network
     self.dv = self.cxn.data_vault
     self.readout_save_context = self.cxn.context()
     self.histogram_save_context = self.cxn.context()
     self.pulser = self.cxn.pulser
     self.sem = cxn.semaphore
     self.dv = cxn.data_vault
     self.p = self.populate_parameters(self.sem, self.experimentPath)
示例#8
0
    def initialize(self, cxn, context, ident):
        self.ident = ident
        self.cxn = labrad.connect(name = 'Mass Spec')
        self.rga_cxn = labrad.connect('flexo', password = '******')
        self.rga = self.rga_cxn.rga_server
        self.scalar = self.cxn.sr430_scalar_server
        self.scalar.select_device(0)
        self.dv = self.cxn.data_vault
        self.grapher = self.cxn.grapher

        self.p = self.parameters.Mass_Spec
示例#9
0
 def __init__(self, seqParams, exprtParams, analysisParams):
     #connect and define servers we'll be using
     self.cxn = labrad.connect()
     self.cxnlab = labrad.connect('192.168.169.49') #connection to labwide network
     self.synth = self.cxnlab.rohdeschwarz_server
     self.synth.select_device('lab-49 GPIB Bus - USB0::0x0AAD::0x0054::104542')
     self.initfreq = self.synth.frequency()
     self.dv = self.cxn.data_vault
     self.pulser = self.cxn.pulser
     self.seqP = Bunch(**seqParams)
     self.expP = Bunch(**exprtParams)
     self.anaP = Bunch(**analysisParams)
示例#10
0
    def initialize(self, cxn, context, ident):
        self.ident = ident
        self.cxn = labrad.connect(name = 'Loading Curve TOF')
        self.cxnHP = labrad.connect('bender', name = 'loading curve tof', password = '******')
        self.trap = self.cxn.trap_server
        self.hp = self.cxnHP.hp6033a_server
        self.hp.select_device(0)
        self.dv = self.cxn.data_vault
        self.grapher = self.cxn.grapher

        self.set_up_parameters()
        self.set_up_tof_folder()
示例#11
0
 def __init__(self, seqParams, exprtParams):
    #connect and define servers we'll be using
     self.cxn = labrad.connect()
     self.cxnlab = labrad.connect('192.168.169.49') #connection to labwide network
     self.dv = self.cxn.data_vault
     self.rf = self.cxn.trap_drive
     self.pulser = self.cxn.pulser
     self.pmt = self.cxn.normalpmtflow
     self.seqP = Bunch(**seqParams)
     self.expP = Bunch(**exprtParams)
     self.xtal = Crystallizer(self.pulser, self.pmt, self.rf)
     self.Binner = None
示例#12
0
    def initialize(self, cxn, context, ident):
        self.ident = ident
        self.cxn = labrad.connect(name = 'Rabi Flopping')
        self.cxnwlm = labrad.connect(multiplexer_config.ip, name = 'Rabi Flopping', password = '******')


        self.wm = self.cxnwlm.multiplexerserver
        self.pulser = self.cxn.pulser
        self.grapher = self.cxn.grapher
        self.dv = self.cxn.data_vault
        self.HPA = self.cxn.hp8672a_server
        self.HPB = self.cxn.hp8657b_server
        self.pv = self.cxn.parametervault
        self.shutter = self.cxn.arduinottl
        self.pb = self.cxn.protectionbeamserver

        # Define variables to be used
        self.p = self.parameters
        self.cycles = self.p.RabiFlopping.Sequences_Per_Point
        self.start_time = self.p.RabiFlopping.Start_Time
        self.stop_time = self.p.RabiFlopping.Stop_Time
        self.step_time = self.p.RabiFlopping.Time_Step
        self.disc = self.pv.get_parameter('StateReadout','state_readout_threshold')
        self.state_detection = self.p.RabiFlopping.State_Detection
        self.dc_thresh = self.p.RabiFlopping.dc_threshold
        self.m_sequence = self.p.RabiFlopping.microwave_pulse_sequence
        self.mode = self.p.RabiFlopping.Mode
        if self.m_sequence == 'single':
            self.LO_freq = self.p.Microwaves133.LO_frequency
        elif self.m_sequence == 'composite_1':
            self.LO_freq = self.p.Composite1.LO_frequency
        elif self.m_sequence == 'composite_2':
            self.LO_freq = self.p.Composite2.LO_frequency
        elif self.m_sequence == 'composite_3':
            self.LO_freq = self.p.Composite3.LO_frequency
        elif self.m_sequence == 'composite_4':
            self.LO_freq = self.p.Composite4.LO_frequency
        elif self.m_sequence == 'spin_echo':
            self.LO_freq = self.p.SpinEcho.LO_frequency
        self.total_exps = 0

        # Define contexts for saving data sets
        self.c_prob = self.cxn.context()
        self.c_hist = self.cxn.context()
        self.c_time_tags = self.cxn.context()

        # Need to map the gpib address to the labrad conection
        self.device_mapA = {}
        self.device_mapB = {}
        self.get_device_map()
        self.HPA.select_device(self.device_mapA['GPIB0::19'])

        self.set_up_datavault()
示例#13
0
 def initialize(self, cxn, context, ident):
     self.ident = ident
     self.excite = self.make_experiment(excitation_729)
     self.excite.initialize(cxn, context, ident)
     self.scan = []
     self.amplitude = None
     self.duration = None
     self.cxnlab = labrad.connect('192.168.169.49') #connection to labwide network
     self.cxnwin = labrad.connect('192.168.169.30') # windows computer for gpib
     self.drift_tracker = cxn.sd_tracker
     self.dv = cxn.data_vault
     self.pulser = self.cxn.pulser
     self.agi_scan_context = self.cxnwin.context()
示例#14
0
 def initialize(self, cxn, context, ident):
     self.ident = ident
     self.cxn = labrad.connect(name = 'Loading Curve Cam')
     #self.cxnwlm = labrad.connect('10.97.111.8', name = 'Linescan Camera', password = '******')
     self.cxnHP = labrad.connect('bender', name = 'loading curve cam', password = '******')
     self.trap = self.cxn.trap_server
     self.hp = self.cxnHP.hp6033a_server
     self.hp.select_device(0)
     self.dv = self.cxn.data_vault
     self.cam = self.cxn.andor_server
     self.pmt = self.cxn.normalpmtflow
     self.pulser = self.cxn.pulser
     self.grapher = self.cxn.grapher
示例#15
0
def run_manager(tls_required, port=7778, tls_port=7779, startup_timeout=20):
    """Context manager to run the labrad manager in a subprocess.

    Will attempt to connect to the manager and fail if we cannot do so within
    the specified timeout. This ensures that the manager is actually running
    and listening for connections before we yield to execute the body of the
    with statement.

    Args:
        tls_required (boolean): Whether the manager should require TLS.
        port (int): The port on which to listen for upgradeable connections
            that start unencrypted and then use STARTTLS to secure the
            connection.
        tls_port (int): The port on which to listen for TLS connections that
            are encrpyted from the start.
        startup_timeout (float): Maximum number of seconds to allow for the
            manager to start before we fail.

    Yields (ManagerInfo):
        Info about the running manager.
    """
    with temp_tls_dirs() as (cert_path, key_path):
        password = '******'
        manager = subprocess.Popen([
                'labrad',
                '--password={}'.format(password),
                '--port={}'.format(port),
                '--tls-port={}'.format(tls_port),
                '--tls-required={}'.format(tls_required),
                '--tls-required-localhost={}'.format(tls_required),
                '--tls-cert-path={}'.format(cert_path),
                '--tls-key-path={}'.format(key_path)])
        try:
            start = time.time()
            while True:
                try:
                    labrad.connect(port=tls_port, tls_mode='on',
                                   password=password)
                except Exception as e:
                    last_error = e
                else:
                    break
                elapsed = time.time() - start
                if elapsed > startup_timeout:
                    raise Exception('labrad failed to start within {} seconds. '
                                    'last_error={}'
                                    .format(startup_timeout, last_error))
                time.sleep(0.5)
            yield ManagerInfo(port, tls_port, password)
        finally:
            manager.kill()
示例#16
0
    def initialize(self, cxn, context, ident):
        self.ident = ident
        self.cxn = labrad.connect(name = 'Frequency Scan')
        self.cxnwlm = labrad.connect('wavemeter', name = 'Frequency Scan', password = '******')
        #self.cxn = labrad.connect('bender', name = 'Frequency Scan', password = '******')

        self.HPA = self.cxn.hp8672a_server
        self.HPB = self.cxn.hp8657b_server
        self.wm = self.cxnwlm.multiplexerserver
        self.pmt = self.cxn.normalpmtflow
        self.grapher = self.cxn.grapher
        self.dv = self.cxn.data_vault
        self.cam = self.cxn.andor_server
        self.single_lock = self.cxn.software_laser_lock_server
        self.bristol = self.cxn.bristolserver
        self.shutter = cxn.arduinottl

        # Need to map the gpib address to the labrad context number
        self.device_mapA = {}
        self.device_mapB = {}

        self.get_device_map()


        self.frequency_493 = self.parameters.Frequency_Scan.Center_Frequency_493
        self.frequency_650 = self.parameters.Frequency_Scan.Center_Frequency_650
        self.frequency_455 = self.parameters.Frequency_Scan.Center_Frequency_455
        self.frequency_1762 = self.parameters.Frequency_Scan.Center_Frequency_1762
        self.frequency = self.parameters.Frequency_Scan.Frequency
        self.start_frequency = self.parameters.Frequency_Scan.Frequency_Start
        self.stop_frequency = self.parameters.Frequency_Scan.Frequency_Stop
        self.step_frequency = self.parameters.Frequency_Scan.Frequency_Step
        self.time_step = self.parameters.Frequency_Scan.Time_Step
        self.return_bool = self.parameters.Frequency_Scan.Return
        self.return_frequency = self.parameters.Frequency_Scan.Return_Frequency
        self.source = self.parameters.Frequency_Scan.Source
        self.points = self.parameters.Frequency_Scan.Points

        self.wm_p = multiplexer_config.info

        # Make sure PMT is recording data
        if not self.pmt.isrunning():
            self.pmt.record_data()
        self.pmt.set_mode('Normal')

        self.set_up_datavault()

        self.binx, self.biny, self.startx, self.stopx, self.starty, self.stopy = self.cam.get_image_region(None)
        self.pixels_x = (self.stopx - self.startx + 1) / self.binx
        self.pixels_y = (self.stopy - self.starty + 1) / self.biny
示例#17
0
    def initialize(self, cxn, context, ident):
        self.ident = ident
        self.cxn = labrad.connect(name = 'Shelving_133')
        self.cxnwlm = labrad.connect('wavemeter', name = 'shelving 133', password = '******')
        self.wm = self.cxnwlm.multiplexerserver
        self.pulser = self.cxn.pulser
        self.dv = self.cxn.data_vault
        self.grapher = self.cxn.grapher
        self.HPA = self.cxn.hp8672a_server
        self.HPB = self.cxn.hp8657b_server
        self.single_lock = self.cxn.software_laser_lock_server
        self.pv = self.cxn.parametervault
        self.shutter = self.cxn.arduinottl
        self.pb = self.cxn.protectionbeamserver
        self.reg = self.cxn.registry

        # Define variables to be used
        self.p = self.parameters
        self.cycles = self.p.Shelving133.cycles
        self.start_time = self.p.Shelving133.Start_Time
        self.stop_time = self.p.Shelving133.Stop_Time
        self.step_time = self.p.Shelving133.Time_Step
        self.start_freq = self.parameters.Shelving133.Frequency_Start
        self.stop_freq = self.parameters.Shelving133.Frequency_Stop
        self.step_freq = self.parameters.Shelving133.Frequency_Step
        self.scan = self.parameters.Shelving133.Scan
        self.scan_laser = self.parameters.Shelving133.Scan_Laser
        self.disc = self.pv.get_parameter('StateReadout','state_readout_threshold')
        self.dc_thresh = self.p.Shelving133.dc_threshold
        self.total_exps = 0


        # Get software laser lock info
        self.reg.cd(['Servers','software_laser_lock'])
        laser = self.reg.get(self.scan_laser)
        # Returns tuple which is not iterable
        laser = list(laser)
        self.scan_laser_chan = laser[1]

        # Get context for saving probability and histograms
        self.c_prob = self.cxn.context()
        self.c_hist = self.cxn.context()
        self.c_dc_hist = self.cxn.context()

        # Need to map the gpib address to the labrad connection
        self.device_mapA = {}
        self.device_mapB = {}
        self.get_device_map()
        # Setup data saving
        self.set_up_datavault()
示例#18
0
    def initialize(self, cxn, context, ident):

        self.ident = ident
        self.cxn = labrad.connect(name='Tickle Scan')
        self.cxnwlm = labrad.connect('10.97.112.2',
                                     name=socket.gethostname() + " Tickle Scan",
                                     password=os.environ['LABRADPASSWORD'])
        self.dv = self.cxn.data_vault
        self.grapher = self.cxn.grapher
        self.rg = self.cxnwlm.rigol_dg1022_server
        self.pmt = self.cxn.normalpmtflow
        self.p = self.parameters
        self.chan = 1
        self.rg.select_device(0)
示例#19
0
def write_to_rigol(coupling_time,drive_frequ,amplitude1,amplitude2,Npoints=100000, is_black=True):
    """Writes the wavefunction directly to the generator
    coupling_strength in Hz
    drive_frequ in Hz
    amplitude in dBm
    """
    if is_black:
        t,y,duration = generate_wavefunc_blackman(coupling_time,drive_frequ,Npoints)
    else:
        t,y,duration = generate_wavefunc(coupling_time,drive_frequ,Npoints)
    s1 = to_str(y)
    freq = 1/duration
    import labrad
    from labrad.units import WithUnit
    cxn = labrad.connect('192.168.169.30')
    a = cxn.rigol_dg4062_server
    a.select_device()
    #Set channel 1
    a.burst_state(True,1)
    a.arbitrary_waveform(s1,1)
    a.voltage(WithUnit(amplitude1,'V'),1)
    a.frequency(WithUnit(freq,'Hz'),1)

    #Set channel 2
    a.burst_state(True,2)
    a.arbitrary_waveform(s1,2)
    a.frequency(WithUnit(freq,'Hz'),2)
    a.voltage(WithUnit(amplitude2,'V'),2)
    a.burst_state(True,2)
    a.burst_state(True,1)
    print freq
示例#20
0
def write_to_agilent(coupling_time,drive_frequ,amplitude,Npoints=10000, is_black=True):
    """Writes the wavefunction directly to the generator
    coupling_strength in Hz
    drive_frequ in Hz
    amplitude in dBm
    """
    if is_black:
        t,y,duration = generate_wavefunc_blackman(coupling_time,drive_frequ,Npoints)
    else:
        t,y,duration = generate_wavefunc(coupling_time,drive_frequ,Npoints)
    s1 = to_str(y)
    freq = 1/duration
    import labrad
    from labrad.units import WithUnit
    cxn = labrad.connect('192.168.169.30')
    a = cxn.agilent_server
    a.select_device()
    a.output(False)
    a.output(False)
    a.arbitrary_waveform2(s1)
    a.output(True)
    a.output(True)
    a.amplitude(amplitude)
    a.frequency(WithUnit(freq,'Hz'))
    print freq
def main(ignoreLVDS=False):
    if 'LabRADPassword' in os.environ:
        password = os.environ['LabRADPassword']
    elif self.args.password is not None:
        try:
            args = _parse_arguments()
        except:
            print('Could not parse the bring-up script arguments.')
            raise
        password = self.args.password
    else:
        raise Exception("Neither enviroment variable "
                "'LabRADPassword' exists nor the command line "
                "argument '--password' is specified.")
    with labrad.connect(password=password) as cxn:
        fpga = cxn['ghz_fpgas']
        no_success = True
        while no_success:
            successes, failures, tries = auto_bringup(fpga, ignoreLVDS)
            successes = [board for board in successes.keys()
                      if board not in failures]
            if successes:
                print('The following boards have been succesfully ' +
                        'brought up:')
                for key in successes:
                    print(key + ' (attempts: ' + str(tries[key]) + ')')
            if failures:
                print('The following boards failed:')
                for key in failures:
                    print(key)
            else:
                no_success = False
示例#22
0
文件: camera.py 项目: younapark/yp
 def __init__(self):
     self.threads=[]
     self.running=True
     self.cxn=labrad.connect()
     self.pulser=self.cxn.pulser
     self.dv = self.cxn.data_vault
     self.pv = self.cxn.parametervault
    def initialize(self, cxn, context, ident):
        self.ident = ident
        self.excite = self.make_experiment(excitation_ramsey_with_heating)
        self.excite.initialize(cxn, context, ident)

        # adding crystallization process
        if self.parameters.Crystallization.auto_crystallization:
            self.crystallizer = self.make_experiment(crystallization)
            self.crystallizer.initialize(cxn, context, ident)
 
        self.scan = []
        self.cxnlab = labrad.connect('192.168.169.49', password='******', tls_mode='off') #connection to labwide network
        #self.cxnlab = labrad.connect('localhost') #connection to labwide network
        self.drift_tracker = cxn.sd_tracker
        self.dv = cxn.data_vault
        self.data_save_context = cxn.context()
        self.contrast_save_context = cxn.context() # for saving the contrast 
        
        minim_t,maxim_t,t_steps = self.parameters.Dephasing_Pulses.scan_blue_heating_start_time
        
        minim_phi,maxim_phi,phi_steps = self.parameters.Dephasing_Pulses.scan_phase #Ahmed
        minim_t = minim_t['us']; maxim_t = maxim_t['us']  #Ahmed
        minim_phi = minim_phi['deg']; maxim_phi = maxim_phi['deg']  #Ahmed

        self.scan_t = linspace(minim_t,maxim_t, t_steps)  #Ahmed
        self.scan_t = [WithUnit(pt_t, 'us') for pt_t in self.scan_t]  #Ahmed

        self.scan_phi = linspace(minim_phi,maxim_phi, phi_steps)  #Ahmed
        self.scan_phi = [WithUnit(pt_phi, 'deg') for pt_phi in self.scan_phi]  #Ahmed
       
        self.radial_freq_offset = self.parameters.Dephasing_Pulses.mode_offset #Ahmed               

        self.setup_data_vault()
示例#24
0
    def initialize(self, cxn, context, ident):
        import_path, class_name = self.base_experiment_class
        
        try:
            __import__(import_path)
            module = sys.modules[import_path]
            exc = getattr(module, class_name)
            self.excite = self.make_experiment(exc)
            self.excite.initialize(cxn, context, ident)
        except ImportError as e:
            print 'Import error: ', e
        self.ident = ident
        
        self.scan = []
        try:
            self.cxnlab = labrad.connect('192.168.169.49')
        except Error as e:
            print "No connection to the labwide network!"
        try:
            self.drift_trcker = cxn.sd_tracker
        except Error as e:
            print "Can't connect to drift tracker"
        try:
            self.dv = cxn.data_vault
        except Error as e:
            print "No connection to data vault."

        self.data_save_context = cxn.context()
示例#25
0
文件: Test2.py 项目: EQ4/resonator
 def run(self):
     #generate lorentzian data
     p = [.01, 25, .1, 0] #p = [gamma, center, I, offset]
     x = np.arange(24.9, 25.1, .005)
     y = p[3] + p[2]*(p[0]**2/((x - p[1])**2 + p[0]**2))# Lorentzian
     #add data to data vault
     self.cxn = labrad.connect()
     self.cxn.server = self.cxn.data_vault
     self.cxn.data_vault.cd('Sine Curves')
     self.cxn.data_vault.new('Lorentzian', [('x', 'num')], [('y1','Test-Spectrum','num')])
     self.cxn.data_vault.add_parameter('Window', ['Lorentzian'])
     self.cxn.data_vault.add_parameter('plotLive', True)
     self.cxn.data_vault.add(np.vstack((x,y)).transpose())
     time.sleep(1)
     self.cxn.data_vault.add_parameter('Fit', ['[]', 'Lorentzian', '[0.01, 25.0, 0.10000000000000001, 1.4901161193880158e-08]']) 
     #wait until the fit is accepted
     i = 0
     while(i < 200): # timeout
         try:
             Continue = self.cxn.data_vault.get_parameter('Accept-0')
         except:
             Continue = False
         if (Continue == True):
             self.doCalculation()
             break
         else:
             time.sleep(1.0)
         i += 1
     self.cleanUp()
示例#26
0
    def initialize(self, cxn, context, ident):
        self.ident = ident
        self.cxn = labrad.connect(name = 'Optical Pumping')

        self.pulser = self.cxn.pulser
        self.grapher = self.cxn.grapher
        self.dv = self.cxn.data_vault
        self.pb = self.cxn.protectionbeamserver
        self.shutter = self.cxn.arduinottl
        self.pv = self.cxn.parametervault
        # Define variables to be used
        self.p = self.parameters
        self.cycles = self.p.OpticalPumping133.Cycles
        self.start_time = self.p.OpticalPumping133.Start_Time
        self.stop_time = self.p.OpticalPumping133.Stop_Time
        self.step_time = self.p.OpticalPumping133.Time_Step
        self.state_detection = self.p.OpticalPumping133.State_Detection
        self.mode = self.p.OpticalPumping133.Mode

        self.disc = self.pv.get_parameter('StateReadout','state_readout_threshold')
        # Define contexts for saving data sets
        self.c_prob = self.cxn.context()
        self.c_hist = self.cxn.context()

        self.set_up_datavault()
示例#27
0
 def initialize(self):
     print 'Started: {}'.format(self.experimentPath)
     import labrad
     self.cxn = cxn = labrad.connect()
     self.sem = cxn.semaphore
     self.dv = cxn.data_vault
     self.tek = cxn.tektronix_server
     print self.tek.list_devices()
     while True:
         try:
             dev = int(raw_input("Please select a device: "))
             self.tek.select_device(dev)
             break
         except:
             print "No such device."
     """
     self.channels = self.sem.get_parameter(self.d['measure_channels'])
     self.resolution = self.sem.get_parameter(self.d['resolution_path'])[2].inUnitsOf('s')
     self.iterations = int(self.sem.get_parameter(self.d['iteration_path'])[2].value)
     self.saving_directory = self.sem.get_parameter(self.d['saving_directory'])
     self.window_name = self.sem.get_parameter(self.d['window_name'])
     self.plotLive = self.sem.get_parameter(self.d['plotLive'])
     print 'Measuring Channels {}'.format(self.channels)
     """
     self.setup_data_vault()
示例#28
0
    def initialize(self, cxn, context, ident):
        self.ident = ident
        self.cxn = labrad.connect(name = 'D32 Measurement')
        self.pulser = self.cxn.pulser
        self.dv = self.cxn.data_vault
        self.grapher = self.cxn.grapher
        self.pv = self.cxn.parametervault

        self.HPA = self.cxn.hp8672a_server
        self.HPB = self.cxn.hp8657b_server

        # Define variables to be used
        self.p = self.parameters
        self.f = self.parameters.FrequencySweep
        self.d = self.parameters.D32Measurement


        self.cycles = self.d.Sequences_Per_Point
        self.c_prob = self.cxn.context()
        self.c_hist = self.cxn.context()

        # Need to map the gpib address to the labrad connection
        self.device_mapA = {}
        self.device_mapB = {}
        self.get_device_map()
        self.get_transitions()
        self.set_up_datavault()
示例#29
0
def test_signal_data_available(dv):
    """Check that we get messages when new parameters are added to a data set."""
    msg_id = 123

    messages = []
    def on_message(ctx, msg):
        messages.append((ctx, msg))

    path, name = dv.new('test', ['x'], ['y'])

    # open a second connection which we'll use to read data added by the other
    with labrad.connect() as cxn:
        reader = setup_dv(cxn)
        reader.signal__data_available(msg_id)

        p = reader._cxn._backend.cxn
        p.addListener(on_message, source=reader.ID, ID=msg_id)

        reader.cd(path)
        reader.open(name)

        dv.add([1, 2])
        time.sleep(0.1)
        assert len(messages) == 1

        dv.add([3, 4])
        time.sleep(0.1)
        assert len(messages) == 1 # we should not get another message until we get the data

        data = reader.get()
        time.sleep(0.1)

        dv.add([5, 6])
        time.sleep(0.1)
        assert len(messages) == 2 # now we get a new message
示例#30
0
def checkBoard(verbose = False):
    print 'Trying to connect to the DAC board...'
    print
    with labrad.connect() as cxn:
        fpga = cxn[FPGA_SERVER]
        boards = fpga.list_devices()
        bold = '\033[1m'
        nobold = '\033[0;0m'
        
        while len(boards) == 0:
            print 'FAILURE: The board was off when you started the GHz DAC Server.'
            print 'Turn on (and connect) the DAC board, close and restart the DAC server and press any key...'
            raw_input()
            boards = fpga.list_devices()
        board = boards[0][1]
        
        while True:
            try:
                getBuildNumber(fpga, board)
                break
            except:
                print 'FAILURE: The DAC board seems to be turned off.'
                print 'Turn on (and connect) the board and press any key...'
                raw_input()
                
        print 'Bring up successfully completed!' if bringupBoard(fpga, board, verbose = verbose) else 'Something went wrong! See above for details.'
示例#31
0
    def run_finally(cls, cxn, parameters_dict, all_data, Phase):

        ident = int(cxn.scriptscanner.get_running()[-1][0])
        print " sequence ident", ident

        # Should find a better way to do this

        # for the multiple case we summ the probabilities, this also
        # reduces the dimension to 1 for single ion case
        all_data = np.array(all_data)
        print all_data

        p = parameters_dict
        duration = p.DriftTrackerRamsey.line_2_pi_time
        ramsey_time = p.DriftTrackerRamsey.gap_time_2
        ion_no = p.DriftTrackerRamsey.no_of_readout_ion_2ions

        ind1 = np.where(Phase == 90.0)
        ind2 = np.where(Phase == 270.0)

        try:
            p1 = all_data[ind1][0][ion_no - 1]
            p2 = all_data[ind2][0][ion_no - 1]
        except:
            print "cannot get population p1 & p2"
            return

        if p1 == p2 == 0.0 or p1 == p2 == 1.0:
            print "Populations are zero. Please make sure everything works well."
            # print "stoping the sequence ident" , ident
            # cxn.scriptscanner.stop_sequence(ident)
            return

        max_gap = U(500, 'us')
        min_gap = U(25, 'us')
        if np.abs((p1 - p2) / (p1 + p2)) > 0.8:
            new_ramsey_time = ramsey_time / 2
            if new_ramsey_time >= min_gap:
                cxn.scriptscanner.set_parameter('DriftTrackerRamsey',
                                                'gap_time_2', new_ramsey_time)
                print "gap_time_2 (line_2) is too big. halve it"
            else:
                cxn.scriptscanner.set_parameter('DriftTrackerRamsey',
                                                'gap_time_1', min_gap)
                print "gap_time_2 (line_2) is too big. Set it to be minimum gaptime: ", min_gap
            if p.DriftTrackerRamsey.auto_schedule:
                cxn.scriptscanner.set_parameter('DriftTrackerRamsey',
                                                'auto_schedule', False)
                scan = [('CalibLine1', ('Spectrum.carrier_detuning', -10, 10,
                                        1, 'kHz')),
                        ('CalibLine2', ('Spectrum.carrier_detuning', -10, 10,
                                        1, 'kHz'))]
                cxn.scriptscanner.new_sequence('CalibAllLines', scan)
            else:
                cxn.scriptscanner.set_parameter('DriftTrackerRamsey',
                                                'auto_schedule', True)
                scan = [('TrackLine1', ('DriftTrackerRamsey.phase_1', 90, 271,
                                        180, 'deg')),
                        ('TrackLine2', ('DriftTrackerRamsey.phase_2', 90, 271,
                                        180, 'deg'))]
                cxn.scriptscanner.new_sequence('DriftTrackerRamsey_2ions',
                                               scan)
            print "stoping the sequence ident", ident
            cxn.scriptscanner.stop_sequence(ident)
            return
        elif np.abs((p1 - p2) / (p1 + p2)) > 0.55:
            new_ramsey_time = ramsey_time * 2 / 3
            if new_ramsey_time >= min_gap:
                cxn.scriptscanner.set_parameter('DriftTrackerRamsey',
                                                'gap_time_2', new_ramsey_time)
                print "gap_time_2 (line_2) should be smaller. multiplies 2/3"
            else:
                cxn.scriptscanner.set_parameter('DriftTrackerRamsey',
                                                'gap_time_2', min_gap)
                print "gap_time_2 (line_2) should be smaller. Set it to be minimum gaptime: ", min_gap
        elif np.abs((p1 - p2) / (p1 + p2)) < 0.15:
            new_ramsey_time = ramsey_time * 3 / 2
            if new_ramsey_time < max_gap:
                cxn.scriptscanner.set_parameter('DriftTrackerRamsey',
                                                'gap_time_2', new_ramsey_time)
                print "gap_time_2 (line_2) can be larger. multiplies 3/2"
            else:
                cxn.scriptscanner.set_parameter('DriftTrackerRamsey',
                                                'gap_time_2', max_gap)
                print "gap_time_2 (line_2) can be larger. set gap_time_1 to be max gap time: ", max_gap

        detuning = 1.0 * np.arcsin(
            (p1 - p2) / (p1 + p2)) / (2.0 * np.pi * ramsey_time['s'] +
                                      4 * duration['s']) / 1000.0
        detuning = detuning.mean()
        detuning = U(detuning, "kHz")

        carrier_translation = {
            'S+1/2D-3/2': 'c0',
            'S-1/2D-5/2': 'c1',
            'S+1/2D-1/2': 'c2',
            'S-1/2D-3/2': 'c3',
            'S+1/2D+1/2': 'c4',
            'S-1/2D-1/2': 'c5',
            'S+1/2D+3/2': 'c6',
            'S-1/2D+1/2': 'c7',
            'S+1/2D+5/2': 'c8',
            'S-1/2D+3/2': 'c9',
        }
        line_2 = parameters_dict.DriftTracker.line_selection_2

        carr_2 = detuning + parameters_dict.Carriers[
            carrier_translation[line_2]]

        print "DFIRT TRACKER FINAL"
        print "Ramsey max frequency shift", 1 / (
            4 * ramsey_time['s'] + 8 * duration['s'] / np.pi) * 1e-3, 'kHz'
        print " calculated detuning", detuning, " and the carrier", line_2, "freq", carr_2

        submission = [(line_2, carr_2)]
        print "3243", submission
        localtime = time.localtime()
        timetag = time.strftime('%H%M_%S', localtime)
        print timetag
        print carr_2

        # temp=  np.zeros(1, dtype=[('timetag', 'U7'), ('car1', float),('car2', float)])
        #         temp['timetag']=timetag
        #         temp['car1']=carr_1['kHz']
        #         temp['car2']=carr_2['kHz']
        #        saving the data to check for the accuracy of this measurement
        # f_handle = file('Drift_tracker.csv','a')
        # np.savetxt(f_handle,temp, fmt="%10s %10.3f %10.3f")
        # f_handle.close()

        #np.savetxt('Dfirt_tracker.csv', (timetag,carr_1,carr_2),  delimiter=',', fmt="%7s %10.3f %10.3f")

        if parameters_dict.DriftTrackerRamsey.submit:
            import labrad
            global_sd_cxn = labrad.connect(cl.global_address,
                                           password=cl.global_password,
                                           tls_mode='off')
            print cl.client_name, "is sub one line to global SD",
            print submission
            global_sd_cxn.sd_tracker_global.set_measurements_with_one_line(
                submission, cl.client_name)
            global_sd_cxn.disconnect()
示例#32
0
import labrad
import numpy as np
import time

#connect to LabRAD
try:
	cxn = labrad.connect('192.168.169.49')
except:
	print 'Please start LabRAD Manager'
	time.sleep(10)
	raise()

nodeDict = {
			'node_lab_49':
				['Serial Server', 'LaserDAC', 'Pulser_729','Multiplexer Server'],
			}

for node in ['node_lab_49']: #sets the order of opening
	#make sure all node servers are up
	if not node in cxn.servers: print node + ' is not running'
	else:
		print '\n' + 'Working on ' + node + '\n'
		#if node server is up, start all possible servers on it that are not already running
		running_servers = np.array(cxn.servers[node].running_servers().asarray)
		for server in nodeDict[node]:
			if server in running_servers: 
				print server + ' is already running'
			else:
				print 'starting ' + server
				try:
					cxn.servers[node].start(server)
示例#33
0
 def connect_to_labrad(self,
                       host=os.getenv("LABRADHOST"),
                       password=os.getenv("LABRADPASSWORD")):
     connection_name = '{} - {}'.format(self.servername, self.name)
     self.cxn = connect(name=connection_name, host=host, password=password)
示例#34
0
文件: main.py 项目: HaeffnerLab/sqip
 def getLRConnection(self):
     Client.connection = labrad.connect()
示例#35
0
import labrad
import numpy as np
import time
import matplotlib.pyplot as plt
from labrad.units import WithUnit as U

#---parameters---#
iterations = 10000 * 10
wait_time = .1

#---script---#
cxn = labrad.connect('192.168.169.50')
dmm = cxn.keithley_2100_dmm
dmm.select_device('sqip_expcontrol GPIB Bus - USB0::0x05E6::0x2100::1243106')
#dmm.select_device('GPIB Bus - USB0::0x05E6::0x2100::1243106')
cxnlocal = labrad.connect()
dv = cxnlocal.data_vault

localtime = time.localtime()
dirappend = [
    time.strftime("%Y%b%d", localtime),
    time.strftime("%H%M_%S", localtime)
]
direc = ['', 'Experiments', 'CoilCurrentStability', 'Keithley']
direc.extend(dirappend)
dv.cd(direc, True)
dv.new('Coil current', [('Time', '100 ms')], [('Current', 'A', 'A')])
dv.add_parameter('Window', 'Coil current')
#dv.add_parameter('plotLive', True)
for i in range(iterations):
    v = dmm.get_dc_volts()
示例#36
0
 def initialize(self):
     import labrad
     cxn = labrad.connect(name=self.name, host=os.getenv('LABRADHOST') , password = '')
     self.device = self.DeviceProxy(cxn)
     self.reactor.callFromThread(self.populateGUI)
示例#37
0
import labrad
import numpy as np
from pylab import *

plotnumber = 113
title = '369 Line Scan'

cxn = labrad.connect(name='plotting module')
dv = cxn.data_vault
dv.cd(['', '369 Wavemeter Line Scan'])
fig, ax = subplots()
dv.open(plotnumber)
params = dv.get_parameter('Solutions-0-Lorentzian')

amp = params[2] * 60
FWHM = params[0]
gamma = 1e6 * FWHM
center = params[1] * 1e6
offset = params[3]

arr = dv.get().asarray
xpoints = 1e6 * (arr[:, 0] - params[1]) * 2

fit = amp * (gamma) / ((xpoints)**2 + (gamma)**2) + offset

ax.plot(xpoints, arr[:, 1], label='369 data')
ax.plot(xpoints, fit)
f = center * 2 * 1e-6
ax.text(-400,
        16,
        'Center Frequency = ' + str(float("{0:.6f}".format(f))) + 'THz',
示例#38
0
        return eta
        
    def compute_state_evolution(self, nbar, delta, T_Rabi, t):
        '''returns the state evolution for temperature nbar, detuning delta, rabi frequency T_Rabi for times t'''
        n = self.n
        if 5 * nbar > self.n.max():
            print 'WARNING, trying to calculate nbar that is high compared to the precomputed energy levels' 
        omega = self.rabi_coupling
        #level population probability for a given nbar, see Leibfried 2003 (57)
        ones = np.ones_like(t)
        p = ((float(nbar)/(nbar+1.))**n)/(nbar+1.) 
        result = np.outer(p*omega/np.sqrt(omega**2+delta**2), ones) * (np.sin( np.outer( np.sqrt(omega**2+delta**2)*np.pi/T_Rabi, t ))**2)
        result = np.sum(result, axis = 0)
        return result

cxn = labrad.connect('192.168.169.197')
dv = cxn.data_vault
trap_frequency = T.Value(1.1, 'MHz') #Hz
projection_angle = 45 #degrees
sideband_order = 0
pump_eff = 1.0
offset_time = 6.0e-6
flop = rabi_flop(trap_frequency = trap_frequency, projection_angle = projection_angle, sideband_order = sideband_order)

#heating times in ms
fig_title = 'Heating by pulsing a global blue laser'
info = [
(0, 0.0, ('2012Nov15','1943_17'), 40e-6, {'nbar': Parameter(48.0), 'delta': 0.0, 'T_Rabi' : Parameter(26.4e-6)}),       
(0, 20.0, ('2012Nov15','1944_33'), 50e-6, {'nbar': Parameter(60.0), 'delta': 0.0, 'T_Rabi' : Parameter(26.4e-6)}),
(0, 100.0, ('2012Nov15','1945_58'), 35e-6, {'nbar': Parameter(100.0), 'delta': 0.0, 'T_Rabi' : Parameter(26.4e-6)}),
(0, 250.0, ('2012Nov15','1952_22'), 50e-6, {'nbar': Parameter(200.0), 'delta' : 0.0, 'T_Rabi' : Parameter(26.4e-6)}),
示例#39
0
    def dac_ramp(self):
        p = self.parameters
        tot_time = p.DACcontrol.time_up
        time_at_top = tot_time - 12

        i = 0
        cxn = labrad.connect()
        current_multipoles = cxn.dac_server.get_multipole_values()
        currentU2 = dict(current_multipoles)['U2']
        targetU2 = p.DACcontrol.U2target
        amplitude = (targetU2 - currentU2)
        readfromfile = True
        v = []
        f = ''
        print 'C:\Users\expcontrol\Downloads\\' + str(
            int(time_at_top)) + 'msec_at_top.txt'
        if (readfromfile):
            z = 'C:\Users\expcontrol\Downloads\\' + str(
                int(time_at_top)) + 'msec_at_top.txt'
            print z
            f = open(z, 'r')

        for line in f:
            #print line
            try:
                temp = float(line)

                v.append(temp * amplitude + currentU2)
            except ValueError:
                print 'error'

        print f
        #v = range(126)
        time.sleep(2)

        if (readfromfile):
            print 'yp'
            while i < p.DACcontrol.num_steps:
                cxn.dac_server.set_next_u2(v[i])
                i = i + 1
            cxn.dac_server.set_next_u2(currentU2)
        else:
            pass

        print cxn.dac_server.get_analog_voltages()
        print 'Setting U2 to:', p.DACcontrol.U2target
        self.end = WithUnit(10, 'us')

        # ramp down if toggled
        if (p.DACcontrol.enable_ramp):
            print 'enabled'
            self.addSequence(advanceDACs)
        print 'finished advance'

        print cxn.dac_server.get_analog_voltages()
        if (p.DACcontrol.enable_ramp):
            print 'enabled'
            cxn.dac_server.reset_queue()
            self.addSequence(resetDACs)
        print 'end'
        f.close()
示例#40
0
文件: pi.py 项目: HaeffnerLab/sqip
        i = 0
        for p in parameters:
            p.set(params[i])
            i += 1
        return y - function(x)

    if x is None: x = np.arange(y.shape[0])
    p = [param() for param in parameters]
    return optimize.leastsq(f, p)


flop_numbers = range(len(flop_files))
dephase_numbers = range(len(dephase_files))

#get access to servers
cxn = labrad.connect('192.168.169.197', password='******')
dv = cxn.data_vault

#get trap frequency
dv.cd(flop_directory)
dv.cd(parameter_file)
dv.open(1)
sideband_selection = dv.get_parameter('RabiFlopping.sideband_selection')
sb = np.array(sideband_selection)
trap_frequencies = [
    'TrapFrequencies.radial_frequency_1', 'TrapFrequencies.radial_frequency_2',
    'TrapFrequencies.axial_frequency', 'TrapFrequencies.rf_drive_frequency'
]
trap_frequency = dv.get_parameter(
    str(np.array(trap_frequencies)[sb.nonzero()][0]))
print 'trap frequency is {}'.format(trap_frequency)
示例#41
0
#!/usr/bin/env python
import labrad
import numpy as np
import time

#connect to LabRAD
try:
    cxn = labrad.connect(name='Node Client')
except:
    print 'Please start LabRAD Manager'
    time.sleep(10)
    raise ()

nodeDict = {
    'node UMI': [
        'Data Vault',
        #'Andor Server',
        #'NI Analog Server',
        'NormalPMTFlow',
        #'SD Tracker',
        #'Line Tracker',
        #'ScriptScanner',
        'ParameterVault',
        'Pulser'
    ],
}

for node in nodeDict.keys():  #sets the order of opening
    #make sure all node servers are up
    if not node in cxn.servers: print node + ' is not running'
    else:
    'initial_cooling': initial_cooling,
    'heat_delay': heat_delay,
    'axial_heat': axial_heat,
    'readout_delay': readout_delay,
    'readout_time': readout_time,
}

#Binning on the fly
binTime = 250.0 * 10**-6
binNumber = int(recordTime / binTime)
binArray = binTime * numpy.arange(binNumber + 1)
#parameters
parameters = Parameters(globalDict)
parameters.addDict(pboxDict)
#connect and define servers we'll be using
cxn = labrad.connect()
cxnlab = labrad.connect('192.168.169.49')  #connection to labwide network
dv = cxn.data_vault
dpass = cxn.double_pass
trigger = cxn.trigger
pbox = cxn.paul_box
trfpga = cxn.timeresolvedfpga
rs110DP = cxn.rohdeschwarz_server
rf = cxn.lattice_pc_hp_server

dirappend = time.strftime("%Y%b%d_%H%M_%S", time.localtime())


def initialize():
    trfpga.set_time_length(recordTime)
    paulsbox.program(pbox, pboxDict)
示例#43
0
 def setUp(self):
     self.cxn = labrad.connect() #host='localhost')
示例#44
0
        fitvals = np.array([ v*v*v*fit[0] + v*v*fit[1] + v * fit[2] + fit[3] for v in self.anaVoltages])
        diffs = fitvals - self.digVoltages

        m = 80./(2**16 - 1)
        b = -40
        idealVals = np.array([m*v + b for v in self.digVoltages])
        uncalDiffs = idealVals - self.anaVoltages
        
        print "MAX DEVIATION: ", max(abs(diffs)), " bits, or ~", m*max(abs(diffs))*1000., " mV"
#        plt.figure(2)
#        plt.plot(self.digVoltages, 1000*(diffs))
#        plt.title('Actual deviation from fit (mV)')
#        plt.figure(3)
#        plt.plot(self.digVoltages, 1000*(uncalDiffs) )
#        plt.title('Deviation from nominal settings (mV)')
#        plt.show()
        
#        print "MAX DEV FROM NOMINAL: ", max(abs(uncalDiffs)), " bits"

if __name__=="__main__":
    import labrad
    cxn = labrad.connect()
    cxncam = labrad.connect('192.168.169.30')
    dacserver = cxn.cctdac_pulser_v2
    dmmserver = cxncam.keithley_2100_dmm
    dmmserver.select_device('GPIB Bus - USB0::0x05E6::0x2100::1243106')
    app = QtGui.QApplication(sys.argv)
    icon = DAC_CALIBRATOR(cxncam, cxn)
    icon.show()
    app.exec_()
示例#45
0
 def __init__(self, cxn=None, **kwargs):
     if cxn == None:
         import labrad
         cxn = labrad.connect()
     HF_WLM.__init__(self, **kwargs)
示例#46
0
    def run_single(self, module):

        cxn = labrad.connect()
        pulser = cxn.pulser

        self.update_params(self.sc.all_parameters())
        if type(module) == tuple:
            multisequence_params = module[1]
            self.set_multisequence_params(multisequence_params)
            module = module[0]

        self.setup_data_vault(cxn, module.__name__)

        if 'camera' in self.parameters_dict.StateReadout.readout_mode:
            self.use_camera = True
            self.initialize_camera(cxn)
            camera = cxn.andor_server
        else:
            self.use_camera = False

        module.run_initial(cxn, self.parameters_dict)
        self.readout_save_iteration = 0

        all_data = []  # 2d numpy array
        data_x = []
        data = []

        for x in self.scan:
            print " scan param.{}".format(x)
            should_stop = self.sc._pause_or_stop(self.ident)
            if should_stop: break
            update = {self.parameter_to_scan: x}
            self.update_params(update)
            self.update_scan_param(update)
            seq = module(self.parameters_dict)
            seq.programSequence(pulser)
            print "programmed pulser"
            self.plot_current_sequence(cxn)

            repetitions = int(
                self.parameters_dict.StateReadout.repeat_each_measurement)
            if self.use_camera:

                exposures = repetitions
                camera.set_number_kinetics(exposures)
                camera.start_acquisition()

            pulser.start_number(
                int(self.parameters_dict.StateReadout.repeat_each_measurement))
            print "started {} sequences".format(
                int(self.parameters_dict.StateReadout.repeat_each_measurement))
            pulser.wait_sequence_done()
            pulser.stop_sequence()

            if not self.use_camera:
                readout_mode = self.parameters_dict.StateReadout.readout_mode
                rds = pulser.get_readout_counts()
                ion_state = readouts.pmt_simple(
                    rds, self.parameters_dict.StateReadout.threshold_list,
                    readout_mode)
                self.save_data(rds)
                data.append(ion_state)

            else:
                #get the percentage of excitation using the camera state readout
                proceed = camera.wait_for_kinetic()

                if not proceed:
                    camera.abort_acquisition()
                    self._finalize_single(cxn)
                    raise Exception(
                        "Did not get all kinetic images from camera")

                images = camera.get_acquired_data(exposures)
                camera.abort_acquisition()

                if self.name == 'ReferenceImage':
                    data = images
                    ion_state = np.ones(
                        self.parameters_dict.IonsOnCamera.ion_number)
                else:
                    ion_state, cam_readout, confidences = readouts.camera_ion_probabilities(
                        images, exposures, self.parameters_dict.IonsOnCamera,
                        self.parameters_dict.StateReadout.readout_mode)
                    self.save_confidences(confidences)
                    data.append(ion_state)

                #useful for debugging, saving the images
                #numpy.save('readout {}'.format(int(time.time())), images)
            x_shift = self.Scan_shift()

            submission = [x[self.submit_unit] + x_shift[self.submit_unit]
                          ]  # + center_frequency[self.submit_unit]]
            submission.extend(ion_state)
            data_x.append(x[self.submit_unit] + x_shift[self.submit_unit])

            module.run_in_loop(cxn, self.parameters_dict, np.array(data),
                               np.array(data_x))
            #submit the results to the data vault
            self.dv.add(submission, context=self.data_save_context)

        module.run_finally(cxn, self.parameters_dict, np.array(data),
                           np.array(data_x))
        self._finalize_single(cxn)
示例#47
0
import labrad
import numpy as np
import time
from datetime import datetime
from keysight import command_expert as kt
from labrad.units import WithUnit as U
from scipy.optimize import curve_fit
from pylab import *

# Connect to labrad
cxn_bender = labrad.connect('bender', password='******')
print 'Connected to Labrad'

# Connect to devices

trap = cxn_bender.trap_server

file_loc = 'rf_settings_101_400.txt'

start_voltage = 101
stop_voltage = 400
voltage_step = 1
max_voltage_itt = 100
voltage_convergence = .003
voltage_guess = 0

start_phase = 36.9
phase_step = .1
max_phase_itt = 25
phase_convergence = .003
示例#48
0
    def run(self, ident):
        self.ident = ident
        sequences = self.module.sequences

        cxn = labrad.connect()

        for seq in sequences:
            if type(seq) == tuple:
                multisequence_params = seq[1]
                self.parameter_to_scan, self.scan_unit, self.scan, self.submit_unit, self.scan_submit = self.scans[
                    seq[0].__name__]
            else:
                multisequence_params = None
                self.parameter_to_scan, self.scan_unit, self.scan, self.submit_unit, self.scan_submit = self.scans[
                    seq.__name__]

            try:
                if type(seq) == tuple:
                    self.window = seq[0].scannable_params[
                        self.parameter_to_scan][1]
                else:
                    self.window = seq.scannable_params[
                        self.parameter_to_scan][1]
            except:
                self.window = 'current'

            self.update_params(self.sc.all_parameters())
            if not multisequence_params is None:
                self.set_multisequence_params(multisequence_params)

            if not self.parameters_dict.Display.relative_frequencies:

                if self.window == "car1":
                    line = self.parameters_dict.DriftTracker.line_selection_1
                    center_frequency = cxn.sd_tracker.get_current_line(line)

                elif self.window == "car2":
                    line = self.parameters_dict.DriftTracker.line_selection_2
                    center_frequency = cxn.sd_tracker.get_current_line(line)

                elif self.window == "spectrum" and self.parameters_dict.Spectrum.scan_selection == "auto":
                    line = self.parameters_dict.Spectrum.line_selection
                    center_frequency = cxn.sd_tracker.get_current_line(line)
                    sideband_selection = self.parameters_dict.Spectrum.sideband_selection
                    trap = self.parameters_dict.TrapFrequencies

                    center_frequency = self.add_sidebands(
                        center_frequency, sideband_selection, trap)

                else:
                    center_frequency = U(0., self.submit_unit)

            else:
                center_frequency = U(0., self.submit_unit)

            self.center_frequency = center_frequency

            # run the single scan
            should_stop = self.sc._pause_or_stop(self.ident)
            if should_stop:
                print " stoping the scan and not proceeding to the next "
                break

            self.run_single(seq)

        cxn.disconnect()

        self.sc._finish_confirmed(self.ident)
示例#49
0
    add_params(dv)
    for i in range(11):
        x = i - 5
        for j in range(11):
            y = j - 5
            for k in range(11):
                z = k - 5
                w = math.exp(-(x**2 + y**2 + z**2) / 5**2)
                dv.add([x, y, z, w])


def main(dv):
    path = ['', 'Test', 'Demo']
    dv.cd(path, True)
    dirs, _ = dv.dir()
    new_dir = 'Demo{:04d}'.format(len(dirs))
    dv.cd(new_dir, True)
    path.append(new_dir)

    raw_input('Starting demo {}. Press [Enter] to continue. '.format(path))

    while True:
        for func in demos:
            print func.__name__
            func(dv)


if __name__ == '__main__':
    with labrad.connect() as cxn:
        main(cxn.data_vault)
示例#50
0
import labrad
import time

cxn_dmm = labrad.connect(
    "192.168.169.30"
)  #Connect to Camera computer, which includes Keithley digital multimeter (dmm)
dmmServer = cxn_dmm.keithley_2110_dmm(
)  #connect to Keithley server, known as dmmServer

cxn_pulser = labrad.connect()  #Connect to labrad manager on this computer
pulserServer = cxn_pulser.pulser()  #Connect to pulser server, known as pulser

Num_Outputs = 22  #Number of DC electrodes
DC_Voltages = list()  #An empty (to be populated) list of electrode voltages


#Sends a square pulse of time t
def sendPulse(t):
    pulserServer.switch_manual('DC multiplexer', True)
    time.sleep(t)
    pulserServer.switch_manual('DC multiplexer', False)
    time.sleep(t)


for i in range(Num_Outputs):
    sendPulse(
        0.01
    )  #Send a pulse, triggering the microcontroller to output the next voltage
    voltage = dmmServer.get_dc_volts()  #get the voltage from the Keithley
    DC_Voltages.append(voltage)  #append it to the list DC_Voltages
示例#51
0
count_time = 30
file_location = 'Z:/Group_Share/Barium/Data/2016/5/17'
# Must enter the bias voltage on the filament
bias_v = 6.6  # V
# Power Supply Settings (Amps)
ps_voltage = 25.0  #Volts (Max Voltage)
ps_current = 14.0  #Amps (Actual Current)
##############################################################################

import labrad
import numpy as np
import time
from datetime import datetime
from labrad.units import WithUnit as U

cxn = labrad.connect(labrad_manager_address)
print 'Connected to Labrad'

# Connect to servers
rga = cxn.planet_express_serial_server
sr430 = cxn.sr430_scalar_server
hp = cxn.hp6033a_server

# Set the baudrate and address for the RGA
rga.open(rga_port)
rga.baudrate(28800)

# Set the GPIB address

sr430.select_device()
hp.select_device()
示例#52
0
import sys
import labrad
import fpgatools2 as fp
import setbias as sb
from labrad.units import V
from PyQt4 import QtCore, QtGui, uic
with labrad.connect() as cxn:
    class TestWindow(QtGui.QMainWindow):
        def __init__(self):
            QtGui.QMainWindow.__init__(self)
            ui_class, widget_class = uic.loadUiType("currentBiasDAC.ui")
            self.ui = ui_class()
            self.ui.setupUi(self)
            self.show()
            self.board = 'Null'
        @QtCore.pyqtSlot(str)
        def on_boardSelect_currentIndexChanged(self, string):
            if string == 'Null':
                print 'No board connected'
            elif string == 'ADR lab FPGA 5':
                self.board = string
                try:
                    seq.select_device('ADR lab FPGA 5')
                except Exception as e:
                    print 'sequencer error'
                    self.board = 'Null'
                    self.ui.boardSelect.setCurrentIndex(0)
                    raise e
                zeroChan = fp.constMem(0.0, fluxDAC=0)
                seq.packet().memory(zeroChan).run_sequence(30).send()
示例#53
0
def main():
    with labrad.connect() as cxn:
        app = QtGui.QApplication(sys.argv)
        w = FridgeGuardianMainWindow(cxn)
        sys.exit(app.exec_())
initialize the fitter
'''
flop = rabi_flop_time_evolution(sideband_order, eta)
'''
create fitting parameters
'''
params = lmfit.Parameters()
params.add('excitation_scaling', value=0.5, vary=False)
params.add('detuning', value=0, vary=False)  #units of rabi frequency
params.add('time_2pi', value=8.2, min=0.0, vary=False)  #microseconds
params.add('nbar', value=3.44, min=0.0, max=200.0, vary=False)
params.add('alpha', value=10.0, min=0.0, max=200.0, vary=True)
'''
load the dataset
'''
dv = labrad.connect().data_vault
title, dataset = info
date, datasetName = dataset
dv.cd(['', 'Experiments', 'Blue Heat RabiFlopping', date, datasetName])
dv.open(1)
times, prob = dv.get().asarray.transpose()
tmin, tmax = times.min(), times.max()
detailed_times = np.linspace(tmin, tmax, 1000)
'''
compute time evolution of the guessed parameters
'''
guess_evolution = flop.compute_evolution_coherent(
    params['nbar'].value,
    params['alpha'].value,
    params['detuning'].value,
    params['time_2pi'].value,
示例#55
0
 def labrad_connect(self):
     cxn = labrad.connect("RoyDAQ-PC", password="******")
     self.cxn = cxn
示例#56
0
 def initialize(self):
     import labrad
     cxn = labrad.connect(name=self.name)
     self.device = self.DeviceProxy(cxn)
     self.reactor.callFromThread(self.populateGUI)
     self.reactor.callFromThread(self.connectSignals)
示例#57
0
                                     flour_temp4 + flour_temp5 +
                                     flour_temp6) / 6.0 + offset
    return flour


'''
define how to compare data to the function
'''


def micro_fit(params, x, data, err):
    model = micro_model(params, x)
    return (model - data) / err


cxn = labrad.connect()
dv = cxn.data_vault
dv.cd('', 'Experiments', 'BareLineScanRed', '2013Nov18', '1923_14')
dv.open(3)
data1 = dv.get().asarray

data1_x = data1[:, 0]
data1_yerr = np.sqrt(data1[:, 1]) / 60.0
data1_y = data1[:, 1] / 60.0

data1_y = data1_y[:-3]
data1_yerr = data1_yerr[:-3]
data1_x = data1_x[:-3]

dv.cd('', 'Experiments', 'BareLineScanRed', '2013Nov18', '1942_13')
dv.open(3)
示例#58
0
    def run(self, ident):

        print " started running"
        self.ident = ident
        cxn = labrad.connect()
        pulser = cxn.pulser

        carrier_translation = {
            'S+1/2D-3/2': 'c0',
            'S-1/2D-5/2': 'c1',
            'S+1/2D-1/2': 'c2',
            'S-1/2D-3/2': 'c3',
            'S+1/2D+1/2': 'c4',
            'S-1/2D-1/2': 'c5',
            'S+1/2D+3/2': 'c6',
            'S-1/2D+1/2': 'c7',
            'S+1/2D+5/2': 'c8',
            'S-1/2D+3/2': 'c9',
        }

        self.update_params(self.sc.all_parameters())
        line = self.parameters_dict.Spectrum.line_selection
        self.setup_data_vault(cxn, self.name)
        self.use_camera = False

        if 'camera' in self.parameters_dict.StateReadout.readout_mode:
            self.use_camera = True
            self.initialize_camera(cxn)
            camera = cxn.andor_server
        else:
            self.use_camera = False

        # sequence initializing hardware (dds_cw or mirrors?)
        self.module.run_initial(cxn, self.parameters_dict)

        self.readout_save_iteration = 0

        data = []
        data_x = []

        if self.parameters_dict.ScanParam.shuffle:
            np.random.shuffle(self.scan)

        for it, x in enumerate(self.scan):

            should_stop = self.sc._pause_or_stop(ident)
            if should_stop: break
            update = {self.parameter_to_scan: x}
            ## needs the two lines of update to ensure the proper updating!!!
            self.update_params(update)
            self.update_scan_param(update)
            seq = self.module(self.parameters_dict)
            seq.programSequence(pulser)
            print "programmed pulser"
            self.plot_current_sequence(cxn)

            repetitions = int(
                self.parameters_dict.StateReadout.repeat_each_measurement)
            if self.use_camera:

                exposures = repetitions
                camera.set_number_kinetics(exposures)
                camera.start_acquisition()

            pulser.start_number(repetitions)
            #             print "started {} sequences".format(int(self.parameters_dict.StateReadout.repeat_each_measurement))
            pulser.wait_sequence_done()
            pulser.stop_sequence()
            #print "done waiting"

            if not self.use_camera:
                readout_mode = self.parameters_dict.StateReadout.readout_mode
                rds = pulser.get_readout_counts()
                ion_state = readouts.pmt_simple(
                    rds, self.parameters_dict.StateReadout.threshold_list,
                    readout_mode)
                self.save_data(rds)
                data.append(ion_state)

            else:
                #get the percentage of excitation using the camera state readout
                proceed = camera.wait_for_kinetic()

                if not proceed:
                    camera.abort_acquisition()
                    self._finalize(cxn)
                    raise Exception(
                        "Did not get all kinetic images from camera")

                images = camera.get_acquired_data(exposures)
                camera.abort_acquisition()

                if self.name == 'ReferenceImage':
                    data = images
                    ion_no = int(self.parameters_dict.IonsOnCamera.ion_number)
                    ion_state = np.ones(ion_no)
                else:
                    ion_state, cam_readout, confidences = readouts.camera_ion_probabilities(
                        images, exposures, self.parameters_dict.IonsOnCamera,
                        self.parameters_dict.StateReadout.readout_mode)
                    self.save_confidences(confidences)
                    data.append(ion_state)

                #useful for debugging, saving the images
                #numpy.save('readout {}'.format(int(time.time())), images)

            x_shift = self.Scan_shift()

            submission = [x[self.submit_unit] + x_shift[self.submit_unit]
                          ]  # + center_frequency[self.submit_unit]]
            submission.extend(ion_state)

            # run in the loop to calculate something
            data_x.append(x[self.submit_unit] + x_shift[self.submit_unit])

            self.module.run_in_loop(cxn, self.parameters_dict, np.array(data),
                                    np.array(data_x))
            #submit the results to the data vault
            self.dv.add(submission, context=self.data_save_context)

        self.module.run_finally(cxn, self.parameters_dict, data,
                                np.array(data_x))

        self._finalize(cxn)
示例#59
0
def main():
    # Loads config
    with open("config.yml", 'r') as ymlfile:
        cfg = yaml.load(ymlfile)

    measurement = cfg['measurement']
    measurement_settings = cfg[measurement]
    balancing_settings = cfg['balancing_settings']
    lockin_settings = cfg['lockin_settings']
    acbox_settings = cfg['acbox_settings']
    dacadc_settings = cfg['dacadc_settings']
    meas_parameters = cfg['meas_parameters']
    delta_var = meas_parameters['delta_var']
    print delta_var

    # Connections and Instrument Configurations
    cxn = labrad.connect()
    reg = cxn.registry
    dv = cxn.data_vault
    dc = cxn.dac_adc
    mag = NHMFLMagnetControl.NHMFLMagnetControl()
    tc = cxn.lakeshore_372
    tc.select_device()
    lck = lockin_select(cxn, cfg['lockin'])
    lck.select_device()
    acbox = cxn.acbox
    ac_scale = init_acbox(acbox, acbox_settings)

    quad_dc = cxn.dcbox_quad_ad5780
    quad_dc.select_device()

    v_fixed = float(quad_dc.get_voltage(1)) - meas_parameters[
        'zOffset']  # this might need to have a case structure based on whats fixed?
    print("Fixed TM gating voltage is {}".format(v_fixed))

    dc.select_device()
    dc.set_conversiontime(measurement_settings['read1'], ADC_CONVERSIONTIME)
    dc.set_conversiontime(measurement_settings['read2'], ADC_CONVERSIONTIME)

    reg.cd(['Measurements', 'Capacitance'])
    rebalance = balancing_settings['rebalance']
    if rebalance:
        ch_x = measurement_settings['ch1']
        ch_y = measurement_settings['ch2']

        cb = init_bridge(lck, acbox, cfg)
        v1_balance, v2_balance = function_select(
            measurement_settings['fixed'])(balancing_settings['p0'],
                                           balancing_settings['n0'],
                                           meas_parameters['delta_var'],
                                           v_fixed)

        lck.time_constant(balancing_settings['balance_tc'])
        dc.set_voltage(ch_x, v1_balance)
        dc.set_voltage(ch_y, v2_balance)

        print cb.balance()
        cs, ds = cb.capacitance(ac_scale)
        print("Via balance: Cs = {}, Ds = {}".format(cs, ds))
        c_, d_ = cb.offBalance(ac_scale)
        print("Scaling factors for offset: Ctg {} and Dtg {}".format(c_, d_))
        reg.set('capacitance_params', [('cs', cs), ('ds', ds), ('c_', c_),
                                       ('d_', d_)])

        vb = cb.vb  # this is the balance point. this is a vector with (x,y) -> amplitude sqrt(x**2+y**2), phase (atan y/x)
        magnitude = np.sqrt(vb[0]**2 + vb[1]**2)
        phase = np.degrees(np.arctan2(vb[1], vb[0])) * (-1.0)
        if phase < 0: phase = 360 + phase
        reg.set('acbox_params', (magnitude, phase))
    else:
        acbox_params = reg.get('acbox_params')
        ref_ch = "Y" + str(balancing_settings['ref_ch'])
        acbox.set_voltage(ref_ch, acbox_params[0][0][0])
        acbox.set_phase(acbox_params[1][0][0])

        cap_params = reg.get('capacitance_params')
        cs = cap_params[0][1]
        ds = cap_params[1][1]
        c_ = cap_params[2][1]
        d_ = cap_params[3][1]
        print("Cs = {}, Ds = {}".format(cs, ds))
        print("Scaling factors for offset: Ctg {} and Dtg {}".format(c_, d_))

    capacitance_params = {
        'Capacitance': cs,
        'Dissipation': ds,
        'offbalance c_': c_,
        'offbalance d_': d_
    }

    probe = tc.probe()
    mc = tc.mc()
    p0fixed = meas_parameters['p0fixed']

    create_file(
        dv, cfg,
        **dict(
            {
                'p0fixed': p0fixed,
                'vfixed': v_fixed,
                'temperature_probe': probe,
                'temperature_magnet_chamber': mc
            }, **capacitance_params))

    #ac_gain_var = int(round(lockin_settings['acgain'] / 6.666))
    tc_var = lockin_settings['tc']
    sens_var = lockin_settings['sensitiviy']
    lck.time_constant(tc_var)
    #lck.set_ac_gain(ac_gain_var)
    lck.sensitivity(sens_var)

    s = lck.sensitivity()
    time.sleep(.25)
    t0 = time.time()

    pxsize = (meas_parameters['n0_pnts'], meas_parameters['b_pnts'])
    extent = (meas_parameters['n0_rng'][0], meas_parameters['n0_rng'][1],
              meas_parameters['b_rng'][0], meas_parameters['b_rng'][1])
    num_x0 = pxsize[0]
    num_y = pxsize[1]
    print extent, pxsize, p0fixed

    DELAY_MEAS = 3 * lockin_settings['tc'] * 1e6
    est_time = (pxsize[0] * pxsize[1] + pxsize[1]) * DELAY_MEAS * 1e-6 / 60.0
    dt = pxsize[0] * DELAY_MEAS * 1e-6 / 60.0
    print(
        "Will take a total of {} mins. With each line trace taking {} ".format(
            est_time, dt))

    field = np.linspace(extent[2], extent[3],
                        num_y)  # generate the array of fields

    dac_ch1 = measurement_settings['ch1']
    dac_ch2 = measurement_settings['ch2']
    adc_ch1 = measurement_settings['read1']
    adc_ch2 = measurement_settings['read2']

    for i in range(num_y):
        #rampfield(mag, field[i])

        if meas_parameters['bscale']:
            bscale = field[i] * 1.0 / field[0] * meas_parameters['scalefactor']
        else:
            bscale = 1

        num_x = int(num_x0 * bscale)
        ext_x = (extent[0] * bscale, extent[1] * bscale)

        m, mdn = mesh(vfixed=v_fixed,
                      offset=(0, -0.0),
                      drange=(p0fixed, p0fixed),
                      nrange=(ext_x[0], ext_x[1]),
                      fixed=measurement_settings['fixed'],
                      pxsize=(num_x, num_y),
                      delta=delta_var)

        data_x = np.zeros(num_x)
        data_y = np.zeros(num_x)

        vec_x = m[i, :][:, 0]
        vec_y = m[i, :][:, 1]

        # vec_x = (m[i, :][:, 0] - dacadc_settings['ch1_offset'])
        # vec_y = (m[i, :][:, 1] - dacadc_settings['ch2_offset'])

        md = mdn[i, :][:, 0]
        mn = mdn[i, :][:, 1]

        mask = np.logical_and(np.logical_and(vec_x <= X_MAX, vec_x >= X_MIN),
                              np.logical_and(vec_y <= Y_MAX, vec_y >= Y_MIN))
        if np.any(mask == True):
            start, stop = np.where(mask == True)[0][0], np.where(
                mask == True)[0][-1]

            num_points = stop - start + 1
            # print(time.strftime("%Y-%m-%d %H:%M:%S"))
            print("{} of {}  --> Ramping. Points: {}".format(
                i + 1, num_y, num_points))
            dc.buffer_ramp([dac_ch1, dac_ch2], [adc_ch1, adc_ch2],
                           [vec_x[start], vec_y[start]],
                           [vec_x[stop], vec_y[stop]], num_points, DELAY_MEAS,
                           ADC_AVGSIZE)

            d_read = dc.serial_poll.future(2, num_points)
            d_tmp = d_read.result()

            data_x[start:stop + 1], data_y[start:stop + 1] = d_tmp
            data_x[start:stop + 1] = (data_x[start:stop + 1] -
                                      adc_offset[0]) / adc_slope[0] / 2.5 * s
            data_y[start:stop + 1] = (data_y[start:stop + 1] -
                                      adc_offset[1]) / adc_slope[1] / 2.5 * s

        d_cap = (c_ * data_x + d_ * data_y) + cs
        d_dis = (d_ * data_x - c_ * data_y) + ds

        j = np.linspace(0, num_x - 1, num_x)
        ii = np.ones(num_x) * i
        t1 = np.ones(num_x) * time.time() - t0
        mB = np.ones(num_x) * field[i]
        totdata = np.array(
            [j, ii, vec_x, vec_y, d_cap, d_dis, mB, mn, data_x, data_y, t1])
        dv.add(totdata.T)
    print("it took {} s. to write data".format(time.time() - t0))
示例#60
0
    def sequence(self):
        p = self.parameters
        #electrode_dict = ['01','02','03','04','05','06','07','08','09','10','11','12','13','14','15','16','17','18','19','20','21']
        tot_time = p.DACcontrol.time_up
        time_at_top = tot_time - 12

        electrode_dict = ['06']
        i = 0
        cxn = labrad.connect()
        current_multipoles = cxn.dac_server.get_multipole_values()
        currentU2 = dict(current_multipoles)['U2']
        targetU2 = p.DACcontrol.U2target
        amplitude = (targetU2 - currentU2)
        #readfromfile =True;
        #filter1ms = True;
        readfromfile = True
        v = []
        f = ''
        print 'C:\Users\expcontrol\Downloads\\' + str(
            int(time_at_top)) + 'msec_at_top.txt'
        if (readfromfile):
            z = 'C:\Users\expcontrol\Downloads\\' + str(
                int(time_at_top)) + 'msec_at_top.txt'
            print z
            f = open(z, 'r')

        for line in f:
            #print line
            try:
                temp = float(line)

                v.append(temp * amplitude + currentU2)
            except ValueError:
                print 'error'

        import time
        from time import sleep
        print f
        #v = range(126)
        time.sleep(2)

        if (readfromfile):
            print 'yp'
            while i < p.DACcontrol.num_steps:
                cxn.dac_server.set_next_u2(v[i])
                i = i + 1
            cxn.dac_server.set_next_u2(currentU2)
        else:
            while i < 1:
                for elect in electrode_dict:
                    cxn.dac_server.set_voltage([(elect, 0)])
                i = i + 1
            while i < p.DACcontrol.num_steps / 2.0:
                for elect in electrode_dict:
                    cxn.dac_server.set_voltage([(elect, 2)])
                i = i + 1
            while i < p.DACcontrol.num_steps - 1:
                for elect in electrode_dict:
                    cxn.dac_server.set_voltage([(elect, 4)])
                i = i + 1
            print i
            for elect in electrode_dict:
                cxn.dac_server.set_voltage([(elect, 0)])

        print cxn.dac_server.get_analog_voltages()
        print 'Setting U2 to:', p.DACcontrol.U2target
        self.end = WithUnit(10, 'us')
        #self.addSequence(turn_off_all)
        #self.addSequence(doppler_cooling_after_repump_d)
        #if p.OpticalPumping.optical_pumping_enable:
        #    self.addSequence(optical_pumping)
        #if p.SidebandCooling.sideband_cooling_enable:
        #    self.addSequence(sideband_cooling)

        # ramp down if toggled
        if (p.DACcontrol.enable_ramp):
            print 'enabled'
            self.addSequence(advanceDACs)  #forward_ramp_U2
        print 'finished advance'

        print cxn.dac_server.get_analog_voltages()
        #        print cxn.dac_server.get_analog_voltages()
        if (p.DACcontrol.enable_ramp):
            print 'enabled'
            cxn.dac_server.reset_queue()
            self.addSequence(resetDACs)
        print 'end'
        f.close()