예제 #1
0
    def testDictBehavior_07_FromKeys_01(self):
        p = TreeDict()
        d = {}

        key_iterable = ["alphabet"]

        self.assert_(p.fromkeys(key_iterable) == d.fromkeys(key_iterable))
예제 #2
0
    def itemHash(self, *items):
	"""
	Returns a hash of arbitrary items.  This is intended to be
	used for fine-grained control of dependencies on parameters;
	the resulting value can passed to :ref:`inCache`,
	:ref:`loadFromCache`, and :ref:`saveToCache`.  For example::

          key = self.itemHash(self.p.x1, self.p.x2)

          if self.inCache(key):
              return self.loadFromCache(key)
          else:
              # process, create obj

              self.saveToCache(key, obj)

        Note that most of this functionality is provided by specifying
        `items` as a tuple to the key argument of :ref:inCache,
        :ref:loadFromCache, or :ref:saveToCache.
        
	"""

	t = TreeDict()

	for n, it in enumerate(items):
	    t["b%d" % n] = it

	return t.hash()
예제 #3
0
 def addSequence(self, sequence, replacement_dict = TreeDict(), position = None):
     """
     Insert a subsequence, position is either time or None to insert at the 
     end
     """
     if sequence not in self.required_subsequences:
         message = "Adding subsequence {0} that is not listed in the required subequences"
         raise Exception (message.format(sequence.__class__.__name__))
     if not type(replacement_dict) == TreeDict:
         raise Exception ("replacement_dict must be a TreeDict")
     for replacement_key in replacement_dict.keys():
         parsed = tuple(replacement_key.split('.'))
         key_list = self.replaced_parameters.get(sequence, [])
         if not parsed in key_list:
             message = "Error in {0}: replacing the key {1} in the sequence {2} that is not listed among the replacement parameters"
             raise Exception(message.format(self, replacement_key, sequence))
     if position is None:
         position = self.end
     # replacement conists of global replacement and keyword arguments
     replacement = TreeDict()
     replacement.update(self.replace)
     replacement.update(replacement_dict)
     seq = sequence(replacement, start = position)
     self._dds_pulses.extend( seq._dds_pulses )
     self._ttl_pulses.extend( seq._ttl_pulses )
     self.end = max(self.end, seq.end)
예제 #4
0
 def testMatch_06(self):
     p = TreeDict()
     p.a.b = 1
     p.a.a.b = 1
     p.a.a.a.c = 1
     self.assert_(p.getClosestKey('a.ab') == 'a.a.b')
     self.assert_(p.getClosestKey('a.ab',1) == ['a.a.b'])
예제 #5
0
파일: Tomography.py 프로젝트: EQ4/resonator
 def sequence(self):
     t = self.parameters.Tomography
     iteration = int(t.iteration)
     print "iteration"
     print iteration
     if not iteration in range(3):
         raise Exception("Incorrect iteration of tomography {}".format(iteration))
     if iteration == 0:
         pass
     elif iteration == 1:
         replace = TreeDict.fromdict(
             {
                 "Excitation_729.rabi_excitation_frequency": t.tomography_excitation_frequency,
                 "Excitation_729.rabi_excitation_amplitude": t.tomography_excitation_amplitude,
                 "Excitation_729.rabi_excitation_duration": t.rabi_pi_time / 2.0,
                 "Excitation_729.rabi_excitation_phase": WithUnit(0, "deg"),
             }
         )
         self.addSequence(rabi_excitation, replace)
     elif iteration == 2:
         replace = TreeDict.fromdict(
             {
                 "Excitation_729.rabi_excitation_frequency": t.tomography_excitation_frequency,
                 "Excitation_729.rabi_excitation_amplitude": t.tomography_excitation_amplitude,
                 "Excitation_729.rabi_excitation_duration": t.rabi_pi_time / 2.0,
                 "Excitation_729.rabi_excitation_phase": WithUnit(90, "deg"),
             }
         )
         self.addSequence(rabi_excitation, replace)
예제 #6
0
 def run(self, cxn, context):
     dt = self.parameters.DriftTracker
     ramsey_dt = self.parameters.DriftTrackerRamsey
     if dt.line_selection_1 == dt.line_selection_2:
         raise Exception ("The two Drift Tracking lines can not be the same")
     replace_1 = TreeDict.fromdict({
                                    'DriftTrackerRamsey.line_selection':dt.line_selection_1,
                                    'DriftTrackerRamsey.pi_time':ramsey_dt.line_1_pi_time,
                                    'DriftTrackerRamsey.amplitude':ramsey_dt.line_1_amplitude,
                                    'DriftTrackerRamsey.detuning':WithUnit(0,'Hz'),
                                    })
     replace_2 = TreeDict.fromdict({
                                    'DriftTrackerRamsey.line_selection':dt.line_selection_2,
                                    'DriftTrackerRamsey.pi_time':ramsey_dt.line_2_pi_time,
                                    'DriftTrackerRamsey.amplitude':ramsey_dt.line_2_amplitude,
                                    'DriftTrackerRamsey.detuning':WithUnit(0,'Hz')
                                    })
     
     replace_1,replace_2 = np.random.permutation([replace_1,replace_2])
     self.ramsey_dt.set_parameters(replace_1)
     self.ramsey_dt.set_progress_limits(0, 50.0)
     frequency_1,excitation = self.ramsey_dt.run(cxn, context)
     error_sensitivity = ramsey_dt.error_sensitivity
     if not 0.5 - error_sensitivity <= excitation <= 0.5 + error_sensitivity:
         raise Exception("Incorrect Excitation {}".format(replace_1.DriftTrackerRamsey.line_selection)) 
     self.ramsey_dt.set_parameters(replace_2)
     self.ramsey_dt.set_progress_limits(50.0, 100.0)
     frequency_2,excitation = self.ramsey_dt.run(cxn, context)
     if not 0.5 - error_sensitivity <= excitation <= 0.5 + error_sensitivity:
         raise Exception("Incorrect Excitation {}".format(replace_2.DriftTrackerRamsey.line_selection)) 
     self.submit_centers(replace_1,frequency_1,replace_2,frequency_2)
    def testIterators_14_Links_are_not_branches_02(self):

        p = TreeDict()
        p.a.x = 1
        p.b = p.a

        self.assert_('b' not in p.keys(recursive = False, branch_mode = 'only'))
예제 #8
0
    def sequence(self):
        r = self.parameters.Ramsey
        
        # First ramsey pulse
        replace = TreeDict.fromdict({
                                     'Excitation_729.rabi_excitation_duration':r.first_pulse_duration,
                                     'Excitation_729.rabi_excitation_phase':WithUnit(0, 'deg'),
                                     'Excitation_729.channel_729':r.channel_729,
                                     })
        self.addSequence(rabi_excitation, replace)

        # EIT Cooling
        replace = TreeDict.fromdict({
                           'EitCooling.eit_cooling_amplitude_397_linear':WithUnit(-63.0, 'dBm'),
                           'EitCooling.eit_cooling_duration':r.ramsey_time
                           })
        self.addSequence(eit_cooling, replace)

        # Second ramsey pulse
        replace = TreeDict.fromdict({
                             'Excitation_729.rabi_excitation_duration':r.second_pulse_duration,
                             'Excitation_729.rabi_excitation_phase':r.second_pulse_phase,
                             'Excitation_729.channel_729':r.channel_729,
                             })
        self.addSequence(rabi_excitation_no_offset, replace)
예제 #9
0
    def testConvertTo_05_only_local_as_values_02(self):

        t = TreeDict()

        t.x.y = 1
        t.a.b.c = 1

        a_refs = random_node_list(0, 100, 0.5)
        x_refs = random_node_list(1, 100, 0.5)

        for n in a_refs:
            t.a[n] = t.a.b

        for n in x_refs:
            t.a[n] = t.x

        d = t.a.convertTo("nested_dict", convert_values=False)

        def get_value(d, n):
            for n in n.split("."):
                d = d[n]
            return d

        for n in a_refs:
            self.assert_(type(get_value(d, n)) is dict)
            self.assert_(get_value(d, n) is d["b"])

        for n in x_refs:
            self.assert_(type(get_value(d, n)) is TreeDict)
            self.assert_(get_value(d, n) is t.x)
예제 #10
0
def runTest(preset_list, module, test_tree):
    
    # Run several different versions; with and without cache 

    def test(opttree):
        reset()
        initialize(opttree)
        runner = manager()
        
        results = runner.getResults(modules = [module], presets = preset_list)
        t = results[module]
        
        if type(test_tree) is TreeDict:
            for k, v in test_tree.iteritems():
                assert t[k] == v, ("%s: t[%s] != %s" % (module, k, repr(v)))
        else:
            assert test_tree == t
            
    
    opttree = TreeDict()
    opttree.project_directory = project_directory
    opttree.debug_mode = True
    opttree.verbose_mode = True
    
    test(opttree)
    
    opttree.cache_directory = join(project_directory, ".cache")
    
    test(opttree)
    test(opttree)
    
    shutil.rmtree(opttree.cache_directory, ignore_errors = True)
예제 #11
0
 def sequence(self):
     l = self.parameters.BareLineScan
     cycles = int(l.cycles_per_sequence)
     #turn off all the lights, then do doppler cooling
     self.end = WithUnit(10, 'us')
     self.addSequence(turn_off_all)
     self.addSequence(doppler_cooling)    
     
     frequency_advance_duration = WithUnit(6, 'us')
     ampl_off = WithUnit(-63.0, 'dBm')
     self.addDDS('397',self.end, frequency_advance_duration, l.frequency_397_pulse, ampl_off)
     self.addDDS('866',self.end, frequency_advance_duration, l.frequency_866_pulse, ampl_off) ###changed from radial to 866 :Hong
     self.end += frequency_advance_duration  
     #record timetags while switching while cycling 'wait, pulse 397, wait, pulse 866'
     start_recording_timetags = self.end
     for i in range(cycles):
         self.addSequence(empty_sequence, TreeDict.fromdict({'EmptySequence.empty_sequence_duration':l.between_pulses}))
         self.addDDS('397',self.end, l.duration_397_pulse, l.frequency_397_pulse, l.amplitude_397_pulse)
         self.end += l.duration_397_pulse
         self.addSequence(empty_sequence, TreeDict.fromdict({'EmptySequence.empty_sequence_duration':l.between_pulses}))
         self.addDDS('866',self.end, l.duration_866_pulse, l.frequency_866_pulse, l.amplitude_866_pulse) ###changed from radial to 866 :Hong
         self.end += l.duration_866_pulse
     stop_recording_timetags = self.end
     timetag_record_duration = stop_recording_timetags - start_recording_timetags
     #record timetags while cycling takes place
     self.addTTL('TimeResolvedCount',start_recording_timetags, timetag_record_duration)
     self.start_recording_timetags = start_recording_timetags
     self.timetag_record_cycle = l.between_pulses + l.duration_397_pulse + l.duration_866_pulse+l.between_pulses
예제 #12
0
    def checkUpdate_09_ProperParents(self, deep_copy, overwrite, preserve_structure):

        p = TreeDict()

        ab = p.a.b = unique_object()
        ac = p.a.c = unique_object()
        b  = p.b   = unique_object()

        p2 = TreeDict()

        p2.update(p)

        self.assert_(p.a is not p2.a)
        self.assert_(p.a.rootNode() is p)
        self.assert_(p.a.parentNode() is p)
        self.assert_(p2.a.rootNode() is p2)
        self.assert_(p2.a.parentNode() is p2)

        self.assert_(p.a.b == p2.a.b)
        self.assert_(p.a.b is p2.a.b)
        
        self.assert_(p.a.c == p2.a.c)
        self.assert_(p.a.c is p2.a.c)
            
        self.assert_(p == p2)
예제 #13
0
    def testFromdict_with_get_02(self):
        t1 = TreeDict.fromdict({'a':1,'b':2})
        
        t2 = TreeDict()
        t2.update({'a':1,'b':2})

        self.assert_(t1 == t2)
예제 #14
0
    def setup_scan(self, sideband):

        if sideband == 'blue':
                       
            replace = TreeDict.fromdict({
                    'Spectrum.sensitivity_selection':'temperature',
                    'Spectrum.scan_selection':'auto',
                    'Spectrum.sideband_selection':self.bsb_sel,
                    'Spectrum.save_directory': self.bsb_scan_dir,
                    'Spectrum.dataset_name_append':self.datasetNameAppend,
                    'Spectrum.window_name': ['Blue sideband scan']
                    })

            self.spectrum.set_parameters(replace)

        elif sideband == 'red':
            temp = self.parameters.Temperature

            replace = TreeDict.fromdict({
                    'Spectrum.sensitivity_selection': 'temperature',
                    'Spectrum.scan_selection': 'auto',
                    'Spectrum.sideband_selection':self.rsb_sel,
                    'Spectrum.save_directory': self.rsb_scan_dir,
                    'Spectrum.dataset_name_append': self.datasetNameAppend,
                    'Spectrum.window_name': ['Red sideband scan']
                    })

            self.spectrum.set_parameters(replace)
예제 #15
0
    def run(self, cxn, context):
        dt = self.parameters.DriftTracker
        ramsey_dt = self.parameters.DriftTrackerRamsey
        if dt.line_selection_1 == dt.line_selection_2:
            raise Exception ("The two Drift Tracking lines can not be the same")
        replace_1 = TreeDict.fromdict({
                                       'DriftTrackerRamsey.line_selection':dt.line_selection_1,
                                       'DriftTrackerRamsey.pi_time':ramsey_dt.line_1_pi_time,
                                       'DriftTrackerRamsey.amplitude':ramsey_dt.line_1_amplitude,
                                       'DriftTrackerRamsey.detuning':WithUnit(0,'Hz'),
                                       })
        replace_2 = TreeDict.fromdict({
                                       'DriftTrackerRamsey.line_selection':dt.line_selection_2,
                                       'DriftTrackerRamsey.pi_time':ramsey_dt.line_2_pi_time,
                                       'DriftTrackerRamsey.amplitude':ramsey_dt.line_2_amplitude,
                                       'DriftTrackerRamsey.detuning':WithUnit(0,'Hz')
                                       })
        

        self.ramsey_dt.set_parameters(replace_1)
        self.ramsey_dt.set_progress_limits(0, 50.0)
        frequency_1,excitation = self.ramsey_dt.run(cxn, context)
        self.ramsey_dt.set_parameters(replace_2)
        self.ramsey_dt.set_progress_limits(50.0, 100.0)
        frequency_2,excitation = self.ramsey_dt.run(cxn, context)
        self.submit_centers(frequency_1, frequency_2)
예제 #16
0
    def sequence(self):
        op = self.parameters.OpticalPumping

        if op.optical_pumping_type == "continuous":
            continuous = True
        elif op.optical_pumping_type == "pulsed":
            continuous = False
        else:
            raise Exception("Incorrect optical pumping type {0}".format(op.optical_pumping_type))
        if continuous:
            replace = {
                "OpticalPumpingContinuous.optical_pumping_continuous_frequency_854": op.optical_pumping_frequency_854,
                "OpticalPumpingContinuous.optical_pumping_continuous_amplitude_854": op.optical_pumping_amplitude_854,
                "OpticalPumpingContinuous.optical_pumping_continuous_frequency_729": op.optical_pumping_frequency_729,
                "OpticalPumpingContinuous.optical_pumping_continuous_amplitude_729": op.optical_pumping_amplitude_729,
                "OpticalPumpingContinuous.optical_pumping_continuous_frequency_866": op.optical_pumping_frequency_866,
                "OpticalPumpingContinuous.optical_pumping_continuous_amplitude_866": op.optical_pumping_amplitude_866,
            }
            self.addSequence(optical_pumping_continuous, TreeDict.fromdict(replace))
        else:
            # pulsed
            replace = {
                "OpticalPumpingPulsed.optical_pumping_pulsed_frequency_854": op.optical_pumping_frequency_854,
                "OpticalPumpingPulsed.optical_pumping_pulsed_amplitude_854": op.optical_pumping_amplitude_854,
                "OpticalPumpingPulsed.optical_pumping_pulsed_frequency_729": op.optical_pumping_frequency_729,
                "OpticalPumpingPulsed.optical_pumping_pulsed_amplitude_729": op.optical_pumping_amplitude_729,
                "OpticalPumpingPulsed.optical_pumping_pulsed_frequency_866": op.optical_pumping_frequency_866,
                "OpticalPumpingPulsed.optical_pumping_pulsed_amplitude_866": op.optical_pumping_amplitude_866,
            }
            self.addSequence(optical_pumping_pulsed, TreeDict.fromdict(replace))
예제 #17
0
    def testEqualityWithDanglingNode_06(self):
        p1 = TreeDict()
        p2 = TreeDict()
        p1.a = p1.b
        p2.a = p2.b

        self.assert_(p1 == p2)
예제 #18
0
    def testEqualityWithDanglingNode_04(self):
        p1 = TreeDict()
        p2 = TreeDict()
        p1.a = 1
        p2.a

        self.assert_(p1 != p2)
예제 #19
0
 def sequence(self):
     op = self.parameters.OpticalPumping
     
     if op.optical_pumping_type == 'continuous':
         continuous = True
     elif op.optical_pumping_type == 'pulsed':
         continuous = False
     else:
         raise Exception ('Incorrect optical pumping type {0}'.format(op.optical_pumping_type))
     if continuous:
         replace = {
                    'OpticalPumpingContinuous.optical_pumping_continuous_frequency_854':op.optical_pumping_frequency_854,
                    'OpticalPumpingContinuous.optical_pumping_continuous_amplitude_854':op.optical_pumping_amplitude_854,
                    'OpticalPumpingContinuous.optical_pumping_continuous_frequency_729':op.optical_pumping_frequency_729,
                    'OpticalPumpingContinuous.optical_pumping_continuous_amplitude_729':op.optical_pumping_amplitude_729,
                    'OpticalPumpingContinuous.optical_pumping_continuous_frequency_866':op.optical_pumping_frequency_866,
                    'OpticalPumpingContinuous.optical_pumping_continuous_amplitude_866':op.optical_pumping_amplitude_866,
                    }
         self.addSequence(optical_pumping_continuous, TreeDict.fromdict(replace))
     else:
         #pulsed
         replace = {
                    'OpticalPumpingPulsed.optical_pumping_pulsed_frequency_854':op.optical_pumping_frequency_854,
                    'OpticalPumpingPulsed.optical_pumping_pulsed_amplitude_854':op.optical_pumping_amplitude_854,
                    'OpticalPumpingPulsed.optical_pumping_pulsed_frequency_729':op.optical_pumping_frequency_729,
                    'OpticalPumpingPulsed.optical_pumping_pulsed_amplitude_729':op.optical_pumping_amplitude_729,
                    'OpticalPumpingPulsed.optical_pumping_pulsed_frequency_866':op.optical_pumping_frequency_866,
                    'OpticalPumpingPulsed.optical_pumping_pulsed_amplitude_866':op.optical_pumping_amplitude_866,
                    }
         self.addSequence(optical_pumping_pulsed, TreeDict.fromdict(replace))
 def run(self, cxn, context):
     replace_no_mirror = TreeDict.fromdict({
                                    'Parity_LLI.mirror_state':False,
                                    'Parity_LLI.use_short_ramsey_time':False,
                                    })
     replace_mirror = TreeDict.fromdict({
                                    'Parity_LLI.mirror_state':True,
                                    'Parity_LLI.use_short_ramsey_time':False,
                                    })
     random_number = np.random.rand()
     
     if (random_number>0.5):
         self.parity_LLI.set_parameters(replace_no_mirror)
         phase_no_mirror = self.parity_LLI.run(cxn, context)
         self.parity_LLI.set_parameters(replace_mirror)
         phase_mirror = self.parity_LLI.run(cxn, context)
     else:
         self.parity_LLI.set_parameters(replace_mirror)
         phase_mirror = self.parity_LLI.run(cxn, context)            
         self.parity_LLI.set_parameters(replace_no_mirror)
         phase_no_mirror = self.parity_LLI.run(cxn, context)  
               
     average_phase = (phase_no_mirror+phase_mirror)/2.0
     difference_phase = (phase_no_mirror-phase_mirror)/2.0
     submission = [time.time(),phase_mirror['deg'],phase_no_mirror['deg'],average_phase['deg'],difference_phase['deg']]
     self.dv.add(submission,context=self.save_data)
예제 #21
0
    def testRetrieve_03_ThroughLink(self):
        p = TreeDict()
        p.a.b.link = p.d
        p.d.v = 1

        self.assert_(p["a.b.link.v"] == 1)
        self.assert_(p.get("a.b.link.v") == 1)
예제 #22
0
    def sequence(self):
        p = self.parameters
        self.end = WithUnit(10, 'us')

        self.addSequence(turn_off_all)
        
        self.addSequence(repump_d)
        
        self.addSequence(rabi_excitation_select_channel)
        
        self.addSequence(state_readout)        
        
        self.addSequence(empty_sequence, TreeDict.fromdict({'EmptySequence.empty_sequence_duration':WithUnit(10,'ms')})) ##state readout has 2ms hangover.  It shouldn't. Ask Dylan
        
        self.addSequence(doppler_cooling)
        if p.OpticalPumping.optical_pumping_enable:
            self.addSequence(optical_pumping)
        if p.SidebandCooling.sideband_cooling_enable:
            self.addSequence(sideband_cooling)

        self.addSequence(ramp_voltage)

        self.addSequence(empty_sequence, TreeDict.fromdict({'EmptySequence.empty_sequence_duration':p.Heating.background_heating_time}))
        
        self.addSequence(empty_sequence, TreeDict.fromdict({'EmptySequence.empty_sequence_duration':WithUnit(1,'us')}))
        
        self.addSequence(ramp_voltage)

        self.addSequence(state_readout)
        
        self.addSequence(reset_dac)
예제 #23
0
    def testRecursiveAttach_03_recursive_with_linked_nodes(self):
        p = TreeDict()

        p.a = p.adef.a
        p.adef.a.v = 1

        p.attach(recursive=True)
예제 #24
0
 def sequence(self):
     p = self.parameters
     self.end = WithUnit(10, 'us')
     self.addSequence(turn_off_all)
     if p.DopplerCooling.mode_swapping_enable:
         self.addSequence(doppler_cooling_with_mode_coupling)
     else:
         self.addSequence(doppler_cooling_after_repump_d)
     if p.OpticalPumping.optical_pumping_enable:
         self.addSequence(optical_pumping)
     if p.SidebandCooling.sideband_cooling_enable:
         if p.SidebandPrecooling.sideband_precooling_enable:
             self.addSequence(sideband_precooling)
         self.addSequence(sideband_cooling)
     if p.PulsedHeating.pulsed_heating_enable:
         #self.addSequence(pulsed_heating)
         self.addSequence(pi_pulse)
         self.addSequence(repump_d)
         self.addSequence(optical_pumping)
     if p.ParametricCoupling.parametric_coupling_enable:
         self.addSequence(parametric_coupling, TreeDict.fromdict({'ParametricCoupling.parametric_coupling_phase':WithUnit(0, 'deg')}))
     if p.WireCharging.wire_charging_enable:
         self.addSequence(wire_charging, TreeDict.fromdict({'EmptySequence.empty_sequence_duration':p.WireCharging.wire_charging_duration}))
     self.addSequence(empty_sequence, TreeDict.fromdict({'EmptySequence.empty_sequence_duration':p.Heating.background_heating_time}))
     if p.ParametricCoupling.swap_after_heating:
         self.addSequence(parametric_coupling, TreeDict.fromdict({'ParametricCoupling.drive_frequency': p.ParametricCoupling.drive_frequency}))
     self.start_excitation_729 = self.end
     self.addSequence(rabi_excitation)
     self.addSequence(state_readout)
예제 #25
0
    def testBranchStructureFrozen_01(self):

        p = TreeDict()
        p.a = TreeDict(x = 1)
        p.freeze(structure_only = True)

        self.assertRaises(TypeError, lambda: p.attach(recursive = True))
예제 #26
0
    def sequence(self):
        r = self.parameters.Ramsey
        p = self.parameters.Excitation_729
        
        # Add the 6 us waits manually here before starting the ladder sequence
        frequency_advance_duration = WithUnit(6, 'us')
        ampl_off = WithUnit(-63.0, 'dBm')
        self.addDDS(r.ladder_blue_channel_729, self.start,                            frequency_advance_duration, r.ladder_blue_frequency, ampl_off)
        self.addDDS(r.ladder_red_channel_729,  self.start+frequency_advance_duration, frequency_advance_duration, r.ladder_red_frequency, ampl_off)
        ramsey_start = self.start+WithUnit(12, 'us')

        # First set of pulses
        self.addSequence(ladder_excitation_no_offset, position=ramsey_start)

        # Set of echo pulses
        if r.spin_echo_enable:
            # First calculate how much time the echo pulses will take
            n_blue_pulses = r.ladder_number_pi_steps + ((r.ladder_number_pi_steps+1)%2)
            n_red_pulses = r.ladder_number_pi_steps + (r.ladder_number_pi_steps%2)
            echo_time = n_blue_pulses*r.ladder_blue_pi_duration + n_red_pulses*r.ladder_red_pi_duration

            # Now add the pulses. Wait times will have half the echo time subtracted off.
            self.addSequence(empty_sequence, TreeDict.fromdict({'EmptySequence.empty_sequence_duration':(r.ramsey_time-echo_time)/2}))
            self.addSequence(ladder_excitation_reverse_no_offset, TreeDict.fromdict({'Ramsey.second_pulse_phase':WithUnit(0, 'deg')})) #There should be no extra phase on this pulse since it's just supposed to be the echo
            self.addSequence(ladder_excitation_no_offset)
            self.addSequence(empty_sequence, TreeDict.fromdict({'EmptySequence.empty_sequence_duration':(r.ramsey_time-echo_time)/2}))
        else:
            self.addSequence(empty_sequence, TreeDict.fromdict({'EmptySequence.empty_sequence_duration':r.ramsey_time}))
        
        # Final set of pulses
        self.addSequence(ladder_excitation_reverse_no_offset)
예제 #27
0
 def testDangling_09_Count_03b_Deletion(self):
     p = TreeDict()
     self.assert_(p._numDangling() == 0)
     p.a
     self.assert_(p._numDangling() == 1)
     del p["a"]
     self.assert_(p._numDangling() == 0)
예제 #28
0
    def sequence(self):
        r = self.parameters.Ramsey
        replace = TreeDict.fromdict({
                                     'Excitation_729.rabi_excitation_duration':r.first_pulse_duration,
                                     'Excitation_729.rabi_excitation_phase':WithUnit(0, 'deg'),
                                     'Excitation_729.channel_729':r.channel_729,
                                     'Excitation_729.rabi_excitation_frequency':r.first_pulse_frequency
                                     }) 
        awg_wait_time = WithUnit(2,'ms')

        self.addTTL('awg_off',self.start,awg_wait_time+r.ramsey_time+r.first_pulse_duration+r.second_pulse_duration)
        #self.addTTL('awg_on',self.start,awg_wait_time+r.ramsey_time+r.first_pulse_duration+r.second_pulse_duration)
        self.addSequence(empty_sequence, TreeDict.fromdict({'EmptySequence.empty_sequence_duration':awg_wait_time}))
        self.addSequence(rabi_excitation, replace)
        if r.spin_echo_enable:
          self.addSequence(empty_sequence_with_echo, TreeDict.fromdict({'EmptySequence.empty_sequence_duration':r.ramsey_time}))
        else:
          self.addSequence(empty_sequence, TreeDict.fromdict({'EmptySequence.empty_sequence_duration':r.ramsey_time}))
        #self.addDDS('radial', self.end, r.ramsey_time, WithUnit(220.0,'MHz'), WithUnit(-13.0,'dBm'))
        #self.end = self.end + r.ramsey_time
        replace = TreeDict.fromdict({
                             'Excitation_729.rabi_excitation_duration':r.second_pulse_duration,
                             'Excitation_729.rabi_excitation_phase':r.second_pulse_phase,
                             'Excitation_729.channel_729':r.channel_729,
                             'Excitation_729.rabi_excitation_frequency':r.second_pulse_frequency
                             })
        self.addSequence(rabi_excitation_no_offset, replace)
        # self.addSequence(rabi_excitation_no_offset, replace) #this is technically correct but can't do pulses shorter than 6us
        # print(r.first_pulse_frequency,r.second_pulse_frequency,r.first_pulse_frequency-r.second_pulse_frequency)
        # print(r.second_pulse_duration,r.first_pulse_duration)
예제 #29
0
 def test02(self):
     
     test_tree = TreeDict()
     test_tree.x = 1
     test_tree.a = 10
     test_tree.b = 2
     
     runTest(['change_default_a'], 'data', test_tree)
예제 #30
0
 def test03(self):
     
     test_tree = TreeDict()
     test_tree.x = 2
     test_tree.a = 1
     test_tree.b = 2
     
     runTest(['data.set_X_2'], 'data', test_tree)
 def sequence(self):
     p = self.parameters
     self.end = WithUnit(10, 'us')
     self.addSequence(turn_off_all)
     self.addSequence(doppler_cooling_after_repump_d)
     self.addSequence(resonant_heating)
     self.addSequence(empty_sequence, TreeDict.fromdict({'EmptySequence.empty_sequence_duration':p.Heating.coherent_evolution_time}))
     self.addSequence(resonant_heating)
     self.addSequence(empty_sequence, TreeDict.fromdict({'EmptySequence.empty_sequence_duration':p.Heating.background_heating_time}))
     if p.OpticalPumping.optical_pumping_enable:
         self.addSequence(optical_pumping)
     if p.SidebandCooling.sideband_cooling_enable:
         self.addSequence(sideband_cooling)
     self.addSequence(rabi_excitation)
     self.addSequence(tomography_readout)
예제 #32
0
 def run(self):
     repetitions = 10
     pulse_sequence = self.pulse_sequence(TreeDict({}))
     pulse_sequence.programSequence(self.pulser)
     self.pulser.start_number(repetitions)
     self.pulser.wait_sequence_done()
     self.pulser.stop_sequence()
예제 #33
0
 def sequence(self):
     p = self.parameters
     self.end = WithUnit(10, 'us')
     self.addSequence(turn_off_all)
     if p.DopplerCooling.mode_swapping_enable:
         self.addSequence(doppler_cooling_with_mode_coupling)
     else:
         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)
     self.addSequence(pi_pulse)
     self.addSequence(repump_d)
     self.addSequence(optical_pumping)
     self.addSequence(parametric_coupling)
     self.addSequence(
         empty_sequence,
         TreeDict.fromdict({
             'EmptySequence.empty_sequence_duration':
             p.Heating.background_heating_time
         }))
     self.start_excitation_729 = self.end
     self.addSequence(rabi_excitation)
     self.addSequence(state_readout)
예제 #34
0
    def run(self, cxn, context):

        self.scan = []

        mint, maxt, steps = self.parameters.VAET.duration_scan
        mint = mint['us']
        maxt = maxt['us']
        self.scan = np.linspace(mint, maxt, steps)

        ## randomize the times
        #np.random.shuffle(self.scan)

        self.scan = [WithUnit(pt, 'us') for pt in self.scan]

        prog1 = 0
        prog2 = 100.0 / len(self.scan)

        for i, duration in enumerate(self.scan):
            print "VAET duration: " + str(duration)

            #should_stop = self.pause_or_stop()
            if self.should_stop: break

            replace = TreeDict.fromdict({'VAET.duration': duration})

            self.vaet.set_parameters(replace)
            self.vaet.set_progress_limits(prog1, prog2)
            prog1 += 100.0 / len(self.scan)
            prog2 += 100.0 / len(self.scan)

            self.vaet.run(cxn, context)
 def run_right_ion_p12p52(self, cxn, context):
     center_power = self.parameters[
         'Parity_transitions.right_ionSp12Dp52_power']
     minim = center_power - self.span / 2.0
     maxim = center_power + self.span / 2.0
     scan = [minim, maxim, self.steps]
     replace = TreeDict.fromdict({
         'Rabi_excitation_729_2ions.use_primary_dds':
         False,
         'RabiPowerFlopping_2ions.block_ion1_729':
         True,
         'RabiPowerFlopping_2ions.block_ion2_729':
         False,
         'RabiPowerFlopping_2ions.ion1_line_selection':
         'S-1/2D-5/2',
         'RabiPowerFlopping_2ions.ion2_line_selection':
         'S+1/2D+5/2',
         'OpticalPumping.line_selection':
         'S+1/2D-3/2',
         'OpticalPumpingAux.aux_op_line_selection':
         'S-1/2D+3/2',
         'RabiPowerFlopping_2ions.manual_power_scan':
         scan,
     })
     self.power_flop.set_parameters(replace)
     self.power_flop.setup_sequence_parameters()
     target_power, accepted = self.power_flop.run(cxn, context)
     if self.enable_feedback:
         if accepted:
             self.pv.set_parameter('Parity_transitions',
                                   'right_ionSp12Dp52_power', target_power)
예제 #36
0
    def run(self, cxn, context):
        time_scan = [WithUnit(0, 'us'), WithUnit(50, 'us'), 60]
        
        ms = self.parameters.MolmerSorensen
        lr = self.parameters.LocalRotation
        replace = TreeDict.fromdict({
            'RabiFlopping.manual_scan':time_scan,
            'RabiFlopping.line_selection':ms.line_selection,
            'RabiFlopping.rabi_amplitude_729':lr.amplitude,
            'RabiFlopping.frequency_selection':'auto',
            'RabiFlopping.sideband_selection':[0,0,0,0],
            'Excitation_729.channel_729':'729local',
            })

        self.rabi_flop.set_parameters(replace)
        t, ex = self.rabi_flop.run(cxn, context)

        ex = ex.flatten()

        #print ex

        t_pi = self.fitter.fit(t, ex)
        t_pi = WithUnit(t_pi, 'us')
        
        self.pv.set_parameter('LocalRotation', 'pi_time', t_pi)
        print t_pi
 def run_left_ion_m12m52_drift_track(self, cxn, context):
     center_power = self.parameters['DriftTrackerRamsey.line_1_amplitude']
     minim = center_power - self.span / 2.0
     maxim = center_power + self.span / 2.0
     scan = [minim, maxim, self.steps]
     replace = TreeDict.fromdict({
         'Rabi_excitation_729_2ions.use_primary_dds':
         True,
         'RabiPowerFlopping_2ions.block_ion1_729':
         False,
         'RabiPowerFlopping_2ions.block_ion2_729':
         True,
         'RabiPowerFlopping_2ions.ion1_line_selection':
         'S-1/2D-5/2',
         'RabiPowerFlopping_2ions.ion2_line_selection':
         'S-1/2D-1/2',
         'RabiPowerFlopping_2ions.ion1_excitation_duration':
         WithUnit(20.0, 'us'),
         'OpticalPumping.line_selection':
         'S+1/2D-3/2',
         'OpticalPumpingAux.aux_op_line_selection':
         'S-1/2D+3/2',
         'RabiPowerFlopping_2ions.manual_power_scan':
         scan,
     })
     self.power_flop.set_parameters(replace)
     self.power_flop.setup_sequence_parameters()
     target_power, accepted = self.power_flop.run(cxn, context)
     if self.enable_feedback:
         if accepted:
             self.pv.set_parameter('DriftTrackerRamsey', 'line_1_amplitude',
                                   target_power)
예제 #38
0
def main():
    import labrad
    cxn = labrad.connect()
    import time
    from treedict import TreeDict
    cxn.pulser.switch_auto('adv', True)
    cxn.pulser.switch_auto('rst', True)
    #cxn.pulser.switch_auto('adv')
    #cxn.pulser.switch_auto('rst')
    params = test_parameters.parameters
    d = TreeDict()
    #make a treedictionary out of the parameters
    for (collection, param), value in test_parameters.parameters.iteritems():
        d['{0}.{1}'.format(collection, param)] = value

    tinit = time.time()
    cs = fast_change_impulse(d)
    cs.programSequence(cxn.pulser)
    print 'to program', time.time() - tinit
    cxn.pulser.start_number(140)
    cxn.pulser.wait_sequence_done()
    cxn.pulser.stop_sequence()
    cxn.pulser.switch_auto('adv', False)
    cxn.pulser.switch_auto('rst', False)
    cxn.pulser.switch_manual('adv', True)
    cxn.pulser.switch_manual('adv', False)
    def run(self, cxn, context):
        self.setup_data_vault()
        dt = self.parameters.DriftTrackerRamsey
        excitations = []
        frequency = cm.frequency_from_line_selection('auto', None , dt.line_selection, self.drift_tracker)
        frequency = frequency + dt.detuning
        for iter,phase in enumerate(self.phases):
            replace = TreeDict.fromdict({
                                           'Ramsey.rabi_pi_time':dt.pi_time,
                                           'Ramsey.ramsey_time':dt.gap_time,
                                           'Ramsey.second_pulse_phase':phase,
                                           'Excitation_729.rabi_excitation_amplitude':dt.amplitude,
                                           'Excitation_729.rabi_excitation_frequency':frequency,
                                           'Tomography.iteration':0.0,
                                           'StateReadout.repeat_each_measurement':dt.readouts,
                                           'SidebandCooling.sideband_cooling_enable':False,
                                           'OpticalPumping.optical_pumping_enable':True,
                                           })
            self.excitation.set_parameters(replace)
            self.update_progress(iter)
            if not self.parameters.StateReadout.use_camera_for_readout:
                #using PMT
                excitation = self.excitation.run(cxn, context)[0]
            else:
                primary_ion = int(self.parameters.StateReadout.camera_primary_ion)
                excitation = self.excitation.run(cxn, context)[primary_ion]
            excitations.append(excitation)
        detuning, average_excitation = self.calculate_detuning(excitations)
        corrected_frequency = frequency + detuning
#        print corrected_frequency, average_excitation
        return corrected_frequency,average_excitation
    def run(self, cxn, context):
        scan_param = self.parameters.CalibrationScans.heating_rate_scan_interval
        self.scan = scan_methods.simple_scan(scan_param, 'us')

        times = []
        ts = []
        ps = []

        for i, heat_time in enumerate(self.scan):
            times.append(heat_time)
            replace = TreeDict.fromdict({
                'Heating.background_heating_time':
                heat_time,
            })
            self.rabi_flopping.set_parameters(replace)
            t, ex = self.rabi_flopping.run(cxn, context)
            t = np.array(t)
            ex = np.array(ex)
            ex = ex.flatten()
            ts.append(t)
            ps.append(ex)
            if heat_time == 0:
                time_2pi = self.fitter.calc_2pitime(t, ex)
            self.rabi_flopping.finalize(cxn, context)

        trap_freq = self.parameters.TrapFrequencies.axial_frequency['Hz']
        rate = self.fitter.fit(times, ts, ps, trap_freq, time_2pi)
        print 'here is the rate'
        print rate
예제 #41
0
    def testFromdict_with_get_02(self):
        t1 = TreeDict.fromdict({'a':1,'b':2})
        
        t2 = makeTDInstance()
        t2.update({'a':1,'b':2})

        self.assert_(t1 == t2)
예제 #42
0
    def run(self, cxn, context):

        dv_args = {
            'output_size': self.rabi_flop.excite.output_size,
            'experiment_name': self.name,
            'window_name': 'other',
            'dataset_name': 'det_scan'
        }
        scan_methods.setup_data_vault(cxn, self.save_context, dv_args)

        scan_param = self.parameters.CalibrationScans.sbc_ac_stark
        self.scan = scan_methods.simple_scan(scan_param, 'kHz')

        self.scan = np.arange(1, 31, 1)

        for i, number in enumerate(self.scan):
            should_stop = self.pause_or_stop()
            if should_stop: break
            replace = TreeDict.fromdict(
                {'SidebandCooling.sideband_cooling_cycles': number})
            self.rabi_flop.set_parameters(replace)
            excitation = self.rabi_flop.run(cxn, context)
            if excitation is None: break
            submission = [number]
            submission.extend([excitation])
            self.dv.add(submission, context=self.save_context)
            self.update_progress(i)
 def run(self, cxn, context):
     
     dv_args = {'output_size':self.rabi_flop.excite.output_size,
                'experiment_name': self.name,
                'window_name': 'current',
                'dataset_name': '854_scan'
                }
     scan_methods.setup_data_vault(cxn, self.save_context, dv_args)
     
     scan_param = self.parameters.CalibrationScans.sbc_854_scan
     self.scan = scan_methods.simple_scan(scan_param, 'dBm')
     
     for i,ampl in enumerate(self.scan):
         should_stop = self.pause_or_stop()
         if should_stop: break
         replace = TreeDict.fromdict({
                                  'SidebandCooling.sideband_cooling_amplitude_854':ampl
                                 })
         self.rabi_flop.set_parameters(replace)
         excitation = self.rabi_flop.run(cxn, context)
         if excitation is None: break 
         submission = [ampl['dBm']]
         submission.extend([excitation])
         self.dv.add(submission, context = self.save_context)
         self.update_progress(i)
예제 #44
0
 def sequence(self):
     spec_time = self.parameters.Spectroscopy_397.readout_duration
     spec_power = self.parameters.Spectroscopy_397.power_397
     spec_freq = self.parameters.Spectroscopy_397.frequency_397
     
     channel = self.parameters.Spectroscopy_397.calibration_channel_397
     if channel == 'linear':
         calib_channel = self.parameters.StatePreparation.channel_397_linear
     elif channel == 'sigma':
         calib_channel = self.parameters.StatePreparation.channel_397_sigma
         
     
     
     #add the sequence
     #self.addSequence(repump_d)
     
     #self.end = self.start + spec_time
     replacement = TreeDict.fromdict({
                                         'DopplerCooling.doppler_cooling_duration':spec_time,
                                         'DopplerCooling.doppler_cooling_amplitude_397':spec_power,
                                         'DopplerCooling.doppler_cooling_frequency_397':spec_freq/2.0, #divide by two because sending to a double pass AOM 
                                         'StatePreparation.channel_397_linear':calib_channel
                                     })
     
     self.addSequence(doppler_cooling, replacement)
     self.addTTL('ReadoutCount', self.start, spec_time)
예제 #45
0
    def run(self, cxn, context):

        self.set_scannable_parameters()
        self.pulser.frequency('369DP', self.freq)
        self.programPulseSequence(self.record_time)
        self.setup_datavault('Frequencies', 'Amplitude')
        self.setup_grapher('PMT FFT')

        pwr = np.zeros_like(self.freqs)
        for i in range(self.average):
            seq = record_timetags(TreeDict.fromdict({'RecordTimetags.record_timetags_duration': self.record_time}))
            seq.programSequence(self.pulser)
            self.pulser.reset_timetags()
            self.pulser.start_single()
            self.pulser.wait_sequence_done()
            self.pulser.stop_sequence()
            timetags = self.pulser.get_timetags()
            should_break = self.update_progress(i/float(self.average))
            if should_break:
                break
            new_pwr =  self.processor.getPowerSpectrum(self.freqs, timetags, self.record_time, U(10.0, 'ns'))
            np.add(pwr, new_pwr, out=pwr, casting="unsafe")
            #pwr += self.processor.getPowerSpectrum(self.freqs, timetags, self.record_time, U(10.0, 'ns'))
        pwr = pwr / float(self.average)
        data = np.array(np.vstack((self.freqs, pwr)).transpose(), dtype='float')
        self.dv.add(data)
    def run(self, cxn, context):

        dv_args = {'output_size': 1,
                    'experiment_name' : self.name,
                    'window_name': 'current',
                    'dataset_name' : 'Heating_Rate'
                    }

        scan_methods.setup_data_vault(cxn, self.save_context, dv_args)

        scan_param = self.parameters.CalibrationScans.heating_rate_scan_interval

        self.scan = scan_methods.simple_scan(scan_param, 'us')

        for i,heat_time in enumerate(self.scan):
            #should_stop = self.pause_or_stop()
            #if should_stop: break
       
            replace = TreeDict.fromdict({
                                    'Heating.background_heating_time':heat_time,
                                    'Documentation.sequence':'calibrate_heating_rates',
                                       })
            
            self.calibrate_temp.set_parameters(replace)
            #self.calibrate_temp.set_progress_limits(0, 33.0)
   
            (rsb_ex, bsb_ex) = self.calibrate_temp.run(cxn, context)

            fac = rsb_ex/bsb_ex
            nbar = fac/(1.0-fac)

            submission = [heat_time['us']]
            submission.extend([nbar])
            #print nbar
            self.dv.add(submission, context = self.save_context)
예제 #47
0
    def sequence(self):
        p = self.parameters
        wait_time = p.MolmerSorensen.wait_time
        self.end = WithUnit(10, 'us')
        self.addSequence(turn_off_all)

        self.addSequence(doppler_cooling_after_repump_d)
        if p.StatePreparation.optical_pumping_enable:
            self.addSequence(optical_pumping)
        if p.StatePreparation.sideband_cooling_enable:
            self.addSequence(sideband_cooling)
        #self.addSequence(global_rotation)
        #self.addSequence(empty_sequence, TreeDict.fromdict({'EmptySequence.empty_sequence_duration':WithUnit(2, 'ms')}))
        #self.addSequence(vaet)
        if p.MolmerSorensen.SDDS_enable:
            self.addSequence(local_rotation)
        self.addSequence(molmer_sorensen)
        if p.MolmerSorensen.SDDS_rotate_out:
            self.addSequence(local_rotation)
        # adding a controled waiting time
        self.addSequence(
            empty_sequence,
            TreeDict.fromdict(
                {'EmptySequence.empty_sequence_duration': wait_time}))
        self.addSequence(global_rotation)
        self.addSequence(tomography_readout)
예제 #48
0
    def run(self, cxn, context):
        self.scan_phi = [WithUnit(x, 'deg') for x in [0.0, 90.0, 180.0, 270.0]]
        self.setup_data_vault()
        scan_time = scan_methods.simple_scan(self.parameters.SZX.duration_scan,
                                             'us')
        self.scan = scan_time
        for i, t in enumerate(scan_time):
            should_stop = self.pause_or_stop()
            if should_stop: break
            p = []
            for j, phi in enumerate(self.scan_phi):
                replace = TreeDict.fromdict({'SZX.duration': t})
                replace['SZX.second_pulse_phase'] = phi
                self.excite.set_parameters(replace)
                p.extend(self.excite.run(cxn, context))

            submission = [t['us']]
            print p
            submission.extend(p)
            p0, p90, p180 = p[0], p[1], p[2]
            #print p0
            k = p0 + p180
            c = np.sqrt((2 * p0 - k)**2 + (2 * p90 - k)**2)
            submission.extend([c])
            self.dv.add(submission, context=self.save_context)
            self.update_progress(i)
예제 #49
0
 def sequence(self):
     #print "blue heating"
     h = self.parameters.Heating
     self.addSequence(
         empty_sequence,
         TreeDict.fromdict({
             'EmptySequence.empty_sequence_duration':
             h.blue_heating_delay_before
         }))
     self.addSequence(local_blue_heating)
     self.addSequence(
         empty_sequence,
         TreeDict.fromdict({
             'EmptySequence.empty_sequence_duration':
             h.blue_heating_delay_after
         }))
예제 #50
0
 def sequence(self):
     dc_duration = self.parameters.DopplerCooling.doppler_cooling_duration
     #add the sequence
     self.addSequence(repump_d)
     stop_repump_d = self.end
     replacement = TreeDict.fromdict({'DopplerCooling.doppler_cooling_duration':stop_repump_d + dc_duration})
     self.addSequence(doppler_cooling, replacement, position = self.start)
예제 #51
0
    def sequence(self):
        p = self.parameters
        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)

        ################3
        self.addSequence(ramp_voltage_up)
        ###############33
        self.addSequence(
            empty_sequence,
            TreeDict.fromdict({
                'EmptySequence.empty_sequence_duration':
                p.Heating.background_heating_time
            }))
        self.addSequence(rabi_excitation_select_channel)

        #############
        self.addSequence(reset_dac)
        ##############

        #print self.parameters.Excitation_729.rabi_excitation_frequency
        #import IPython
        #IPython.embed()

        self.addSequence(tomography_readout)
예제 #52
0
 def run(self, cxn, context):
     
     dv_args = {'output_size':self.rabi_flop.excite.output_size,
                'experiment_name': self.name,
                'window_name': 'MotionalRamseyTime',
                'dataset_name': 'ramsey_time'
                }
     scan_methods.setup_data_vault(cxn, self.save_context, dv_args)
     
     scan_param = self.parameters.Motion_Analysis.scan_ramsey_time
     self.scan = scan_methods.simple_scan(scan_param, 'us')
     
     for i,t in enumerate(self.scan):
         should_stop = self.pause_or_stop()
         if should_stop: break
         replace = TreeDict.fromdict({
                                  'Motion_Analysis.ramsey_time':t
                                 })
         self.rabi_flop.set_parameters(replace)
         excitation = self.rabi_flop.run(cxn, context)
         if excitation is None: break 
         submission = [t['us']]
         submission.extend([excitation])
         self.dv.add(submission, context = self.save_context)
         self.update_progress(i)
예제 #53
0
    def testFromKeys_01_setting(self):

        key_iterable = ["a", "b", "cdef"]

        p = TreeDict.fromkeys(key_iterable)

        for n in key_iterable:
            self.assertTrue(p.get(n) is None)
예제 #54
0
 def sequence(self):
     p = self.parameters.PiPulse
     replace = TreeDict.fromdict({
             'Excitation_729.rabi_excitation_duration': p.pi_time,
             'Excitation_729.rabi_excitation_amplitude': p.rabi_amplitude_729,
             'Excitation_729.rabi_excitation_frequency': p.rabi_excitation_frequency
             })
     self.addSequence(rabi_excitation, replace)
예제 #55
0
 def sequence(self):
     r = self.parameters.Ramsey
     replace = TreeDict.fromdict({
                                  'Excitation_729.rabi_excitation_duration':r.first_pulse_duration,
                                  'Excitation_729.rabi_excitation_phase':WithUnit(0, 'deg'),
                                  'Excitation_729.channel_729':r.channel_729,
                                  }) 
     self.addSequence(rabi_excitation, replace)
     self.addSequence(empty_sequence, TreeDict.fromdict({'EmptySequence.empty_sequence_duration':r.ramsey_time}))
     #self.addDDS('radial', self.end, r.ramsey_time, WithUnit(220.0,'MHz'), WithUnit(-13.0,'dBm'))
     #self.end = self.end + r.ramsey_time
     replace = TreeDict.fromdict({
                          'Excitation_729.rabi_excitation_duration':r.second_pulse_duration,
                          'Excitation_729.rabi_excitation_phase':r.second_pulse_phase,
                          'Excitation_729.channel_729':r.channel_729,
                          })
     self.addSequence(rabi_excitation_no_offset, replace)
예제 #56
0
    def sequence(self):

        sc = self.parameters.SidebandCooling
        scc = self.parameters.SidebandCoolingContinuous
        spc = self.parameters.SidebandPrecooling

        repump_dur = WithUnit(100, 'us')
        f_repump = WithUnit(80, 'MHz')

        if spc.mode_1 == 'aux_radial': channel1 = '729local'
        if spc.mode_1 == 'aux_axial': channel1 = '729global'
        if spc.mode_2 == 'aux_radial': channel2 = '729local'
        if spc.mode_2 == 'aux_axial': channel2 = '729global'

        cooling_duration = scc.sideband_cooling_continuous_duration
        cooling_amplitude = sc.sideband_cooling_amplitude_729
        amp_854 = sc.sideband_cooling_amplitude_854
        amp_866 = sc.sideband_cooling_amplitude_866

        op_replace = {
            'OpticalPumping.optical_pumping_continuous':
            True,
            'OpticalPumpingContinuous.optical_pumping_continuous_duration':
            sc.sideband_cooling_optical_pumping_duration
        }

        self.end = self.start
        do_optical_pumping = False

        for n in range(int(spc.cycles)):
            self.cycle_start_time = self.end

            if spc.mode_1 != 'off':
                self.addDDS(channel1, self.cycle_start_time, cooling_duration,
                            spc.frequency_1, cooling_amplitude)
                self.addDDS('854', self.cycle_start_time,
                            cooling_duration + repump_dur, f_repump, amp_854)
                self.addDDS('866', self.cycle_start_time,
                            cooling_duration + repump_dur, f_repump, amp_866)
                self.end = self.cycle_start_time + cooling_duration + repump_dur
                do_optical_pumping = True
                self.cycle_start_time = self.end

            if spc.mode_2 != 'off':
                self.addDDS(channel2, self.cycle_start_time, cooling_duration,
                            spc.frequency_2, cooling_amplitude)
                self.addDDS('854', self.cycle_start_time,
                            cooling_duration + repump_dur, f_repump, amp_854)
                self.addDDS('866', self.cycle_start_time,
                            cooling_duration + repump_dur, f_repump, amp_866)
                self.end = self.cycle_start_time + cooling_duration + repump_dur
                do_optical_pumping = True
                self.cycle_start_time = self.end

            ## optical pumping
            if do_optical_pumping:
                self.addSequence(optical_pumping,
                                 TreeDict.fromdict(op_replace))
예제 #57
0
 def addSequence(self,
                 sequence,
                 replacement_dict=TreeDict(),
                 position=None):
     '''insert a subsequence, position is either time or None to insert at the end'''
     if sequence not in self.required_subsequences:
         raise Exception(
             "Adding subsequence {0} that is not listed in the required subequences"
             .format(sequence.__class__.__name__))
     if not type(replacement_dict) == TreeDict:
         raise Exception("replacement_dict must be a TreeDict")
     for replacement_key in replacement_dict.keys():
         parsed = tuple(replacement_key.split('.'))
         key_list = self.replaced_parameters.get(sequence, [])
         if not parsed in key_list:
             raise Exception(
                 "Error in {0}: replacing the key {1} in the sequence {2} that is not listed among the replacement parameters"
                 .format(self, replacement_key, sequence))
     if position is None:
         position = self.end
     #replacement conists of global replacement and keyword arguments
     replacement = TreeDict()
     replacement.update(self.replace)
     replacement.update(replacement_dict)
     seq = sequence(replacement, start=position)
     self._dds_pulses.extend(seq._dds_pulses)
     self._ttl_pulses.extend(seq._ttl_pulses)
     self.end = max(self.end, seq.end)
예제 #58
0
    def sequence(self):
        l = self.parameters.BareLineScan
        cycles = int(l.cycles_per_sequence)
        #turn off all the lights, then do doppler cooling
        self.end = WithUnit(10, 'us')
        self.addSequence(turn_off_all)
        self.addSequence(doppler_cooling)

        frequency_advance_duration = WithUnit(6, 'us')
        ampl_off = WithUnit(-63.0, 'dBm')
        self.addDDS('397', self.end, frequency_advance_duration,
                    l.frequency_397_pulse, ampl_off)
        self.addDDS('866', self.end, frequency_advance_duration,
                    l.frequency_866_pulse,
                    ampl_off)  ###changed from radial to 866 :Hong
        self.end += frequency_advance_duration
        #record timetags while switching while cycling 'wait, pulse 397, wait, pulse 866'
        start_recording_timetags = self.end
        for i in range(cycles):
            self.addSequence(
                empty_sequence,
                TreeDict.fromdict({
                    'EmptySequence.empty_sequence_duration':
                    l.between_pulses
                }))
            self.addDDS('397', self.end, l.duration_397_pulse,
                        l.frequency_397_pulse, l.amplitude_397_pulse)
            self.end += l.duration_397_pulse
            self.addSequence(
                empty_sequence,
                TreeDict.fromdict({
                    'EmptySequence.empty_sequence_duration':
                    l.between_pulses
                }))
            self.addDDS(
                '866', self.end, l.duration_866_pulse, l.frequency_866_pulse,
                l.amplitude_866_pulse)  ###changed from radial to 866 :Hong
            self.end += l.duration_866_pulse
        stop_recording_timetags = self.end
        timetag_record_duration = stop_recording_timetags - start_recording_timetags
        #record timetags while cycling takes place
        self.addTTL('TimeResolvedCount', start_recording_timetags,
                    timetag_record_duration)
        self.start_recording_timetags = start_recording_timetags
        self.timetag_record_cycle = l.between_pulses + l.duration_397_pulse + l.duration_866_pulse + l.between_pulses
예제 #59
0
    def sequence(self):
        op = self.parameters.OpticalPumping

        if op.optical_pumping_type == 'continuous':
            continuous = True
        elif op.optical_pumping_type == 'pulsed':
            continuous = False
        else:
            raise Exception('Incorrect optical pumping type {0}'.format(
                op.optical_pumping_type))
        if continuous:
            replace = {
                'OpticalPumpingContinuous.optical_pumping_continuous_frequency_854':
                op.optical_pumping_frequency_854,
                'OpticalPumpingContinuous.optical_pumping_continuous_amplitude_854':
                op.optical_pumping_amplitude_854,
                'OpticalPumpingContinuous.optical_pumping_continuous_frequency_729':
                op.optical_pumping_frequency_729,
                'OpticalPumpingContinuous.optical_pumping_continuous_amplitude_729':
                op.optical_pumping_amplitude_729,
                'OpticalPumpingContinuous.optical_pumping_continuous_frequency_866':
                op.optical_pumping_frequency_866,
                'OpticalPumpingContinuous.optical_pumping_continuous_amplitude_866':
                op.optical_pumping_amplitude_866,
            }
            self.addSequence(optical_pumping_continuous,
                             TreeDict.fromdict(replace))
        else:
            #pulsed
            replace = {
                'OpticalPumpingPulsed.optical_pumping_pulsed_frequency_854':
                op.optical_pumping_frequency_854,
                'OpticalPumpingPulsed.optical_pumping_pulsed_amplitude_854':
                op.optical_pumping_amplitude_854,
                'OpticalPumpingPulsed.optical_pumping_pulsed_frequency_729':
                op.optical_pumping_frequency_729,
                'OpticalPumpingPulsed.optical_pumping_pulsed_amplitude_729':
                op.optical_pumping_amplitude_729,
                'OpticalPumpingPulsed.optical_pumping_pulsed_frequency_866':
                op.optical_pumping_frequency_866,
                'OpticalPumpingPulsed.optical_pumping_pulsed_amplitude_866':
                op.optical_pumping_amplitude_866,
            }
            self.addSequence(optical_pumping_pulsed,
                             TreeDict.fromdict(replace))
예제 #60
0
    def run(self, cxn, context):
        dt = self.parameters.DriftTracker
        ramsey_dt = self.parameters.DriftTrackerRamsey
        if dt.line_selection_1 == dt.line_selection_2:
            raise Exception("The two Drift Tracking lines can not be the same")
        replace_1 = TreeDict.fromdict({
            'DriftTrackerRamsey.line_selection':
            dt.line_selection_1,
            'DriftTrackerRamsey.pi_time':
            ramsey_dt.line_1_pi_time,
            'DriftTrackerRamsey.amplitude':
            ramsey_dt.line_1_amplitude,
            'DriftTrackerRamsey.detuning':
            WithUnit(0, 'Hz'),
            'StateReadout.use_camera_for_readout':
            ramsey_dt.use_camera_for_readout,
        })
        replace_2 = TreeDict.fromdict({
            'DriftTrackerRamsey.line_selection':
            dt.line_selection_2,
            'DriftTrackerRamsey.pi_time':
            ramsey_dt.line_2_pi_time,
            'DriftTrackerRamsey.amplitude':
            ramsey_dt.line_2_amplitude,
            'DriftTrackerRamsey.detuning':
            WithUnit(0, 'Hz'),
            'StateReadout.use_camera_for_readout':
            ramsey_dt.use_camera_for_readout,
        })

        replace_1, replace_2 = np.random.permutation([replace_1, replace_2])
        self.ramsey_dt.set_parameters(replace_1)
        self.ramsey_dt.set_progress_limits(0, 50.0)
        frequency_1, excitation = self.ramsey_dt.run(cxn, context)
        error_sensitivity = ramsey_dt.error_sensitivity
        if not 0.5 - error_sensitivity <= excitation <= 0.5 + error_sensitivity:
            raise Exception("Incorrect Excitation {}".format(
                replace_1.DriftTrackerRamsey.line_selection))
        self.ramsey_dt.set_parameters(replace_2)
        self.ramsey_dt.set_progress_limits(50.0, 100.0)
        frequency_2, excitation = self.ramsey_dt.run(cxn, context)
        if not 0.5 - error_sensitivity <= excitation <= 0.5 + error_sensitivity:
            raise Exception("Incorrect Excitation {}".format(
                replace_2.DriftTrackerRamsey.line_selection))
        self.submit_centers(replace_1, frequency_1, replace_2, frequency_2)