Esempio n. 1
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)
Esempio n. 2
0
 def __call__(self, *args, **kwargs):
     # Use TreeDict to allow for mutable parameters / kwargs
     kw_t = TreeDict(**kwargs)
     arg_t = TreeDict(args=args)
     cache_key = (kw_t.hash(), arg_t.hash())
     try:
         return self.cache[cache_key]
     except KeyError:
         self.cache[cache_key] = value = self.func(*args, **kwargs)
         return value
Esempio n. 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'''
		#position where sequence is inserted
		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")
		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)
Esempio n. 4
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)
Esempio n. 5
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()
Esempio n. 6
0
def parse_cryosat_l1b_filename(filename):
    """
    Returns the information in the CryoSat-2 l1b filename
    """
    # Strip path and file extension
    filename = os.path.basename(filename)
    filename = os.path.splitext(filename)[0]
    # Construct the parser
    parser_str = "CS_{proc_stage}_"
    parser_str += "{instrument}_"
    parser_str += "{radar_mode}_"
    parser_str += "{data_level}_"
    parser_str += "{start_dt}_"
    parser_str += "{stop_dt}_"
    parser_str += "{baseline}"
    parser = parse.compile(parser_str)
    # Parse the filename
    result = parser.parse(filename)
    # Do some post-editing
    # - parse is not that smart when it comes to work with date strings
    # - naming conventions as the rest of pysiral
    info = TreeDict()
    info.mission = "cryosat2"
    info.instrument = result["instrument"].lower()
    info.radar_mode = result["radar_mode"].lower()
    info.data_level = "L" + result["data_level"]
    info.start_dt = dtparser.parse(result["start_dt"])
    info.stop_dt = dtparser.parse(result["stop_dt"])
    info.baseline = result["baseline"]
    return info
Esempio n. 7
0
def makeTDInstance(*args, **kwargs):
    if _inheritance_level == 0:
        return TreeDict(*args, **kwargs)
    elif _inheritance_level == 1:
        return TDLvl1(*args, **kwargs)
    elif _inheritance_level == 2:
        return TDLvl2(*args, **kwargs)
    else:
        assert False
Esempio n. 8
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 not type(replacement_dict) == TreeDict: raise Exception ("replacement_dict must be a TreeDict")
     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)
     #print 'heres the seq pulses'
     #print seq._ttl_pulses
     self._ttl_pulses.extend(seq._ttl_pulses)
     self.end = max(self.end, seq.end)
Esempio n. 9
0
 def __init__(self):
     self.type = None
     self.active = None
     self.exclude_from_rendering = None
     self.version = None
     self.desc = None
     self.HashParam = {}  #hash di tutti i param del layer
     self.treeObj = TreeDict()
     self.zMax = None
     self.filenameParamImportLayer = None
     self.node = None
	def fill_parameters(self, params, replace):
		if not len(params) == len(set(params)):
			raise Exception ("Duplicate required parameters found in {0}".format(self.__class__.__name__))
		new_dict = TreeDict()
		for collection,parameter_name in params:
			treedict_key = '{0}.{1}'.format(collection,parameter_name)
			try:
				new_dict[treedict_key] = replace[treedict_key]
			except KeyError:
				raise Exception('{0} {1} value not provided for the {2} Pulse Sequence'.format(collection, parameter_name, self.__class__.__name__))
		return new_dict
Esempio n. 11
0
 def __init__(self, parameter_dict=TreeDict(), start=WithUnit(0, 's')):
     if not type(parameter_dict) == TreeDict:
         raise Exception(
             "replacement_dict must be a TreeDict in sequence {0}".format(
                 self.__class__.__name__))
     self.start = start
     self.end = start
     self._dds_pulses = []
     self._ttl_pulses = []
     self.replace = parameter_dict
     self.parameters = self.fill_parameters(self.required_parameters,
                                            self.replace)
     self.sequence()
Esempio n. 12
0
 def _load_parameters_dict(self, params):
     '''loads the required parameter into a treedict'''
     d = TreeDict()
     for collection, parameter_name in params:
         try:
             value = self.pv.get_parameter(collection, parameter_name)
         except Exception as e:
             print e
             raise Exception(
                 "In {}: Parameter {} not found among Parameter Vault parameters"
                 .format(self.name, (collection, parameter_name)))
         else:
             d['{0}.{1}'.format(collection, parameter_name)] = value
     return d
Esempio n. 13
0
 def set_parameters(self, parameter_dict):
     '''
     can reload all parameter values from parameter_vault or replace parameters with values from the provided parameter_dict
     '''
     if isinstance(parameter_dict, dict):
         udpate_dict = TreeDict()
         for (collection,
              parameter_name), value in parameter_dict.iteritems():
             udpate_dict['{0}.{1}'.format(collection,
                                          parameter_name)] = value
     elif isinstance(parameter_dict, TreeDict):
         udpate_dict = parameter_dict
     else:
         raise Exception(
             "Incorrect input type for the replacement dictionary")
     self.parameters.update(udpate_dict)
def main():
    import labrad
    cxn = labrad.connect()
    import time
    from treedict import TreeDict
    cxn.dac_server.reset_queue()
    cxn.pulser.switch_auto('adv', True)
    cxn.pulser.switch_auto('rst', True)
    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


#        if not (collection,param) in spectrum_rabi.required_parameters:
#            print 'parameter not listed among requirments', collection, param
#    for key in d.keys():
#        a = TreeDict()
#        a.update(d)
#        a.pop(key)
#        try:
#            sequence = spectrum_rabi(a)
#        except Exception:
#            pass
#        else:
#            print 'key not needed', key
    tinit = time.time()
    cs = spectrum_rabi_ramp(d)
    cs.programSequence(cxn.pulser)
    print 'to program', time.time() - tinit
    cxn.pulser.start_number(1000)
    cxn.pulser.wait_sequence_done()
    cxn.pulser.stop_sequence()
    #dds = cxn.pulser.human_readable_dds()
    #ttl = cxn.pulser.human_readable_ttl()
    #print ttl == [['0.0', '00000000000000000000000000000000'], ['1e-05', '00000000000000000010000000000000'], ['1.008e-05', '00000000000000000000000000000000'], ['6e-05', '00000000000000000010000000000000'], ['6.008e-05', '00000000000000000000000000000000'], ['0.00026', '00000000000000000010000000000000'], ['0.00026008', '00000000000000000000000000000000'], ['0.00132', '00000000000000000010000000000000'], ['0.00132008', '00000000000000000000000000000000'], ['0.00142', '00000000000000000010000000000000'], ['0.00142008', '00000000000000000000000000000000'], ['0.00242', '00000000000000000010000000000000'], ['0.00242008', '00000000000000000000000000000000'], ['0.00262', '00000000000000000010000000000000'], ['0.00262008', '00000000000000000000000000000000'], ['0.00282', '00000000000000000010000000000000'], ['0.00282008', '00000000000000000000000000000000'], ['0.00332', '00000000000000000010000000000000'], ['0.00332008', '00000000000000000000000000000000'], ['0.00352', '00000000000000000010000000000000'], ['0.00352008', '00000000000000000000000000000000'], ['0.00372', '00000000000000000010000000000000'], ['0.00372008', '00000000000000000000000000000000'], ['0.00422', '00000000000000000010000000000000'], ['0.00422008', '00000000000000000000000000000000'], ['0.00442', '00000000000000000010000000000000'], ['0.00442008', '00000000000000000000000000000000'], ['0.00462', '00000000000000000010000000000000'], ['0.00462008', '00000000000000000000000000000000'], ['0.00512', '00000000000000000010000000000000'], ['0.00512008', '00000000000000000000000000000000'], ['0.00532', '00000000000000000010000000000000'], ['0.00532008', '00000000000000000000000000000000'], ['0.00552', '00000000000000000010000000000000'], ['0.00552008', '00000000000000000000000000000000'], ['0.00602', '00000000000000000010000000000000'], ['0.00602008', '00000000000000000000000000000000'], ['0.00622', '00000000000000000010000000000000'], ['0.00622008', '00000000000000000000000000000000'], ['0.00642', '00000000000000000010000000000000'], ['0.00642008', '00000000000000000000000000000000'], ['0.00692', '00000000000000000010000000000000'], ['0.00692008', '00000000000000000000000000000000'], ['0.00712', '00000000000000000010000000000000'], ['0.00712008', '00000000000000000000000000000000'], ['0.00732', '00000000000000000010000000000000'], ['0.00732008', '00000000000000000000000000000000'], ['0.00782', '00000000000000000010000000000000'], ['0.00782008', '00000000000000000000000000000000'], ['0.00802', '00000000000000000010000000000000'], ['0.00802008', '00000000000000000000000000000000'], ['0.00822', '00000000000000000010000000000000'], ['0.00822008', '00000000000000000000000000000000'], ['0.00872', '00000000000000000010000000000000'], ['0.00872008', '00000000000000000000000000000000'], ['0.00892', '00000000000000000010000000000000'], ['0.00892008', '00000000000000000000000000000000'], ['0.00912', '00000000000000000010000000000000'], ['0.00912008', '00000000000000000000000000000000'], ['0.00962', '00000000000000000010000000000000'], ['0.00962008', '00000000000000000000000000000000'], ['0.00982', '00000000000000000010000000000000'], ['0.00982008', '00000000000000000000000000000000'], ['0.01002', '00000000000000000010000000000000'], ['0.01002008', '00000000000000000000000000000000'], ['0.010026', '00000000000000000010000000000000'], ['0.01002608', '00000000000000000000000000000000'], ['0.010036', '00000100000000000010100000000000'], ['0.01003608', '00000100000000000000100000000000'], ['0.010136', '00000000000000000000100000000000'], ['0.013036', '00000000000000000010000000000000'], ['0.01303608', '00000000000000000000000000000000'], ['0.013136', '00000000000000000010000000000000'], ['0.01313608', '00000000000000000001000000000000'], ['0.01313616', '00000000000000000000000000000000'], ['0.0', '00000000000000000000000000000000']]
    #dds_result = [('global397', 89.99923704890517, -33.0004577706569), ('global397', 69.99923704890517, -63.0), ('global397', 89.99923704890517, -15.0), ('global397', 89.99923704890517, -15.0), ('global397', 69.99923704890517, -63.0), ('global397', 69.99923704890517, -63.0), ('global397', 69.99923704890517, -63.0), ('global397', 69.99923704890517, -63.0), ('global397', 69.99923704890517, -63.0), ('global397', 69.99923704890517, -63.0), ('global397', 69.99923704890517, -63.0), ('global397', 69.99923704890517, -63.0), ('global397', 69.99923704890517, -63.0), ('global397', 69.99923704890517, -63.0), ('global397', 69.99923704890517, -63.0), ('global397', 69.99923704890517, -63.0), ('global397', 69.99923704890517, -63.0), ('global397', 69.99923704890517, -63.0), ('global397', 69.99923704890517, -63.0), ('global397', 69.99923704890517, -63.0), ('global397', 69.99923704890517, -63.0), ('global397', 69.99923704890517, -63.0), ('global397', 69.99923704890517, -63.0), ('global397', 69.99923704890517, -63.0), ('global397', 69.99923704890517, -63.0), ('global397', 69.99923704890517, -63.0), ('global397', 69.99923704890517, -63.0), ('global397', 69.99923704890517, -63.0), ('global397', 69.99923704890517, -63.0), ('global397', 69.99923704890517, -63.0), ('global397', 69.99923704890517, -63.0), ('global397', 69.99923704890517, -63.0), ('global397', 69.99923704890517, -63.0), ('global397', 69.99923704890517, -63.0), ('global397', 89.99923704890517, -13.000457770656901), ('global397', 69.99923704890517, -63.0), ('global397', 69.99923704890517, -63.0), ('854DP', 79.99923704890517, -33.0004577706569), ('854DP', 79.99923704890517, -63.0), ('854DP', 79.99923704890517, -11.0), ('854DP', 79.99923704890517, -63.0), ('854DP', 79.99923704890517, -63.0), ('854DP', 79.99923704890517, -3.0), ('854DP', 79.99923704890517, -3.0), ('854DP', 79.99923704890517, -63.0), ('854DP', 79.99923704890517, -11.0), ('854DP', 79.99923704890517, -11.0), ('854DP', 79.99923704890517, -63.0), ('854DP', 79.99923704890517, -3.0), ('854DP', 79.99923704890517, -3.0), ('854DP', 79.99923704890517, -63.0), ('854DP', 79.99923704890517, -11.0), ('854DP', 79.99923704890517, -11.0), ('854DP', 79.99923704890517, -63.0), ('854DP', 79.99923704890517, -3.0), ('854DP', 79.99923704890517, -3.0), ('854DP', 79.99923704890517, -63.0), ('854DP', 79.99923704890517, -11.0), ('854DP', 79.99923704890517, -11.0), ('854DP', 79.99923704890517, -63.0), ('854DP', 79.99923704890517, -3.0), ('854DP', 79.99923704890517, -3.0), ('854DP', 79.99923704890517, -63.0), ('854DP', 79.99923704890517, -11.0), ('854DP', 79.99923704890517, -11.0), ('854DP', 79.99923704890517, -63.0), ('854DP', 79.99923704890517, -3.0), ('854DP', 79.99923704890517, -3.0), ('854DP', 79.99923704890517, -63.0), ('854DP', 79.99923704890517, -63.0), ('854DP', 79.99923704890517, -63.0), ('854DP', 79.99923704890517, -63.0), ('854DP', 79.99923704890517, -63.0), ('854DP', 79.99923704890517, -63.0), ('729DP_1', 149.99999984866008, -63.0), ('729DP_1', 0.0, -63.0), ('729DP_1', 0.0, -63.0), ('729DP_1', 0.0, -63.0), ('729DP_1', 0.0, -63.0), ('729DP_1', 0.0, -63.0), ('729DP_1', 0.0, -63.0), ('729DP_1', 0.0, -63.0), ('729DP_1', 0.0, -63.0), ('729DP_1', 0.0, -63.0), ('729DP_1', 0.0, -63.0), ('729DP_1', 0.0, -63.0), ('729DP_1', 0.0, -63.0), ('729DP_1', 0.0, -63.0), ('729DP_1', 0.0, -63.0), ('729DP_1', 0.0, -63.0), ('729DP_1', 0.0, -63.0), ('729DP_1', 0.0, -63.0), ('729DP_1', 0.0, -63.0), ('729DP_1', 0.0, -63.0), ('729DP_1', 0.0, -63.0), ('729DP_1', 0.0, -63.0), ('729DP_1', 0.0, -63.0), ('729DP_1', 0.0, -63.0), ('729DP_1', 0.0, -63.0), ('729DP_1', 0.0, -63.0), ('729DP_1', 0.0, -63.0), ('729DP_1', 0.0, -63.0), ('729DP_1', 0.0, -63.0), ('729DP_1', 0.0, -63.0), ('729DP_1', 0.0, -63.0), ('729DP_1', 0.0, -63.0), ('729DP_1', 0.0, -63.0), ('729DP_1', 0.0, -63.0), ('729DP_1', 0.0, -63.0), ('729DP_1', 0.0, -63.0), ('729DP_1', 0.0, -63.0), ('radial', 109.99923704890517, -63.0), ('radial', 89.99923704890517, -63.0), ('radial', 89.99923704890517, -63.0), ('radial', 89.99923704890517, -63.0), ('radial', 89.99923704890517, -63.0), ('radial', 89.99923704890517, -63.0), ('radial', 89.99923704890517, -63.0), ('radial', 89.99923704890517, -63.0), ('radial', 89.99923704890517, -63.0), ('radial', 89.99923704890517, -63.0), ('radial', 89.99923704890517, -63.0), ('radial', 89.99923704890517, -63.0), ('radial', 89.99923704890517, -63.0), ('radial', 89.99923704890517, -63.0), ('radial', 89.99923704890517, -63.0), ('radial', 89.99923704890517, -63.0), ('radial', 89.99923704890517, -63.0), ('radial', 89.99923704890517, -63.0), ('radial', 89.99923704890517, -63.0), ('radial', 89.99923704890517, -63.0), ('radial', 89.99923704890517, -63.0), ('radial', 89.99923704890517, -63.0), ('radial', 89.99923704890517, -63.0), ('radial', 89.99923704890517, -63.0), ('radial', 89.99923704890517, -63.0), ('radial', 89.99923704890517, -63.0), ('radial', 89.99923704890517, -63.0), ('radial', 89.99923704890517, -63.0), ('radial', 89.99923704890517, -63.0), ('radial', 89.99923704890517, -63.0), ('radial', 89.99923704890517, -63.0), ('radial', 89.99923704890517, -63.0), ('radial', 89.99923704890517, -63.0), ('radial', 89.99923704890517, -63.0), ('radial', 89.99923704890517, -63.0), ('radial', 89.99923704890517, -63.0), ('radial', 89.99923704890517, -63.0), ('729DP', 219.99999997671694, -33.0004577706569), ('729DP', 0.0, -63.0), ('729DP', 0.0, -63.0), ('729DP', 0.0, -63.0), ('729DP', 0.0, -63.0), ('729DP', 219.99999997671694, -10.000228885328454), ('729DP', 219.99999997671694, -63.0), ('729DP', 219.99999997671694, -63.0), ('729DP', 224.99999986612238, -11.0), ('729DP', 224.99999986612238, -63.0), ('729DP', 224.99999986612238, -63.0), ('729DP', 219.99999997671694, -10.000228885328454), ('729DP', 219.99999997671694, -63.0), ('729DP', 219.99999997671694, -63.0), ('729DP', 224.99999986612238, -11.0), ('729DP', 224.99999986612238, -63.0), ('729DP', 224.99999986612238, -63.0), ('729DP', 219.99999997671694, -10.000228885328454), ('729DP', 219.99999997671694, -63.0), ('729DP', 219.99999997671694, -63.0), ('729DP', 224.99999986612238, -11.0), ('729DP', 224.99999986612238, -63.0), ('729DP', 224.99999986612238, -63.0), ('729DP', 219.99999997671694, -10.000228885328454), ('729DP', 219.99999997671694, -63.0), ('729DP', 219.99999997671694, -63.0), ('729DP', 224.99999986612238, -11.0), ('729DP', 224.99999986612238, -63.0), ('729DP', 224.99999986612238, -63.0), ('729DP', 219.99999997671694, -10.000228885328454), ('729DP', 219.99999997671694, -63.0), ('729DP', 219.99999997671694, -63.0), ('729DP', 214.99999990104698, -63.0), ('729DP', 214.99999990104698, -3.0), ('729DP', 214.99999990104698, -63.0), ('729DP', 214.99999990104698, -63.0), ('729DP', 214.99999990104698, -63.0), ('866DP', 79.99923704890517, -33.0004577706569), ('866DP', 79.99923704890517, -63.0), ('866DP', 79.99923704890517, -11.0), ('866DP', 79.99923704890517, -11.0), ('866DP', 79.99923704890517, -11.0), ('866DP', 79.99923704890517, -11.0), ('866DP', 79.99923704890517, -11.0), ('866DP', 79.99923704890517, -11.0), ('866DP', 79.99923704890517, -11.0), ('866DP', 79.99923704890517, -11.0), ('866DP', 79.99923704890517, -11.0), ('866DP', 79.99923704890517, -11.0), ('866DP', 79.99923704890517, -11.0), ('866DP', 79.99923704890517, -11.0), ('866DP', 79.99923704890517, -11.0), ('866DP', 79.99923704890517, -11.0), ('866DP', 79.99923704890517, -11.0), ('866DP', 79.99923704890517, -11.0), ('866DP', 79.99923704890517, -11.0), ('866DP', 79.99923704890517, -11.0), ('866DP', 79.99923704890517, -11.0), ('866DP', 79.99923704890517, -11.0), ('866DP', 79.99923704890517, -11.0), ('866DP', 79.99923704890517, -11.0), ('866DP', 79.99923704890517, -11.0), ('866DP', 79.99923704890517, -11.0), ('866DP', 79.99923704890517, -11.0), ('866DP', 79.99923704890517, -11.0), ('866DP', 79.99923704890517, -11.0), ('866DP', 79.99923704890517, -11.0), ('866DP', 79.99923704890517, -11.0), ('866DP', 79.99923704890517, -11.0), ('866DP', 79.99923704890517, -63.0), ('866DP', 79.99923704890517, -63.0), ('866DP', 79.99923704890517, -11.0), ('866DP', 79.99923704890517, -11.0), ('866DP', 79.99923704890517, -63.0)]
    #print dds == dds_result
    #     for a,b in zip(dds_result, dds):
    #         if not a == b:
    #             print a,b
    cxn.pulser.switch_auto('adv', False)
    cxn.pulser.switch_auto('rst', False)
    cxn.pulser.switch_manual('adv', True)
    cxn.pulser.switch_manual('adv', False)
Esempio n. 15
0
 def __init__(self, module, sc, cxn):
     self.module = module # pulse sequence module
     self.name = module.__name__
     # copy the parameter vault dict by value
     self.parameters_dict = TreeDict()
     self.show_params = module.show_params
     self.scan = None
     self.sc = sc # reference to scriptscanner class, not through the labrad connection
     self.cxn = cxn
     try:
         self.dt = self.cxn.sd_tracker
     except:
         self.dt = None
     try:
         self.grapher = cxn.grapher
     except:
         self.grapher = None
     self.total_readouts = []
Esempio n. 16
0
def main():
    import labrad
    cxn = labrad.connect()
    import time
    from treedict import TreeDict

    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
#        if not (collection,param) in spectrum_rabi.required_parameters:
#            print 'parameter not listed among requirments', collection, param
#    for key in d.keys():
#        a = TreeDict()
#        a.update(d)
#        a.pop(key)
#        try:
#            sequence = spectrum_rabi(a)
#        except Exception:
#            pass
#        else:
#            print 'key not needed', key
    tinit = time.time()
    #    cs = fast_change_dacs(d)
    #    cs.programSequence(cxn.pulser)
    adv = advanceDACs(d)
    adv.programSequence(cxn.pulser)
    print 'to program', time.time() - tinit
    cxn.pulser.start_number(1)
    cxn.pulser.wait_sequence_done()
    cxn.pulser.stop_sequence()

    adv = resetDACs(d)
    adv.programSequence(cxn.pulser)
    print 'to program', time.time() - tinit
    cxn.pulser.start_number(1)
    cxn.pulser.wait_sequence_done()
    cxn.pulser.stop_sequence()
Esempio n. 17
0
        self.addDDS('DDS_0', WithUnit(0.1, 'ms'), WithUnit(250, 'ms'),
                    WithUnit(40.0, 'MHz'), WithUnit(-23.0, 'dBm'))
        self.addDDS('DDS_0', WithUnit(500, 'ms'), WithUnit(250, 'ms'),
                    WithUnit(40.1, 'MHz'), WithUnit(-23.0, 'dBm'))
        #        self.addDDS('DDS_1', WithUnit(1000, 'ms'), WithUnit(100, 'ms'), WithUnit(88.0, 'MHz'), WithUnit(-40.0, 'dBm'))
        #        self.addDDS('DDS_1', WithUnit(2000, 'ms'), WithUnit(2000, 'ms'), WithUnit(87.0, 'MHz'), WithUnit(-40.0, 'dBm'))

        self.addTTL('ttl_0', WithUnit(0, 'ms'), WithUnit(100, 'ms'))
        self.addTTL('ttl_0', WithUnit(200, 'ms'), WithUnit(100, 'ms'))
        self.addTTL('ttl_0', WithUnit(400, 'ms'), WithUnit(100, 'ms'))


if __name__ == '__main__':
    import labrad
    cxn = labrad.connect()
    cs = sampleDDS(TreeDict())
    cs.programSequence(cxn.pulser)

    dds = cxn.pulser.human_readable_dds()
    ttl = cxn.pulser.human_readable_ttl()
    channels = cxn.pulser.get_channels().asarray
    ##print ttl.asarray
    ##print dds.aslist
    sp = SequencePlotter(ttl.asarray, dds.aslist, channels)
    #sp.makePlot()

    cxn.pulser.start_number(10)
    cxn.pulser.wait_sequence_done()
    cxn.pulser.stop_sequence()

    #print 'DONE'
Esempio n. 18
0
import os
from treedict import TreeDict

filedir = os.path.join(os.path.dirname(__file__))

paths = TreeDict()
#paths.abccare = os.path.join(os.environ['klmshare'], 'Data_Central', 'Abecedarian', 'data', 'ABC-CARE', 'extensions', 'cba-iv', 'append-abccare_iv.dta')
paths.abccare = os.path.join(filedir, '..', '..', '..', 'data', 'abccare',
                             'extensions', 'cba-iv',
                             'append-abccare_iv.dta')  # for testing
paths.maintables = os.path.join(filedir, '..', '..', '..', 'output')
paths.apptables = os.path.join(filedir, '..', '..', '..', 'AppOutput',
                               'Program')
paths.rslt = os.path.join(filedir, 'rslt')
paths.outcomes = os.path.join(filedir, 'outcomes.csv')
paths.samples = os.path.join(filedir, '..', '..', 'misc', 'sampling',
                             'care_samples_1000.csv')
Lower order functions sould rely entirely on data passed to them as configuration attributes."""

import numpy as np
import scipy.io as io
import datetime
from treedict import TreeDict

# International System of Units
qe = 1.60217646e-19
me = 9.10938188e-31
mp = 1.67262158e-27

# Universal Parameters
save = 1
useDate = 0  # determine if simulation files are saved with our without date in name
debug = TreeDict()
debug.import_data = 0
debug.get_trap = 0
debug.expand_field = 0
debug.trap_knobs = 0
debug.post_process_trap = 0
debug.pfit = 0
debug.soef = 0
debug.trap_depth = 0
eurotrap = 0
rfplot = 'no plots'  # dimensions to plot RF with plotpot
dcplot = 'no plots'  # dimensions to plot DC with plotpot

#################################################################################
################################ import_data ####################################
#################################################################################
Esempio n. 20
0
        self.addAnalog(1, self.start + WithUnit(2, 'ms'), MOT_intensity)
        self.addAnalog(1, self.end - WithUnit(2, 'ms'), MOT_intensity)

        ## MOT coil
        self.addAnalog(5, self.start + WithUnit(2, 'ms'), 0.0)
        self.addAnalog(5, self.end - time_before_detect, 0.0)
        self.addAnalog(5, self.end - time_before_detect + WithUnit(2, 'ms'),
                       p.MOT_loading.MOT_current_compress)

        ### Lattice
        self.addAnalog(6, self.start + WithUnit(2, 'ms'), -1.0)
        self.addAnalog(6, self.start + WithUnit(12, 'ms'), -1.0)
        self.addAnalog(6, self.start + WithUnit(15, 'ms'), -1.3)
        self.addAnalog(6, self.end - WithUnit(3, 'ms'), -1.3)

        ### clock
        self.addAnalog(7, self.start + WithUnit(2, 'ms'), 10.0)
        self.addAnalog(7, self.end - WithUnit(2, 'ms'), 10.0)


if __name__ == '__main__':
    print "hey world"
    import labrad
    cxn = labrad.connect()
    ni = cxn.ni_analog_server
    M = MOT_spectroscopy_analog(TreeDict())
    #M.sequence()
    #M.convert_sequence()
    M.programAnalog(ni)
        self.addAnalog(7, WithUnit(0.0,'ms'), 10.0) ### clock
        
        
        ### MOT frequency
        
        compress = p.MOT_loading.MOT_compress_freq
        far_red = p.MOT_loading.MOT_far_red_freq
        
        self.addAnalog(0, WithUnit(0.0,'ms'), compress)
        self.addAnalog(0, WithUnit(3.0,'ms'), compress)
        self.addAnalog(0, WithUnit(4.0,'ms'), far_red)
        self.addAnalog(0, p.MOT_loading.loading_time-WithUnit(60.0,'ms'), far_red)
        self.addAnalog(0, p.MOT_loading.loading_time-WithUnit(60.0,'ms')+WithUnit(3.0,'ms'), compress)
        self.addAnalog(0, p.MOT_loading.loading_time-WithUnit(0.1,'ms'), compress)
        
        self.end = p.MOT_loading.loading_time
        
        self.addSequence(MOT_spectroscopy_analog)
        self.addSequence(MOT_detection_analog)
        

if __name__ == '__main__':
    print "hey world"
    import labrad
    cxn = labrad.connect()
    ni = cxn.ni_analog_server
    M = MOT_clock_analog(TreeDict())
    #M.sequence()
    M.convert_sequence()
    #M.programAnalog(ni)
Esempio n. 22
0
    #make sure all node servers are up
    pulser_on = True
    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)
                except:
                    print 'ERROR with ' + server
                    if server == 'Pulser':
                        pulser_on = False

#initialize DAC into correct set number after random startup flashes from advance trigger from the pulser
if pulser_on:
    parameters = TreeDict()
    pulser = cxn.pulser
    pulse_sequence = reset_DACs(parameters)
    pulse_sequence.programSequence(pulser)
    pulser.start_number(1)
    pulser.wait_sequence_done()
    pulser.stop_sequence()

time.sleep(10)
Esempio n. 23
0
        WithUnit(-16.0, 'dBm'),
        ('LifetimeP', 'duration_866_pulse'):
        WithUnit(10, 'us'),
        ('LifetimeP', 'amplitude_866_pulse'):
        WithUnit(-12.0, 'dBm'),
        ('LifetimeP', 'frequency_866_pulse'):
        WithUnit(110, 'MHz'),
    }


if __name__ == '__main__':
    import labrad
    cxn = labrad.connect()
    from treedict import TreeDict
    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
#        if not (collection,param) in branching_ratio.required_parameters:
#            print 'parameter not listed among requirments', collection, param
#    for key in d.keys():
#        a = TreeDict()
#        a.update(d)
#        a.pop(key)
#        try:
#            sequence = branching_ratio(a)
#        except Exception:
#            pass
#        else:
#            print 'key not needed', key
Esempio n. 24
0
# For the makeReport example
from treedict import TreeDict

t = TreeDict("mytree")
t.x = 1
t.y = 2
t.a.z = [1, 2, 3]
t.a.y = {1: 2}
t.b.x = "hello"
t.a.x = None
t.b.z = 2

print t.makeReport()
print t.a.makeReport()
print t.a.makeReport(add_path=True)
print t.a.makeReport(add_path=True, add_tree_name=False)

# For set()
from treedict import TreeDict
t = TreeDict()
t.set("x", 1)
t.set(z=3)
t.set("ya", 2, "yb", 2, yc=3)
t.set("a.b.c.v", 1)
print t.makeReport()

# for set

from treedict import TreeDict
t = TreeDict()
t.set("x", 1)
Esempio n. 25
0
 def __init__(self, name=None, required_parameters=None):
     if name is not None:
         self.name = name
     if required_parameters is not None:
         self.required_parameters = required_parameters
     self.parameters = TreeDict()
Esempio n. 26
0
import os
import sys
from pandas.io.pytables import read_hdf
from treedict import TreeDict

sys.path.extend([os.path.join(os.path.dirname(__file__), '..')])
from paths import paths

extrap = TreeDict()

psid = read_hdf(os.path.join(paths.data, 'data.h5'), 'psid-transfer')
cnlsy = read_hdf(os.path.join(paths.data, 'data.h5'), 'cnlsy-transfer')
nlsy = read_hdf(os.path.join(paths.data, 'data.h5'), 'nlsy-transfer')
interp = read_hdf(os.path.join(paths.data, 'data.h5'), 'interp-transfer')
extrap = read_hdf(os.path.join(paths.data, 'data.h5'), 'extrap-transfer')
abcd = read_hdf(os.path.join(paths.data, 'data.h5'), 'abc-mini')
Esempio n. 27
0
def test_cube():
    """Build a data struction, like the output by get_trap, to test the following functions.
    Consider a set of electrodes which produce a potential field in a cube, 10x10x10 for speed.
    Each field is built up by a linear combination of functions defined by the terms weighted by Ex,Ey,Ez,U1,U2,U3,U4,U5.
    For now, there are no constant terms and the weighting of each is binary (0 or 1).
    We will have 14 electrodes total: 3 from the 3 E's, 10 from (5 choose 2) of the U's, and one for the RF (U1 only).
    The grid for each axis varies z from -5 to 5 and the test ion is at the center.
    We will also choose trap configuration variables as appropriate and save the data in the same manner."""

    import numpy as np
    import datetime
    from treedict import TreeDict
    savePath = 'C:\\Python27\\trap_simulation_software\\data\\'  # directory to save data at
    name = 'manual_test'  # name to save trapping field as
    save = True
    nue = 22
    n = 11
    Ex, Ey, Ez = 1, 1, 1
    U1, U2, U3, U4, U5 = 1, 1, 1, 1, 1  # x**2-y**2,2*z**2-x**2-y**2,x*y,z*y,x*z (matlab/experiment)
    trap = TreeDict()
    p = trap.potentials
    p.X, p.Y, p.Z = np.arange(-5, 6), np.arange(-5, 6), np.arange(
        -5, 6)  # construct grid vectors

    I, J, K = np.arange(-5, 6), np.arange(-5, 6), np.arange(
        -5, 6)  # construct background for functions
    [i, j, k] = np.meshgrid(I, J, K)
    # apply small perturbation to make saddle only pick out zeroes instead of any x=y
    #i,j,k = i-3.3*np.ones((n,n,n)),j-0.01*np.ones((n,n,n)),k-0.01*np.ones((n,n,n))
    u1, u2, u3, u4, u5 = i**2 - j**2, 2 * k**2 - i**2 - j**2, i * j, k * j, i * k

    # Change to python/math mapping from ion trap mapping
    U1, U2, U3, U4, U5 = U3, U4, U2, U5, U1
    u1, u2, u3, u4, u5 = u3, u4, u2, u5, u1

    # Weird mapping?
    #     Ex,Ey,Ez = Ey,Ez,Ex
    #     i,j,k = j,k,i

    p.EL_DC_1 = Ex * i
    p.EL_DC_2 = Ey * j
    p.EL_DC_3 = Ez * k
    p.EL_DC_4 = U1 * u1 + U2 * u2
    p.EL_DC_5 = U1 * u1 + U3 * u3
    p.EL_DC_6 = U1 * u1 + U4 * u4
    p.EL_DC_7 = U1 * u1 + U5 * u5
    p.EL_DC_8 = U2 * u2 + U3 * u3
    p.EL_DC_9 = U2 * u2 + U4 * u4
    p.EL_DC_10 = U2 * u2 + U5 * u5
    p.EL_DC_11 = U3 * u3 + U4 * u4
    p.EL_DC_12 = U3 * u3 + U5 * u5
    p.EL_DC_13 = U4 * u4 + U5 * u5
    p.EL_DC_14 = np.zeros((n, n, n))  #+u1
    p.EL_DC_15 = np.zeros((n, n, n))  #+u2
    p.EL_DC_16 = np.zeros((n, n, n))  #+u3
    p.EL_DC_17 = np.zeros((n, n, n))  #+u4
    p.EL_DC_18 = np.zeros((n, n, n))  #+u5
    p.EL_DC_19 = np.zeros((n, n, n))  #+u5/2
    p.EL_DC_20 = np.zeros((n, n, n))  #+u5/3
    p.EL_DC_21 = np.zeros((n, n, n))  #+u5/4
    p.EL_DC_22 = u3
    p.EL_RF = p.EL_DC_22

    p.mEL_DC_22 = u3

    c = trap.configuration
    c.rfBias = False
    c.charge = 1.60217646e-19
    c.mass = 1.67262158e-27
    c.numUsedElectrodes = nue
    c.electrodeMapping = np.array([[1, 1], [2, 2], [3, 3], [4, 4], [5, 5],
                                   [6, 6], [7, 7], [8, 8], [9, 9], [10, 10],
                                   [11, 11], [12, 12], [13, 13], [14, 14],
                                   [15, 15], [16, 16], [17, 17], [18, 18],
                                   [19, 19], [20, 20], [21, 21], [22, 22]])
    c.manualElectrodes = np.zeros(nue)
    #c.manualElectrodes[nue-1] = 999
    c.usedMultipoles = [1, 1, 1, 1, 1, 1, 1, 1]
    c.position = 0
    c.dataPointsPerAxis = np.shape(p.Z)
    c.date = datetime.datetime.now().date()

    trap.potentials = p
    trap.configuration = c

    if save:
        import pickle
        name = savePath + name + '.pkl'
        print('Saving ' + name + ' as a data structure...')
        output = open(name, 'wb')
        pickle.dump(trap, output)
        output.close()

    from all_functions import plot_potential, find_saddle, exact_saddle, set_dc, dc_potential, spher_harm_exp
    from project_parameters import dcVoltages, manualElectrodes, weightElectrodes
    #print plot_potential(p.EL_DC_22,p.X,p.Y,p.Z,'1D plots','title','ylab',[0,0,0])

    return
Esempio n. 28
0
def main():

    # oxygen toxicity sudden convulsions and unconsciousness
    state = {
        'location': {
            'current': 'wake up'
        },
        'suit': {
            'pressure': 'normal',
            'co2 absorbers': 'expended',
            'mode': 'blood letting',
            'nitrogen': 'empty',
            'oxygen': 15,
            'oxygen content': 80,
            'status': 'breach'
        },
        'breach kit': {}
    }

    #http://www.readanybook.com/online/565265
    location = {
        'wake up': {
            'description': [
                'You awake to the oxygen alarm in your suit. A steady, obnoxious beeping that '
                'eventually rouses you from a deep and profound desire to just f*****g die.',
                'You are facedown, almost totally buried in sand. As you groggily came to, you '
                'wonder why you aren\'t more dead.'
            ],
            'questions': {
                'where':
                'You have been knocked back quite a ways and rolled down a steep hill.',
                'what':
                'Your main communications dish, which relayed signals from the Hab to '
                'Hermes, acted like a parachute, getting torn from its foundation and carried '
                'with the torrent. Along the way, it crashed through the reception antenna '
                'array. Then one of those long thin antennae slammed into you end-first. It '
                'tore through your suit like a bullet through butter, and you felt the worst '
                'pain of your life as it ripped open your side.',
                'last':
                'You vaguely remember having '
                'the wind knocked out of you (pulled out of you, really) and your ears popping '
                'painfully as the pressure of your suit escaped.'
            }
        },
        'look around': [
            'The antenna had enough force to punch through the suit and my side, but it had been stopped by my pelvis. So there was only one hole in the suit (and a hole in me, of course).',
            'I had been knocked back quite a ways and rolled down a steep hill. Somehow I landed facedown, which forced the antenna to a strongly oblique angle that put a lot of torque on the hole in the suit. It made a weak seal.'
        ],
        'check hole': [
            'Then, the copious blood from my wound trickled down toward the hole. As the blood reached the site of the breach, the water in it quickly evaporated from the airflow and low pressure, leaving a gunky residue behind. More blood came in behind it and was also reduced to gunk. Eventually, it sealed the gaps around the hole and reduced the leak to something the suit could counteract.'
        ],
        'check suit': [
            'The suit did its job admirably. Sensing the drop in pressure, it constantly flooded itself with air from my nitrogen tank to equalize. Once the leak became manageable, it only had to trickle new air in slowly to relieve the air lost.',
            'After a while, the CO2 (carbon dioxide) absorbers in the suit were expended. That\'s really the limiting factor to life support. Not the amount of oxygen you bring with you, but the amount of CO2 you can remove. In the Hab, I have the oxygenator, a large piece of equipment that breaks apart CO2 to give the oxygen back. But the space suits have to be portable, so they use a simple chemical absorption process with expendable filters. I\'d been asleep long enough that my filters were useless.',
            'The suit saw this problem and moved into an emergency mode the engineers call \'bloodletting.\' Having no way to separate out the CO2, the suit deliberately vented air to the Martian atmosphere, then backfilled with nitrogen. Between the breach and the bloodletting, it quickly ran out of nitrogen. All it had left was my oxygen tank.'
            'So it did the only thing it could to keep me alive. It started backfilling with pure oxygen. I now risked dying from oxygen toxicity, as the excessively high amount of oxygen threatened to burn up my nervous system, lungs, and eyes. An ironic death for someone with a leaky space suit: too much oxygen.',
            'Every step of the way would have had beeping alarms, alerts, and warnings. But it was the high-oxygen warning that woke me.',
            'The sheer volume of training for a space mission is astounding. I\'d spent a week back on Earth practicing emergency space suit drills. I knew what to do.',
            'Carefully reaching to the side of my helmet, I got the breach kit. It\'s nothing more than a funnel with a valve at the small end and an unbelievably sticky resin on the wide end. The idea is you have the valve open and stick the wide end over a hole. The air can escape through the valve, so it doesn\'t interfere with the resin making a good seal. Then you close the valve, and you\'ve sealed the breach.',
            'The tricky part was getting the antenna out of the way. I pulled it out as fast as I could, wincing as the sudden pressure drop dizzied me and made the wound in my side scream in agony.',
            'I got the breach kit over the hole and sealed it. It held. The suit backfilled the missing air with yet more oxygen. Checking my arm readouts, I saw the suit was now at 85 percent oxygen. For reference, Earth\'s atmosphere is about 21 percent. I\'d be okay, so long as I didn\'t spend too much time like that.',
            'I stumbled up the hill back toward the Hab. As I crested the rise, I saw something that made me very happy and something that made me very sad: The Hab was intact (yay!) and the MAV was gone (boo!).'
        ]
    }

    while True:

        output_location(TreeDict(location), TreeDict(state))

        cmd = input(':')

        question_asked(TreeDict(location), TreeDict(state), cmd)
Esempio n. 29
0
        ('Excitation_729', 'rabi_excitation_amplitude'):
        WithUnit(-3.0, 'dBm'),
        ('Excitation_729', 'rabi_excitation_phase'):
        WithUnit(0, 'deg'),
        ('Excitation_729', 'rabi_excitation_duration'):
        WithUnit(50, 'us'),
    }


if __name__ == '__main__':
    import labrad
    cxn = labrad.connect()
    import time
    from treedict import TreeDict
    params = test_parameters.parameters
    d = TreeDict()
    for (collection, param), value in test_parameters.parameters.iteritems():
        d['{0}.{1}'.format(collection, param)] = value
#        if not (collection,param) in ramsey_dephase.required_parameters:
#            print 'parameter not listed among requirments', collection, param
    for key in d.keys():
        a = TreeDict()
        a.update(d)
        a.pop(key)
        try:
            sequence = spectrum_rabi(a)
#            sequence = ramsey_dephase(a)
        except Exception:
            pass
        else:
            print 'key not needed', key
Esempio n. 30
0
# -*- coding: utf-8 -*-
"""
Created on Fri Jun 10 19:22:00 2016

@author: jkcshea

This file just lists all the variables that are used for interpolation,
extrapolation, and the weights.
"""

from treedict import TreeDict

cols = TreeDict()

# Interpolation ---------------------------------------------------------------

cols.interp.black = ['black']
cols.interp.background = ['male', 'm_ed0y']
cols.interp.outcomes = ['piatmath']
cols.interp.weight = ['wtabc_allids']
cols.interp.predictors = cols.interp.outcomes + cols.interp.background  #
cols.interp.keep = cols.interp.predictors + cols.interp.black
# cols.interp.outcomes = ['si21y_inc_labor', 'years_30y', 'piatmath']
# Extrapolation --------------------------------------------------------------

cols.extrap.black = ['black']
cols.extrap.background = ['male']
cols.extrap.outcomes = ['si30y_inc_labor']
cols.extrap.weight = ['wtabc_allids']
cols.extrap.predictors = cols.extrap.outcomes + cols.extrap.background  #
cols.extrap.keep = cols.extrap.predictors + cols.extrap.black