def __init__(self, name, exec_qtlab_name, **kw):
        Instrument.__init__(self, name)
        self._exec_qtlab_name = exec_qtlab_name
        ins_pars  = {'measurement_name'     :   {'type':types.StringType,'val':'','flags':Instrument.FLAG_GETSET},
                    'is_running'            :   {'type':types.BooleanType,'val':False,'flags':Instrument.FLAG_GETSET},
                    'data_path'             :   {'type':types.StringType,'val':'','flags':Instrument.FLAG_GETSET},
                    'script_path'           :   {'type':types.StringType,'val':'','flags':Instrument.FLAG_GETSET},
                    'live_plot_interval'    :   {'type':types.FloatType, 'val':2,'flags':Instrument.FLAG_GETSET},
                    'do_live_plotting'      :   {'type':types.BooleanType, 'val':False,'flags':Instrument.FLAG_GETSET},
                    'completed_reps'        :   {'type':types.IntType, 'val':0,'flags':Instrument.FLAG_GETSET}
                    }
        instrument_helper.create_get_set(self,ins_pars)
        
        self.add_function('execute_script')
        self.add_function('get_measurement_params')
        self.add_function('set_measurement_params')

        self.add_function('start_adwin_live_plotting')
        self.add_function('get_adwin_data')
        self.add_function('plot_adwin_data')
        self.add_function('stop_adwin_live_plotting')

        self._measurement_params = {}

        # override from config       
        cfg_fn = os.path.join(qt.config['ins_cfg_path'], name+'.cfg')

        if not os.path.exists(cfg_fn):
            _f = open(cfg_fn, 'w')
            _f.write('')
            _f.close()

        self._ins_cfg = config.Config(cfg_fn)     
        self.load_cfg()
        self.save_cfg()
    def __init__(self, name, positioner, adwin, red_laser=None):
        Instrument.__init__(self, name)

        self.add_function('optimize')
        self.add_function('run')
        self.add_function('fit')
        self.add_function('first_time_run')
        self.add_function('routine') 
        
        self.rotator = positioner
        self.red = red_laser
        self.adwin = adwin

        ins_pars  = {'half_channel'           : {'type':types.IntType,'flags':Instrument.FLAG_GETSET, 'val':2},
                    'half_stepsize'           : {'type':types.IntType,'flags':Instrument.FLAG_GETSET, 'val':400},
                    'half_noof_points'        : {'type':types.IntType,'flags':Instrument.FLAG_GETSET, 'val':11},
                    'quarter_channel'         : {'type':types.IntType,'flags':Instrument.FLAG_GETSET, 'val':1},
                    'quarter_stepsize'        : {'type':types.IntType,'flags':Instrument.FLAG_GETSET, 'val':400},
                    'quarter_noof_points'     : {'type':types.IntType,'flags':Instrument.FLAG_GETSET, 'val':11},
                    'first_time_channel'      : {'type':types.IntType,'flags':Instrument.FLAG_GETSET, 'val':0},
                    'first_time_stepsize'     : {'type':types.IntType,'flags':Instrument.FLAG_GETSET, 'val':4250},
                    'first_time_noof_points'  : {'type':types.IntType,'flags':Instrument.FLAG_GETSET, 'val':11},
                    'first_opt_red_power'     : {'type':types.FloatType,'flags':Instrument.FLAG_GETSET, 'val':1e-9},
                    'opt_threshold'           : {'type':types.FloatType,'flags':Instrument.FLAG_GETSET, 'val':5E5},
                    'zpl_counter'             : {'type':types.IntType,'flags':Instrument.FLAG_GETSET, 'val':2},
                    'plot_degrees'            : {'type':types.BooleanType,'flags':Instrument.FLAG_GETSET, 'val':True},
                    }
        instrument_helper.create_get_set(self,ins_pars)

        self.check_noof_steps = 10000    #ask before changing this number of steps
        self.opt_red_power = 1E-9 #NOTE!!        self.first_opt_red_power = 1E-9

        self.add_parameter('opt_red_power',
                flags=Instrument.FLAG_GETSET,
                minval = 0, maxval = 100E-9,
                units = 'W', type=types.FloatType)


        self.add_parameter('opt_scan_range',
                flags=Instrument.FLAG_GETSET,
                type=types.TupleType,
                units = 'deg')

        self.add_parameter('conversion_factor',
                type=types.FloatType,
                flags=Instrument.FLAG_GET)
        
        cfg_fn = os.path.join(qt.config['ins_cfg_path'], name+'.cfg')

        if not os.path.exists(cfg_fn):
            _f = open(cfg_fn, 'w')
            _f.write('')
            _f.close()

        self._ins_cfg = config.Config(cfg_fn)     
        self.load_cfg()
        self.save_cfg()
Example #3
0
    def __init__(self,
                 name,
                 get_freq_yellow=None,
                 get_freq_gate=None,
                 get_freq_newfocus=None):
        Instrument.__init__(self, name)

        self._get_freq_yellow = get_freq_yellow
        self._get_freq_gate = get_freq_gate
        self._get_freq_newfocus = get_freq_newfocus

        ins_pars = {
            'delta_t': {
                'type': types.FloatType,
                'val': 1.0,
                'flags': Instrument.FLAG_GETSET
            },
            'log_gate': {
                'type': types.BooleanType,
                'val': True,
                'flags': Instrument.FLAG_GETSET
            },
            'log_yellow': {
                'type': types.BooleanType,
                'val': True,
                'flags': Instrument.FLAG_GETSET
            },
            'log_newfocus': {
                'type': types.BooleanType,
                'val': True,
                'flags': Instrument.FLAG_GETSET
            },
            'is_running': {
                'type': types.BooleanType,
                'val': False,
                'flags': Instrument.FLAG_GETSET
            }
        }

        instrument_helper.create_get_set(self, ins_pars)

        self.add_function('start')
        self.add_function('stop')

        # override from config
        cfg_fn = os.path.join(qt.config['ins_cfg_path'], name + '.cfg')
        if not os.path.exists(cfg_fn):
            _f = open(cfg_fn, 'w')
            _f.write('')
            _f.close()

        self.ins_cfg = config.Config(cfg_fn)
        self.load_cfg()
        self.save_cfg()
    def __init__(self, name):
        Instrument.__init__(self, name)

        self.add_function('step_up')
        self.add_function('step_down')
        self.add_function('set_zero')

        ins_pars = {
            'channel': {
                'type': types.StringType,
                'flags': Instrument.FLAG_GETSET,
                'val': ''
            },
            'min_value': {
                'type': types.FloatType,
                'flags': Instrument.FLAG_GETSET,
                'val': 0
            },
            'max_value': {
                'type': types.FloatType,
                'flags': Instrument.FLAG_GETSET,
                'val': 2
            },
            'step_size': {
                'type': types.FloatType,
                'flags': Instrument.FLAG_GETSET,
                'val': 0
            },
        }
        instrument_helper.create_get_set(self, ins_pars)

        self.add_parameter('current_value',
                           type=types.FloatType,
                           flags=Instrument.FLAG_GETSET)

        self._parlist = ins_pars.keys()

        self._adwin = qt.instruments['adwin']

        # override from config
        cfg_fn = os.path.join(qt.config['ins_cfg_path'], name + '.cfg')
        if not os.path.exists(cfg_fn):
            _f = open(cfg_fn, 'w')
            _f.write('')
            _f.close()

        self.ins_cfg = config.Config(cfg_fn)
        self.load_cfg()
        self.save_cfg()

        self._do_get_current_value()
    def __init__(self, name, mos_ins=qt.instruments['master_of_space'],
            adwin_ins=qt.instruments['adwin']):
        Instrument.__init__(self, name)

        self.add_function('optimize')
        self.mos = mos_ins
        self.adwin= adwin_ins

        ins_pars  = {'a'  :   {'type':types.FloatType,'val':1.5,'flags':Instrument.FLAG_GETSET},
                     'b'  :   {'type':types.FloatType,'val':1.3,'flags':Instrument.FLAG_GETSET},
                     'c'  :   {'type':types.FloatType,'val':0.5,'flags':Instrument.FLAG_GETSET},
                     'd'  :   {'type':types.FloatType,'val':0.9,'flags':Instrument.FLAG_GETSET},
                     }
        instrument_helper.create_get_set(self,ins_pars)
    def __init__(self, name, rotator, rotation_config_name='',
                waveplates=['zpl_half','zpl_quarter'],
                get_value_f=None, get_norm_f=None, get_count_f=None, get_msmt_running_f = None):
        Instrument.__init__(self, name)


        self._rotator = qt.instruments[rotator]
        
        self._waveplates=waveplates
        self._rotation_cfg=rotcfg.config[rotation_config_name]
        self._prev_wp_channel='none'

        self._get_value_f = get_value_f
        self._get_norm_f = get_norm_f
        self._get_count_f = get_count_f
        self._get_msmt_running_f = get_msmt_running_f
        self._is_running = False
        self._timer = -1

        self._half_direction = 1
        self._quarter_direction = 1
        self._reject_cycles = 0

        ins_pars  = {
                    'integration_time_during_msmt'   : {'type':types.FloatType,'flags':Instrument.FLAG_GETSET, 'val':10, 'units': 's'},
                    'integration_time'        : {'type':types.FloatType,'flags':Instrument.FLAG_GETSET, 'val':0.3, 'units': 's'},
                    'good_rejection'          : {'type':types.FloatType,'flags':Instrument.FLAG_GETSET, 'val':3},
                    'step_size'               : {'type':types.FloatType,'flags':Instrument.FLAG_GETSET, 'val':2}
                    }
        instrument_helper.create_get_set(self,ins_pars)

        self.add_function('move')
        self.add_function('get_waveplates')
        self.add_function('start')
        self.add_function('stop')
        self.add_function('get_value')
        self.add_function('get_noof_reject_cycles')

        cfg_fn = os.path.join(qt.config['ins_cfg_path'], name+'.cfg')

        if not os.path.exists(cfg_fn):
            _f = open(cfg_fn, 'w')
            _f.write('')
            _f.close()

        self._ins_cfg = config.Config(cfg_fn)     
        self.load_cfg()
        self.save_cfg()
Example #7
0
    def __init__(self, name, rotator, adwin, red_laser=None, rotation_config_name='',
                waveplates=['zpl_half','zpl_quarter']):
        Instrument.__init__(self, name)


        self._rotator = qt.instruments[rotator]
        if red_laser != None:
            self._red_laser = qt.instruments[red_laser]
        else:
            self._red_laser = None
        self._adwin = qt.instruments[adwin]
        self._waveplates=waveplates
        self._rotation_cfg=rotcfg.config[rotation_config_name]
        self._prev_wp_channel='none'

        self.add_function('optimize')
        self.add_function('jog_optimize')
        self.add_function('optimize_all')
        self.add_function('first_time_run')
        self.add_function('move')
        self.add_function('get_waveplates')
        self.add_function('reset_wp_channel')
        self.add_function('nd_optimize')

        ins_pars  = {'opt_range'              : {'type':types.FloatType,'flags':Instrument.FLAG_GETSET, 'val':4, 'units': 'deg'},
                    'opt_noof_points'         : {'type':types.IntType,'flags':Instrument.FLAG_GETSET,   'val':11},
                    'opt_red_power'           : {'type':types.FloatType,'flags':Instrument.FLAG_GETSET, 'val':10e-9}, 
                    'first_time_range'        : {'type':types.FloatType,'flags':Instrument.FLAG_GETSET, 'val':45,  'units': 'deg'},
                    'first_time_noof_points'  : {'type':types.IntType,'flags':Instrument.FLAG_GETSET,   'val':11},
                    'first_time_red_power'    : {'type':types.FloatType,'flags':Instrument.FLAG_GETSET, 'val':1e-9, 'units': 'W'},
                    'cnt_threshold'           : {'type':types.FloatType,'flags':Instrument.FLAG_GETSET, 'val':5E5},
                    'zpl_counter'             : {'type':types.IntType,'flags':Instrument.FLAG_GETSET,   'val':2},
                    }
        instrument_helper.create_get_set(self,ins_pars)

        self._powell_direc=None

        cfg_fn = os.path.join(qt.config['ins_cfg_path'], name+'.cfg')

        if not os.path.exists(cfg_fn):
            _f = open(cfg_fn, 'w')
            _f.write('')
            _f.close()

        self._ins_cfg = config.Config(cfg_fn)     
        self.load_cfg()
        self.save_cfg()
    def __init__(self, name, rotator, adwin, red_laser=None, rotation_config_name='waveplates_lt3',
                waveplates=['zpl_half','zpl_quarter']):
        Instrument.__init__(self, name)


        self._rotator = qt.instruments[rotator]
        if red_laser != None:
            self._red_laser = qt.instruments[red_laser]
        else:
            self._red_laser = None
        self._adwin = qt.instruments[adwin]
        self._waveplates=waveplates
        self._rotation_cfg=rotcfg.config[rotation_config_name]
        self._prev_wp_channel='none'

        self.add_function('optimize')
        self.add_function('jog_optimize')
        self.add_function('optimize_all')
        self.add_function('first_time_run')
        self.add_function('move')
        self.add_function('get_waveplates')
        self.add_function('reset_wp_channel')


        ins_pars  = {'opt_range'              : {'type':types.FloatType,'flags':Instrument.FLAG_GETSET, 'val':4, 'units': 'deg'},
                    'opt_noof_points'         : {'type':types.IntType,'flags':Instrument.FLAG_GETSET,   'val':11},
                    'opt_red_power'           : {'type':types.FloatType,'flags':Instrument.FLAG_GETSET, 'val':10e-9}, 
                    'first_time_range'        : {'type':types.FloatType,'flags':Instrument.FLAG_GETSET, 'val':45,  'units': 'deg'},
                    'first_time_noof_points'  : {'type':types.IntType,'flags':Instrument.FLAG_GETSET,   'val':11},
                    'first_time_red_power'    : {'type':types.FloatType,'flags':Instrument.FLAG_GETSET, 'val':1e-9, 'units': 'W'},
                    'cnt_threshold'           : {'type':types.FloatType,'flags':Instrument.FLAG_GETSET, 'val':5E5},
                    'zpl_counter'             : {'type':types.IntType,'flags':Instrument.FLAG_GETSET,   'val':2},
                    }
        instrument_helper.create_get_set(self,ins_pars)

        cfg_fn = os.path.join(qt.config['ins_cfg_path'], name+'.cfg')

        if not os.path.exists(cfg_fn):
            _f = open(cfg_fn, 'w')
            _f.write('')
            _f.close()

        self._ins_cfg = config.Config(cfg_fn)     
        self.load_cfg()
        self.save_cfg()
    def __init__(self, name, set_half_control_f=None, set_quarter_control_f=None, get_value_f=None, get_norm_f=None,msmt_helper = 'lt3_measurement_helper' , plot_name=''):
        Instrument.__init__(self, name)        
        if plot_name=='': 
            self._plot_name='optimizer_'+name            
        else:
            self._plot_name =  plot_name

        self._set_half_control_f = set_half_control_f
        self._set_quarter_control_f = set_quarter_control_f
        self._set_control_f = set_quarter_control_f 
        self._get_value_f = get_value_f
        self._get_norm_f=get_norm_f
        self._msmt_helper = msmt_helper
        self._half_direction = 1
        self._quarter_direction = 1
        self._quarter_first = True
        ins_pars  ={'scan_min'          :   {'type':types.FloatType,  'val':0.0,'flags':Instrument.FLAG_GETSET},
                    'scan_max'          :   {'type':types.FloatType,  'val':0.0,'flags':Instrument.FLAG_GETSET},
                    'control_step_size' :   {'type':types.FloatType,  'val':0.0,'flags':Instrument.FLAG_GETSET},
                    'min_value'         :   {'type':types.FloatType,  'val':0.,'flags':Instrument.FLAG_GETSET},
                    'min_norm'          :   {'type':types.FloatType,  'val':200.,'flags':Instrument.FLAG_GETSET},
                    'dwell_time'        :   {'type':types.FloatType,  'val':0.1,'flags':Instrument.FLAG_GETSET}, #s
                    'do_plot'           :   {'type':types.BooleanType,'val':True,'flags':Instrument.FLAG_GETSET},
                    'dwell_after_set'   :   {'type':types.BooleanType,'val':True,'flags':Instrument.FLAG_GETSET},
                    }
        
        instrument_helper.create_get_set(self,ins_pars)
                    
        self.add_function('scan')
        self.add_function('optimize')
        self.add_function('get_value')
        self.add_function('go_one_step')
        self.add_function('optimize_rejection')

    # override from config       
        cfg_fn = os.path.join(qt.config['ins_cfg_path'], name+'.cfg')
        if not os.path.exists(cfg_fn):
            _f = open(cfg_fn, 'w')
            _f.write('')
            _f.close()
        
        self.ins_cfg = config.Config(cfg_fn)
        self.load_cfg()
        self.save_cfg()
        print 'creating waveplate optimizer'
Example #10
0
 def __init__(self, name, **kw):
     Instrument.__init__(self, name)
     
    
     ins_pars  = {'read_interval'    :   {'type':types.FloatType,'flags':Instrument.FLAG_GETSET},
                 'is_running'       :   {'type':types.BooleanType,'flags':Instrument.FLAG_GETSET},
                 }           
     instrument_helper.create_get_set(self,ins_pars)
     
     self.add_function('start')        
     self.add_function('stop')
     self.add_function('manual_check')
     
     self._optimizers=[]
     
     self.set_is_running(False)
     self.set_read_interval(60) #s
     self._is_waiting=False
     self._timer=-1
 def __init__(self, name, **kw):
     Instrument.__init__(self, name)
     
    
     ins_pars  = {'read_interval'    :   {'type':types.FloatType,'flags':Instrument.FLAG_GETSET},
                 'is_running'       :   {'type':types.BooleanType,'flags':Instrument.FLAG_GETSET},
                 }           
     instrument_helper.create_get_set(self,ins_pars)
     
     self.add_function('start')        
     self.add_function('stop')
     self.add_function('add_optimizer')
     self.add_function('get_optimizers')
     self.add_function('manual_optimize')
     
     self._optimizers=[]
     
     self.set_is_running(False)
     self.set_read_interval(60) #s
     self._is_waiting=False
     self._timer=-1
 def __init__(self, name, get_control_f=None, set_control_f=None, get_value_f=None, get_norm_f=None, plot_name=''):
     Instrument.__init__(self, name)        
     if plot_name=='': 
         plot_name='optimizer_'+name            
            
     self._get_control_f=get_control_f
     self._set_control_f=set_control_f
     self._get_value_f=get_value_f
     self._get_norm_f=get_norm_f
     
     ins_pars  = {'max_control'      :   {'type':types.FloatType,'val':0.0,'flags':Instrument.FLAG_GETSET},
                 'min_control'       :   {'type':types.FloatType,'val':0.0,'flags':Instrument.FLAG_GETSET},
                 'scan_range'        :   {'type':types.FloatType,'val':0.0,'flags':Instrument.FLAG_GETSET},
                 'control_step_size' :   {'type':types.FloatType,'val':0.0,'flags':Instrument.FLAG_GETSET},
                 'min_value'         :   {'type':types.IntType, 'val':2,'flags':Instrument.FLAG_GETSET},
                 'dwell_time'        :   {'type':types.FloatType,'val':0.1,'flags':Instrument.FLAG_GETSET}, #s
                 'wait_time'         :   {'type':types.FloatType,'val':10,'flags':Instrument.FLAG_GETSET}, #s
                 'order_index'       :   {'type':types.IntType,  'val':1,'flags':Instrument.FLAG_GETSET},
                 'do_plot'           :   {'type':types.BooleanType,'val':True,'flags':Instrument.FLAG_GETSET},
                 'plot_name'         :   {'type':types.StringType,'val':plot_name,'flags':Instrument.FLAG_GETSET},
                 'variance'          :   {'type':types.FloatType,'val':0.,'flags':Instrument.FLAG_GETSET},
                 'last_max'          :   {'type':types.FloatType,'val':0.,'flags':Instrument.FLAG_GETSET},
                 }
     
     instrument_helper.create_get_set(self,ins_pars)
                 
     self.add_function('scan')
     self.add_function('optimize')
     self.add_function('get_value')
     
 # override from config       
     cfg_fn = os.path.join(qt.config['ins_cfg_path'], name+'.cfg')
     if not os.path.exists(cfg_fn):
         _f = open(cfg_fn, 'w')
         _f.write('')
         _f.close()
     
     self.ins_cfg = config.Config(cfg_fn)
     self.load_cfg()
     self.save_cfg()
Example #13
0
    def __init__(self, name, address, reset=False):
        Instrument.__init__(self, name)

        self._address = address
        self._ser = serial.Serial(address, 19200, timeout=2)
        ins_pars = {
            'current_card_address': {
                'type': types.IntType,
                'val': 0,
                'flags': Instrument.FLAG_GETSET
            },
        }
        instrument_helper.create_get_set(self, ins_pars)

        self.add_function('Initialize')
        self.add_function('Get_Relay_State')
        self.add_function('Get_Status')
        self.add_function('Set_Relay_State')
        self.add_function('Turn_On_Relay')
        self.add_function('Turn_Off_Relay')
        self.add_function('Toggle_Relay')

        self.Initialize()
Example #14
0
    def __init__(self, name, set_eprime_func,get_eprime_func,get_E_func,get_Y_func,set_strain_splitting_func, **kw):
        Instrument.__init__(self, name)
       
        ins_pars  = {'read_interval'   :   {'type':types.FloatType,'flags':Instrument.FLAG_GETSET,'unit':'s', 'val': 1.},
                    'is_running'       :   {'type':types.BooleanType,'flags':Instrument.FLAG_GETSET, 'val': False},
                    'E_y'              :   {'type':types.BooleanType,'flags':Instrument.FLAG_GETSET, 'val': True},
                    'offset'           :   {'type':types.FloatType,  'flags':Instrument.FLAG_GETSET, 'unit':'GHz', 'val': 0.},
                    'precision'        :   {'type':types.FloatType,  'flags':Instrument.FLAG_GETSET, 'unit':'GHz', 'val': 0.05},
                    'yellow_z_factor'  :   {'type':types.FloatType,  'flags':Instrument.FLAG_GETSET, 'unit':'GHz', 'val': 4.2},
                    'yellow_x_factor'  :   {'type':types.FloatType,  'flags':Instrument.FLAG_GETSET, 'unit':'GHz', 'val': 0.2},
                    'strain_splitting' :   {'type':types.FloatType,  'flags':Instrument.FLAG_GET, 'unit':'GHz', 'val': 0.},
                    }           
        instrument_helper.create_get_set(self,ins_pars)
        
        self.add_function('start')        
        self.add_function('stop')
        
        self._get_E_func=get_E_func
        self._get_Y_func=get_Y_func
        self._set_eprime_func = set_eprime_func
        self._get_eprime_func = get_eprime_func
        self._set_strain_splitting_func = set_strain_splitting_func

        self._timer=-1

    # override from config    ----------   
        cfg_fn = os.path.abspath(
                os.path.join(qt.config['ins_cfg_path'], name+'.cfg'))
        if not os.path.exists(cfg_fn):
            _f = open(cfg_fn, 'w')
            _f.write('')
            _f.close()
        self._parlist = ['read_interval', 'E_y', 'offset','yellow_z_factor', 'yellow_x_factor','precision']
        self.ins_cfg = config.Config(cfg_fn)
        self.load_cfg()
        self.save_cfg()
Example #15
0
    def __init__(self, name, setup_name='lt4'):
        mo.multiple_optimizer.__init__(self, name)
        
        ins_pars  ={'min_cr_counts'              :   {'type':types.FloatType,'flags':Instrument.FLAG_GETSET, 'val':10},
                    'min_repump_counts'          :   {'type':types.FloatType,'flags':Instrument.FLAG_GETSET},
                    'max_counter_optimize'       :   {'type':types.IntType,'flags':Instrument.FLAG_GETSET, 'val':2},
                    'rejecter_step'              :   {'type':types.FloatType,'flags':Instrument.FLAG_GETSET}, 
                    'email_recipient'            :   {'type':types.StringType,'flags':Instrument.FLAG_GETSET}, 
                    'max_pulse_counts'           :   {'type':types.FloatType,'flags':Instrument.FLAG_GETSET, 'val':3},
                    'max_SP_ref'                 :   {'type':types.FloatType,'flags':Instrument.FLAG_GETSET, 'val':6},
                    'max_laser_reject_cycles'    :   {'type':types.IntType,'flags':Instrument.FLAG_GETSET, 'val':3},
                    'nb_min_between_nf_optim'    :   {'type':types.FloatType,'flags':Instrument.FLAG_GETSET, 'val':2},
                    'max_strain_splitting'      :   {'type':types.FloatType,'flags':Instrument.FLAG_GETSET, 'val':2.1},
                    }           
        instrument_helper.create_get_set(self,ins_pars)

        self._parlist = ins_pars.keys()
        self._parlist.append('read_interval')

        self.add_parameter('pidgate_running',
                           type=types.BooleanType,
                           flags=Instrument.FLAG_GETSET)
        self.add_parameter('pid_e_primer_running',
                           type=types.BooleanType,
                           flags=Instrument.FLAG_GETSET)
        self.add_parameter('pidyellowfrq_running',
                           type=types.BooleanType,
                           flags=Instrument.FLAG_GETSET)
        self.add_parameter('invalid_data_marker',
                          type=types.IntType,
                          flags=Instrument.FLAG_GETSET)
        
        self.add_function('optimize_nf')     
        self.add_function('optimize_gate')
        self.add_function('optimize_yellow') 
        self.add_function('rejecter_half_plus')
        self.add_function('rejecter_half_min')
        self.add_function('optimize_rejection')
        self.add_function('rejecter_quarter_plus')
        self.add_function('rejecter_quarter_min')
        #self.add_function('optimize_half')
        #self.add_function('optimize_quarter')

        #self._mode = 'check_starts'
        #self._mode_rep = 0

        self.setup_name = setup_name
        if 'lt3' in setup_name:
            requests.packages.urllib3.disable_warnings() #XXXXXXXXXXX FIX by updating packages in Canopy package manager?
        self.par_counts_old          = np.zeros(10,dtype= np.int32)
        self.par_laser_old           = np.zeros(5,dtype= np.int32)
        
        self.init_counters()  


    # override from config       
        cfg_fn = os.path.join(qt.config['ins_cfg_path'], name+'.cfg')
        if not os.path.exists(cfg_fn):
            _f = open(cfg_fn, 'w')
            _f.write('')
            _f.close()
        
        self.ins_cfg = config.Config(cfg_fn)
        self.load_cfg()
        self.save_cfg()
Example #16
0
    def __init__(self, name, setup_name='lt4'):
        mo.multiple_optimizer.__init__(self, name)

        ins_pars = {
            'min_cr_counts': {
                'type': types.FloatType,
                'flags': Instrument.FLAG_GETSET,
                'val': 10
            },
            'min_repump_counts': {
                'type': types.FloatType,
                'flags': Instrument.FLAG_GETSET
            },
            'max_counter_optimize': {
                'type': types.IntType,
                'flags': Instrument.FLAG_GETSET,
                'val': 2
            },
            'rejecter_step': {
                'type': types.FloatType,
                'flags': Instrument.FLAG_GETSET
            },
            'email_recipient': {
                'type': types.StringType,
                'flags': Instrument.FLAG_GETSET
            },
            'max_pulse_counts': {
                'type': types.FloatType,
                'flags': Instrument.FLAG_GETSET,
                'val': 3
            },
            'max_SP_ref': {
                'type': types.FloatType,
                'flags': Instrument.FLAG_GETSET,
                'val': 6
            },
            'min_tail_counts': {
                'type': types.FloatType,
                'flags': Instrument.FLAG_GETSET,
                'val': 3.5
            },
            'max_strain_splitting': {
                'type': types.FloatType,
                'flags': Instrument.FLAG_GETSET,
                'val': 2.1
            },
            'max_cr_counts_avg': {
                'type': types.FloatType,
                'flags': Instrument.FLAG_GETSET,
                'val': 36
            },
        }
        instrument_helper.create_get_set(self, ins_pars)

        self._parlist = ins_pars.keys()

        self._parlist.append('read_interval')

        self.add_parameter('pidgate_running',
                           type=types.BooleanType,
                           flags=Instrument.FLAG_GETSET)
        self.add_parameter('pid_e_primer_running',
                           type=types.BooleanType,
                           flags=Instrument.FLAG_GETSET)
        self.add_parameter('pidyellowfrq_running',
                           type=types.BooleanType,
                           flags=Instrument.FLAG_GETSET)
        self.add_parameter('invalid_data_marker',
                           type=types.IntType,
                           flags=Instrument.FLAG_GETSET)

        self.add_function('optimize_nf')
        self.add_function('optimize_gate')
        self.add_function('optimize_yellow')
        self.add_function('rejecter_half_plus')
        self.add_function('rejecter_half_min')
        self.add_function('zoptimize_rejection')
        self.add_function('rejecter_quarter_plus')
        self.add_function('rejecter_quarter_min')
        self.add_function('check_laser_lock')

        self.setup_name = setup_name
        if 'lt3' in setup_name:
            requests.packages.urllib3.disable_warnings(
            )  #XXXXXXXXXXX FIX by updating packages in Canopy package manager?
            self._pharp = qt.instruments['PH_300']

        self._taper_index = 4 if 'lt3' in setup_name else 3

        self.max_cryo_half_rot_degrees = 3
        self.max_laser_reject_cycles = 25
        self.nb_min_between_nf_optim = 7

        self.history_length = 10
        self.avg_length = 9
        self.deque_par_counts = deque([], self.history_length)
        self.deque_par_laser = deque([], self.history_length)
        self.deque_t = deque([], self.history_length)
        self.deque_fpar_laser = deque([], self.history_length)

        self.init_counters()

        # override from config
        cfg_fn = os.path.join(qt.config['ins_cfg_path'], name + '.cfg')
        if not os.path.exists(cfg_fn):
            _f = open(cfg_fn, 'w')
            _f.write('')
            _f.close()

        self.ins_cfg = config.Config(cfg_fn)
        self.load_cfg()
        self.save_cfg()
Example #17
0
    def __init__(self,
                 name,
                 set_ctrl_func=None,
                 get_val_func=None,
                 get_val_func_fine=None,
                 set_ctrl_func_coarse=None,
                 get_ctrl_func_coarse=None,
                 get_ctrl_func=None,
                 get_stabilizor_func=None,
                 **kw):

        Instrument.__init__(self, name)

        self._set_ctrl = set_ctrl_func
        self._get_val = get_val_func
        self._get_val_fine = get_val_func_fine
        self._get_ctrl = get_ctrl_func  #neccecary for the Matisse pid
        self._get_stabilizor = get_stabilizor_func  #neccecary for the HeNe true wavelength stabilisation
        self._set_ctrl_coarse = set_ctrl_func_coarse

        if not (self._get_stabilizor == None):
            self._stabilizor_value = self._get_stabilizor()

        self.add_parameter('control_parameter',
                           type=types.FloatType,
                           minval=kw.get('ctrl_minval', -10.),
                           maxval=kw.get('ctrl_maxval', +10.),
                           flags=Instrument.FLAG_GETSET)

        self.add_parameter('control_parameter_coarse',
                           type=types.FloatType,
                           minval=kw.get('ctrl_minval_coarse', -10.),
                           maxval=kw.get('ctrl_maxval_coarse', +10.),
                           flags=Instrument.FLAG_GETSET)

        self.add_parameter('value',
                           type=types.FloatType,
                           flags=Instrument.FLAG_GET)

        self.add_parameter('setpoint',
                           type=types.FloatType,
                           flags=Instrument.FLAG_GETSET)

        ins_pars = {
            'is_running': {
                'type': types.BooleanType,
                'val': False,
                'flags': Instrument.FLAG_GETSET
            },
            'use_stabilizor': {
                'type': types.BooleanType,
                'val': False,
                'flags': Instrument.FLAG_GETSET
            },
            'max_value': {
                'type': types.FloatType,
                'val': 100.0,
                'flags': Instrument.FLAG_GETSET
            },
            'min_value': {
                'type': types.FloatType,
                'val': 0.0,
                'flags': Instrument.FLAG_GETSET
            },
            'P': {
                'type': types.FloatType,
                'val': 0.,
                'flags': Instrument.FLAG_GETSET
            },
            'I': {
                'type': types.FloatType,
                'val': 0.,
                'flags': Instrument.FLAG_GETSET
            },  #s
            'D': {
                'type': types.FloatType,
                'val': 0.,
                'flags': Instrument.FLAG_GETSET
            },  #s
            'read_interval': {
                'type': types.FloatType,
                'val': 0.2,
                'units': 's',
                'flags': Instrument.FLAG_GETSET
            },
            'write_interval': {
                'type': types.IntType,
                'val': 1,
                'maxval': 100,
                'minval': 1,
                'flags': Instrument.FLAG_GETSET
            },
            'value_offset': {
                'type': types.FloatType,
                'val': 470.4,
                'flags': Instrument.FLAG_GETSET
            },
            'value_factor': {
                'type': types.FloatType,
                'val': 1e3,
                'flags': Instrument.FLAG_GETSET
            },
            'step_size': {
                'type': types.FloatType,
                'val': 0.01,
                'flags': Instrument.FLAG_GETSET
            },
            'floating_avg_pts': {
                'type': types.IntType,
                'val': 1.,
                'maxval': 100,
                'minval': 1,
                'flags': Instrument.FLAG_GETSET
            },
            'max_control_deviation': {
                'type': types.FloatType,
                'val': 1.0,
                'flags': Instrument.FLAG_GETSET
            },
            'min_value_deviation': {
                'type': types.FloatType,
                'val': 0.0,
                'flags': Instrument.FLAG_GETSET
            },
            'fine_value_threshold': {
                'type': types.FloatType,
                'val': 0.0,
                'flags': Instrument.FLAG_GETSET
            },
            'control_coarse_step': {
                'type': types.FloatType,
                'val': 0.05,
                'flags': Instrument.FLAG_GETSET
            },
            'do_plot': {
                'type': types.BooleanType,
                'val': True,
                'flags': Instrument.FLAG_GETSET
            },
            'do_save_data': {
                'type': types.BooleanType,
                'val': False,
                'flags': Instrument.FLAG_GETSET
            },
        }
        instrument_helper.create_get_set(self, ins_pars)
        self.add_function('start')
        self.add_function('stop')
        self.add_function('step_up')
        self.add_function('step_down')

        self.set_setpoint(0)

        self._control_parameter = 0
        self._control_parameter_coarse = 0

        # override from config
        cfg_fn = os.path.abspath(
            os.path.join(qt.config['ins_cfg_path'], name + '.cfg'))
        if not os.path.exists(cfg_fn):
            _f = open(cfg_fn, 'w')
            _f.write('')
            _f.close()

        self._parlist = [
            'P', 'I', 'D', 'setpoint', 'value_factor', 'value_offset',
            'max_value', 'min_value', 'max_control_deviation',
            'use_stabilizor', 'step_size', 'control_coarse_step', 'do_plot',
            'min_value_deviation', 'fine_value_threshold'
        ]
        self.ins_cfg = config.Config(cfg_fn)
        self.load_cfg()
        self.save_cfg()
Example #18
0
    def __init__(self, name, SAMPLE_SIL='MyTestSample'):
        Instrument.__init__(self, name)
        self.name = name
        self._SAMPLE_SIL = SAMPLE_SIL
        self._carbon_number = name[-1]

        ####
        #init necessary parameters

        ins_pars = {
            'freq_1_m1': {
                'type': types.FloatType,
                'flags': Instrument.FLAG_GETSET,
                'val': 10,
                'units': 'Hz'
            },
            'freq_m1': {
                'type': types.FloatType,
                'flags': Instrument.FLAG_GETSET,
                'val': 10,
                'units': 'Hz'
            },
            'freq_1_p1': {
                'type': types.FloatType,
                'flags': Instrument.FLAG_GETSET,
                'val': 10,
                'units': 'Hz'
            },
            'freq_p1': {
                'type': types.FloatType,
                'flags': Instrument.FLAG_GETSET,
                'val': 10,
                'units': 'Hz'
            },
            'freq_0': {
                'type': types.FloatType,
                'flags': Instrument.FLAG_GETSET,
                'val': 10,
                'units': 'Hz'
            },
            'Ren_tau_m1': {
                'type': types.ListType,
                'flags': Instrument.FLAG_GETSET,
                'val': [0]
            },
            'Ren_N_m1': {
                'type': types.ListType,
                'flags': Instrument.FLAG_GETSET,
                'val': [0]
            },
            'Ren_tau_p1': {
                'type': types.ListType,
                'flags': Instrument.FLAG_GETSET,
                'val': [0]
            },
            'Ren_N_p1': {
                'type': types.ListType,
                'flags': Instrument.FLAG_GETSET,
                'val': [0]
            },
            'Ren_comp_phase_m1': {
                'type': types.ListType,
                'flags': Instrument.FLAG_GETSET,
                'val': [0]
            },  #output to msmt params is an np.array
            'Ren_comp_phase_p1': {
                'type': types.ListType,
                'flags': Instrument.FLAG_GETSET,
                'val': [0]
            },  #output to msmt params is an np.array
            'Ren_flip_electron_for_comp_gate_list_m1': {
                'type': types.ListType,
                'flags': Instrument.FLAG_GETSET,
                'val': [False]
            },
            'Ren_flip_electron_for_comp_gate_list_p1': {
                'type': types.ListType,
                'flags': Instrument.FLAG_GETSET,
                'val': [False]
            },
            'Ren_extra_phase_correction_list_m1': {
                'type': types.ListType,
                'flags': Instrument.FLAG_GETSET,
                'val': [0] * 10
            },  #output to msmt params is an np.array
            'Ren_extra_phase_correction_list_p1': {
                'type': types.ListType,
                'flags': Instrument.FLAG_GETSET,
                'val': [0] * 10
            }  #output to msmt params is an np.array
        }
        instrument_helper.create_get_set(self, ins_pars)

        self.add_function('write_attributes_to_msmt_params')
        self.add_function('get_optimize_gate_sweep')
        self.add_function('get_frequencies')
        self.add_function('get_sample_name')
        # self.add_fucntion('get_carbon_number')

        cfg_fn = os.path.join(
            qt.config['ins_cfg_path'] + '\\' + self._SAMPLE_SIL, name + '.cfg')
        cfg_dir = os.path.dirname(cfg_fn)

        ### does the sample folder exist?
        if not os.path.exists(cfg_dir):
            os.makedirs(cfg_dir)
        # print cfg_fn

        ### does the carbon exist?
        if not os.path.exists(cfg_fn):
            _f = open(cfg_fn, 'w')
            _f.write('')
            _f.close()

        self._ins_cfg = config.Config(cfg_fn)
        self.load_cfg()
        self.save_cfg()
Example #19
0
    def __init__(self,name,mos,coarse_mos,remote_plug,**kw):
        logging.info(__name__ + ' : Initializing instrument Diamond scanner')
        Instrument.__init__(self, name)

        ### useful instruments
        self._adwin = qt.instruments['physical_adwin']
        self._mos = qt.instruments[mos]
        self._coarse_mos = qt.instruments[coarse_mos] 
        self._rem_plug = qt.instruments[remote_plug]
        self._aom = qt.instruments['GreenAOM']
        self._optimiz0r = qt.instruments['optimiz0r']
        self._scan2d = qt.instruments['scan2d']
        self._setup_controller = qt.instruments['setup_controller']

        ######## parameters
        ins_pars = { ### positioning
                    'x_pos'  :   {'type':types.Inttype,'flags':Instrument.FLAG_GETSET, 'val':10},
                    'y_pos'  :   {'type':types.Inttype,'flags':Instrument.FLAG_GETSET, 'val':10},
                    'last_x_pos'  :   {'type':types.Inttype,'flags':Instrument.FLAG_GETSET, 'val':10}, ### used to check gross image misinterpretation
                    'last_y_pos'  :   {'type':types.Inttype,'flags':Instrument.FLAG_GETSET, 'val':10}, ### used to check gross image misinterpretation
                    'sample_tilt_x': {'type':types.Floattype,'flags':Instrument.FLAG_GETSET, 'val':0.1}, ### in nm per um
                    'sample_til_y' : {'type':types.Floattype,'flags':Instrument.FLAG_GETSET, 'val':0.1}, ### in nm per um

                    'logged_distance_x' : {'type':types.Floattype,'flags':Instrument.FLAG_GETSET, 'val':10},
                    'logged_distance_y' : {'type':types.Floattype,'flags':Instrument.FLAG_GETSET, 'val':10},

                    ### anything ebeam pattern related
                    'bitm_pitch' :  {'type':types.Inttype,'flags':Instrument.FLAG_GETSET, 'val':60},
                    'small_marker_pitch' :  {'type':types.Inttype,'flags':Instrument.FLAG_GETSET, 'val':5},
                    'bitm_x_max' :  {'type':types.Inttype,'flags':Instrument.FLAG_GETSET, 'val':5},
                    'bitm_y_max' :  {'type':types.Inttype,'flags':Instrument.FLAG_GETSET, 'val':5},
                    'stripline_positions': {'type':types.Listtype,'flags':Instrument.FLAG_GETSET, 'val':[5,20]},
                    'stripline_width': {'type':types.Inttype,'flags':Instrument.FLAG_GETSET, 'val':30},

                    ### image analysis:
                    'cam_path'  :   {'type':types.Stringtype,'flags':Instrument.FLAG_GETSET, 'val':''},
                    'cam_diameter_field_of_view' : {'type':types.Inttype,'flags':Instrument.FLAG_GETSET, 'val':30},
                    'cam_resolution' : {'type':types.Floattype,'flags':Instrument.FLAG_GETSET, 'val':0.2},
                    'sample_rotation'  :   {'type':types.Floattype,'flags':Instrument.FLAG_GETSET, 'val':10},
                    'l_spot_on_cam_x' :   {'type':types.Floattype,'flags':Instrument.FLAG_GETSET, 'val':10},
                    'l_spot_on_cam_y' :   {'type':types.Floattype,'flags':Instrument.FLAG_GETSET, 'val':10},


        }

        instrument_helper.create_get_set(self,ins_pars)

        ### camera related 
        self.add_function('cam_where_am_i')
        self.add_function('cam_find_surface')
        self.add_function('cam_take_image')
        self.add_function('cam_load_latest_image')

        ### mos related
        self.add_fucntion('mos_go_to_bitmarker')
        self.add_function('mos_reset_fine_XY')

        ### data management 
        self.add_function('create_ebeam_pattern')
        self.add_function('update_ebeam_pattern')

        ### scanning + NV related
        self.add_function('generate_scanning_plan')
        self.add_function('execute_scanning_plan')
        self.add_function('save_NV_position_to_msmt_folder')
        self.add_function('find_nvs')

        self._ebeam_pattern = np.zeros((5,5)) ### dummy pattern

        ### priv variables
        self._last_where_am_i_succeeded = False
        self._scan_resolution = 10 ### 10 px per um
        self._scan_aom_power = 400e-6
Example #20
0
    def __init__(self, name, setup_name='lt4'):
        mo.multiple_optimizer.__init__(self, name)
        
        ins_pars  ={'min_cr_counts'              :   {'type':types.FloatType,'flags':Instrument.FLAG_GETSET, 'val':10},
                    'min_repump_counts'          :   {'type':types.FloatType,'flags':Instrument.FLAG_GETSET},
                    'max_counter_optimize'       :   {'type':types.IntType,'flags':Instrument.FLAG_GETSET, 'val':2},
                    'rejecter_step'              :   {'type':types.FloatType,'flags':Instrument.FLAG_GETSET}, 
                    'email_recipient'            :   {'type':types.StringType,'flags':Instrument.FLAG_GETSET, 'val':''}, 
                    'max_pulse_counts'           :   {'type':types.FloatType,'flags':Instrument.FLAG_GETSET, 'val':3},
                    'max_SP_ref'                 :   {'type':types.FloatType,'flags':Instrument.FLAG_GETSET, 'val':6},
                    'min_tail_counts'            :   {'type':types.FloatType,'flags':Instrument.FLAG_GETSET, 'val':3.5},
                    'max_strain_splitting'       :   {'type':types.FloatType,'flags':Instrument.FLAG_GETSET, 'val':2.1},
                    'max_cr_counts_avg'          :   {'type':types.FloatType,'flags':Instrument.FLAG_GETSET, 'val':36},
                    'babysitting'                :   {'type':types.BooleanType,'flags':Instrument.FLAG_GETSET, 'val':False},
                    'stop_optimize'              :   {'type':types.BooleanType,'flags':Instrument.FLAG_GETSET, 'val':False},
                    }           
        instrument_helper.create_get_set(self,ins_pars)

        self._parlist = ins_pars.keys()
        
        self._parlist.append('read_interval')

        self.add_parameter('pidgate_running',
                           type=types.BooleanType,
                           flags=Instrument.FLAG_GETSET)
        self.add_parameter('pid_e_primer_running',
                           type=types.BooleanType,
                           flags=Instrument.FLAG_GETSET)
        self.add_parameter('pidyellowfrq_running',
                           type=types.BooleanType,
                           flags=Instrument.FLAG_GETSET)
        self.add_parameter('invalid_data_marker',
                          type=types.IntType,
                          flags=Instrument.FLAG_GETSET)
        
        self.add_function('optimize_nf')     
        self.add_function('optimize_gate')
        self.add_function('optimize_yellow') 

        self.add_function('toggle_pid_gate')
        self.add_function('toggle_pid_nf')
        self.add_function('toggle_pid_yellowfrq')
        self.add_function('auto_optimize')
        self.add_function('start_babysit')
        self.add_function('stop_babysit')  
        self.add_function('stop_optimize_now')         
        self.add_function('rejecter_half_plus')
        self.add_function('rejecter_half_min')
        self.add_function('rejecter_quarter_plus')
        self.add_function('rejecter_quarter_min')

        
        self.setup_name = setup_name

        self._busy = False;

        self._taper_index = 4 if 'lt3' in setup_name else 3

        self.max_cryo_half_rot_degrees  = 3
        self.nb_min_between_nf_optim = 4
        
        self.history_length = 10
        self.avg_length = 9
        self.deque_par_counts   = deque([], self.history_length)
        self.deque_par_laser    = deque([], self.history_length)
        self.deque_t            = deque([], self.history_length)
        self.deque_fpar_laser    = deque([], self.history_length)
        self.deque_repump_counts = deque(self.history_length*[-1], self.history_length)
        
        self.init_counters()  


    # override from config       
        cfg_fn = os.path.join(qt.config['ins_cfg_path'], name+'.cfg')
        if not os.path.exists(cfg_fn):
            _f = open(cfg_fn, 'w')
            _f.write('')
            _f.close()
        
        self.ins_cfg = config.Config(cfg_fn)
        self.load_cfg()
        self.save_cfg()
Example #21
0
    def __init__(self, name, positioner, adwin, red_laser=None):
        Instrument.__init__(self, name)

        self.add_function('optimize')
        self.add_function('run')
        self.add_function('fit')
        self.add_function('first_time_run')
        self.add_function('routine')

        self.rotator = qt.instruments[positioner]
        if red_laser != None:
            self.red = qt.instruments[red_laser]
        else:
            self.red = None
        self.adwin = qt.instruments[adwin]

        ins_pars = {
            'half_channel': {
                'type': types.IntType,
                'flags': Instrument.FLAG_GETSET,
                'val': 2
            },
            'half_stepsize': {
                'type': types.IntType,
                'flags': Instrument.FLAG_GETSET,
                'val': 400
            },
            'half_noof_points': {
                'type': types.IntType,
                'flags': Instrument.FLAG_GETSET,
                'val': 11
            },
            'quarter_channel': {
                'type': types.IntType,
                'flags': Instrument.FLAG_GETSET,
                'val': 1
            },
            'quarter_stepsize': {
                'type': types.IntType,
                'flags': Instrument.FLAG_GETSET,
                'val': 400
            },
            'quarter_noof_points': {
                'type': types.IntType,
                'flags': Instrument.FLAG_GETSET,
                'val': 11
            },
            'first_time_channel': {
                'type': types.IntType,
                'flags': Instrument.FLAG_GETSET,
                'val': 0
            },
            'first_time_stepsize': {
                'type': types.IntType,
                'flags': Instrument.FLAG_GETSET,
                'val': 4250
            },
            'first_time_noof_points': {
                'type': types.IntType,
                'flags': Instrument.FLAG_GETSET,
                'val': 11
            },
            'first_opt_red_power': {
                'type': types.FloatType,
                'flags': Instrument.FLAG_GETSET,
                'val': 1e-9
            },
            'opt_threshold': {
                'type': types.FloatType,
                'flags': Instrument.FLAG_GETSET,
                'val': 5E5
            },
            'zpl_counter': {
                'type': types.IntType,
                'flags': Instrument.FLAG_GETSET,
                'val': 2
            },
            'plot_degrees': {
                'type': types.BooleanType,
                'flags': Instrument.FLAG_GETSET,
                'val': True
            },
            'pos_degrees_per_step_cal': {
                'type': types.FloatType,
                'flags': Instrument.FLAG_GETSET,
                'val': 1e-3
            },
            'neg_degrees_per_step_cal': {
                'type': types.FloatType,
                'flags': Instrument.FLAG_GETSET,
                'val': 1e-3
            },
        }

        instrument_helper.create_get_set(self, ins_pars)

        self.check_noof_steps = 10000  #ask before changing this number of steps
        self.opt_red_power = 1E-9  #NOTE!!        self.first_opt_red_power = 1E-9

        self.add_parameter('opt_red_power',
                           flags=Instrument.FLAG_GETSET,
                           minval=0,
                           maxval=100E-9,
                           units='W',
                           type=types.FloatType)

        self.add_parameter('opt_scan_range',
                           flags=Instrument.FLAG_GETSET,
                           type=types.TupleType,
                           units='deg')

        self.add_parameter('conversion_factor',
                           type=types.FloatType,
                           flags=Instrument.FLAG_GET)

        cfg_fn = os.path.join(qt.config['ins_cfg_path'], name + '.cfg')

        if not os.path.exists(cfg_fn):
            _f = open(cfg_fn, 'w')
            _f.write('')
            _f.close()

        self._ins_cfg = config.Config(cfg_fn)
        self.load_cfg()
        self.save_cfg()
Example #22
0
    def __init__(self,
                 name,
                 adwin='adwin',
                 master_of_cavity='master_of_cavity',
                 control_adc_no=32,
                 value_adc_no=16,
                 **kw):
        Instrument.__init__(self, name)

        ins_pars = {
            'read_interval': {
                'type': types.FloatType,
                'flags': Instrument.FLAG_GETSET,
                'unit': 's',
                'val': 1.
            },
            'is_running': {
                'type': types.BooleanType,
                'flags': Instrument.FLAG_GETSET,
                'val': False
            },
            'step_size': {
                'type': types.FloatType,
                'flags': Instrument.FLAG_GETSET,
                'unit': 'V',
                'val': 0.001
            },
            'step_threshold': {
                'type': types.FloatType,
                'flags': Instrument.FLAG_GETSET,
                'unit': 'V',
                'val': 8.
            },
            'min_value': {
                'type': types.FloatType,
                'flags': Instrument.FLAG_GETSET,
                'unit': 'V',
                'val': 0.1
            },
        }
        instrument_helper.create_get_set(self, ins_pars)

        self.add_parameter('control',
                           flags=Instrument.FLAG_GET,
                           units='V',
                           type=types.FloatType)

        self.add_parameter('value',
                           flags=Instrument.FLAG_GET,
                           units='V',
                           type=types.FloatType)

        self.add_function('start')
        self.add_function('stop')
        self.add_function('manual_check')

        self._control_adc_no = control_adc_no
        self._value_adc_no = value_adc_no

        self._adwin = qt.instruments[adwin]
        self._moc = qt.instruments[master_of_cavity]

        self._timer = -1

        # override from config    ----------
        cfg_fn = os.path.abspath(
            os.path.join(qt.config['ins_cfg_path'], name + '.cfg'))
        if not os.path.exists(cfg_fn):
            _f = open(cfg_fn, 'w')
            _f.write('')
            _f.close()
        self._parlist = ['read_interval', 'step_size', 'step_threshold']
        self.ins_cfg = config.Config(cfg_fn)
        self.load_cfg()
        self.save_cfg()
Example #23
0
    def __init__(self, name, get_freq_yellow = None, set_freq_yellow = None, get_counts_yellow = None, get_attemps_yellow = None,
                             get_freq_gate = None, set_freq_gate = None, get_counts_gate = None, get_attemps_gate = None,
                             get_freq_newfocus = None, set_freq_newfocus = None, plot_name=''):
        Instrument.__init__(self, name)        
        if plot_name=='': 
            plot_name='optimizer_'+name            
               
        self._get_freq_yellow=get_freq_yellow
        self._set_freq_yellow=set_freq_yellow
        self._get_counts_yellow=get_counts_yellow
        self._get_attemps_yellow=get_attemps_yellow  

        self._get_freq_gate=get_freq_gate
        self._set_freq_gate=set_freq_gate
        self._get_counts_gate=get_counts_gate
        self._get_attemps_gate=get_attemps_gate       

        self._get_freq_newfocus=get_freq_newfocus
        self._set_freq_newfocus=set_freq_newfocus 

        self._yellow_went_up = False;
        self._gate_went_up = False;  
        self._nf_went_up = False

        self._newfocus_iterations = 0;
        self._gate_iterations = 0;
        self._yellow_iterations = 0; 
       
        self.adwin = qt.get_instruments()['adwin']
        self.pidyellow = qt.get_instruments()['pidyellow']

        ins_pars  ={'do_plot'               :   {'type':types.BooleanType,'val':True,'flags':Instrument.FLAG_GETSET},
                    'plot_name'             :   {'type':types.StringType, 'val':plot_name,'flags':Instrument.FLAG_GETSET},
                    'external_break'        :   {'type':types.BooleanType,'val':False,'flags':Instrument.FLAG_GETSET},                                                            
 
                    'detect_cycles'         :   {'type':types.IntType,    'val':10,'flags':Instrument.FLAG_GETSET},
                    'data_time'             :   {'type':types.FloatType,  'val':0.05,'flags':Instrument.FLAG_GETSET},
                    'flow_sleep'            :   {'type':types.FloatType,  'val':0.1,'flags':Instrument.FLAG_GETSET},                    

                    'yellow_delay'          :   {'type':types.FloatType,  'val':0.4,'flags':Instrument.FLAG_GETSET},                                        
                    'NV0_zeros'             :   {'type':types.IntType,    'val':4,'flags':Instrument.FLAG_GETSET}, 

                    'check_gate_threshold'  :   {'type':types.FloatType,  'val':5,'flags':Instrument.FLAG_GETSET},                    
                    'check_yellow_threshold':   {'type':types.FloatType,  'val':10,'flags':Instrument.FLAG_GETSET},                    
                    'check_newfocus_zeros'  :   {'type':types.IntType,    'val':3,'flags':Instrument.FLAG_GETSET},

                    'opt_gate_good'         :   {'type':types.FloatType,  'val':15,'flags':Instrument.FLAG_GETSET},                    
                    'opt_yellow_good'       :   {'type':types.FloatType,  'val':10,'flags':Instrument.FLAG_GETSET},                    
                    'opt_nf_good'           :   {'type':types.FloatType,  'val':25,'flags':Instrument.FLAG_GETSET},                                        
                    
                    'opt_gate_scan_min'     :   {'type':types.FloatType,  'val':-0.1,'flags':Instrument.FLAG_GETSET},                    
                    'opt_yellow_scan_min'   :   {'type':types.FloatType,  'val':-0.8,'flags':Instrument.FLAG_GETSET},                    
                    'opt_nf_scan_min'       :   {'type':types.FloatType,  'val':-0.5,'flags':Instrument.FLAG_GETSET},                                        

                    'opt_gate_scan_max'     :   {'type':types.FloatType,  'val':0.1,'flags':Instrument.FLAG_GETSET},                    
                    'opt_yellow_scan_max'   :   {'type':types.FloatType,  'val':0.8,'flags':Instrument.FLAG_GETSET},                    
                    'opt_nf_scan_max'       :   {'type':types.FloatType,  'val':0.5,'flags':Instrument.FLAG_GETSET},                                        
                    
                    'opt_gate_dwell'        :   {'type':types.FloatType,  'val':0.2,'flags':Instrument.FLAG_GETSET},                    
                    'opt_yellow_dwell'      :   {'type':types.FloatType,  'val':0.3,'flags':Instrument.FLAG_GETSET},                    
                    'opt_nf_dwell'          :   {'type':types.FloatType,  'val':0.1,'flags':Instrument.FLAG_GETSET},                                        

                    'opt_gate_step'         :   {'type':types.FloatType,  'val':0.01,'flags':Instrument.FLAG_GETSET},                    
                    'opt_yellow_step'       :   {'type':types.FloatType,  'val':0.04,'flags':Instrument.FLAG_GETSET},                    
                    'opt_nf_step'           :   {'type':types.FloatType,  'val':0.02,'flags':Instrument.FLAG_GETSET},                                        

                    'max_gate_iterations'   :   {'type':types.IntType,    'val':5,'flags':Instrument.FLAG_GETSET},                    
                    'max_yellow_iterations' :   {'type':types.IntType,    'val':5,'flags':Instrument.FLAG_GETSET},                    
                    'max_nf_iterations'     :   {'type':types.IntType,    'val':1,'flags':Instrument.FLAG_GETSET},                                        
                    }
        
        instrument_helper.create_get_set(self,ins_pars)

        self.add_parameter('is_pidgate_running',type=types.BooleanType, flags = Instrument.FLAG_GETSET)
        self.add_parameter('is_yellowfrq_running',type=types.BooleanType,flags = Instrument.FLAG_GETSET)   

        self.add_function('optimize_gate')
        self.add_function('optimize_yellow')
        self.add_function('optimize_newfocus')
        self.add_function('flow')
        
    # override from config       
        cfg_fn = os.path.join(qt.config['ins_cfg_path'], name+'.cfg')
        if not os.path.exists(cfg_fn):
            _f = open(cfg_fn, 'w')
            _f.write('')
            _f.close()
        
        self.ins_cfg = config.Config(cfg_fn)
        self.load_cfg()
        self.save_cfg()
Example #24
0
    def __init__(self,
                 name,
                 get_control_f=None,
                 set_control_f=None,
                 get_value_f=None,
                 get_norm_f=None,
                 plot_name=''):
        Instrument.__init__(self, name)
        if plot_name == '':
            plot_name = 'optimizer_' + name

        self._get_control_f = get_control_f
        self._set_control_f = set_control_f
        self._get_value_f = get_value_f
        self._get_norm_f = get_norm_f

        ins_pars = {
            'scan_min': {
                'type': types.FloatType,
                'val': 0.0,
                'flags': Instrument.FLAG_GETSET
            },
            'scan_max': {
                'type': types.FloatType,
                'val': 0.0,
                'flags': Instrument.FLAG_GETSET
            },
            'control_step_size': {
                'type': types.FloatType,
                'val': 0.0,
                'flags': Instrument.FLAG_GETSET
            },
            'min_value': {
                'type': types.FloatType,
                'val': 2.,
                'flags': Instrument.FLAG_GETSET
            },
            'min_norm': {
                'type': types.FloatType,
                'val': 200.,
                'flags': Instrument.FLAG_GETSET
            },
            'dwell_time': {
                'type': types.FloatType,
                'val': 0.1,
                'flags': Instrument.FLAG_GETSET
            },  #s
            'wait_time': {
                'type': types.FloatType,
                'val': 10,
                'flags': Instrument.FLAG_GETSET
            },  #s
            'order_index': {
                'type': types.IntType,
                'val': 1,
                'flags': Instrument.FLAG_GETSET
            },
            'do_plot': {
                'type': types.BooleanType,
                'val': True,
                'flags': Instrument.FLAG_GETSET
            },
            'do_fit': {
                'type': types.BooleanType,
                'val': False,
                'flags': Instrument.FLAG_GETSET
            },
            'dwell_after_set': {
                'type': types.BooleanType,
                'val': True,
                'flags': Instrument.FLAG_GETSET
            },
            'plot_name': {
                'type': types.StringType,
                'val': plot_name,
                'flags': Instrument.FLAG_GETSET
            },
            'variance': {
                'type': types.FloatType,
                'val': 0.,
                'flags': Instrument.FLAG_GETSET
            },
            'last_max': {
                'type': types.FloatType,
                'val': 0.,
                'flags': Instrument.FLAG_GETSET
            },
            'good_value': {
                'type': types.FloatType,
                'val': 100,
                'flags': Instrument.FLAG_GETSET
            },
        }

        instrument_helper.create_get_set(self, ins_pars)

        self.add_function('scan')
        self.add_function('optimize')
        self.add_function('get_value')

        # override from config
        cfg_fn = os.path.join(qt.config['ins_cfg_path'], name + '.cfg')
        if not os.path.exists(cfg_fn):
            _f = open(cfg_fn, 'w')
            _f.write('')
            _f.close()

        self.ins_cfg = config.Config(cfg_fn)
        self.load_cfg()
        self.save_cfg()
    def __init__(self, name, set_ctrl_func=None, get_val_func=None, 
                 set_ctrl_func_coarse=None,get_ctrl_func_coarse=None, get_ctrl_func=None, 
                 get_stabilizor_func=None, **kw):
        
        Instrument.__init__(self, name)

        self._set_ctrl = set_ctrl_func
        self._get_val = get_val_func
        self._get_ctrl = get_ctrl_func #neccecary for the Matisse pid
        self._get_stabilizor = get_stabilizor_func #neccecary for the HeNe true wavelength stabilisation
        self._set_ctrl_coarse = set_ctrl_func_coarse
        self._get_ctrl_coarse = get_ctrl_func_coarse

        if not(self._get_stabilizor == None): self._stabilizor_value = self._get_stabilizor()

        self.add_parameter('control_parameter',
                type=types.FloatType,
                minval=kw.get('ctrl_minval', -10.),
                maxval=kw.get('ctrl_maxval', +10.),
                flags=Instrument.FLAG_GETSET)
                
        self.add_parameter('control_parameter_coarse',
                type=types.FloatType,
                minval=kw.get('ctrl_minval_coarse', -10.),
                maxval=kw.get('ctrl_maxval_coarse', +10.),
                flags=Instrument.FLAG_GETSET)
        
        self.add_parameter('value',
                type=types.FloatType,
                flags=Instrument.FLAG_GET)

        self.add_parameter('setpoint',
                type=types.FloatType,
                flags=Instrument.FLAG_GETSET)
        
        ins_pars  = {'is_running'               :   {'type':types.BooleanType,'val':False,'flags':Instrument.FLAG_GETSET},
                    'use_stabilizor'            :   {'type':types.BooleanType,'val':False,'flags':Instrument.FLAG_GETSET},
                    'max_value'                 :   {'type':types.FloatType,  'val':100.0,'flags':Instrument.FLAG_GETSET},
                    'min_value'                 :   {'type':types.FloatType,  'val':0.0,  'flags':Instrument.FLAG_GETSET},
                    'P'                         :   {'type':types.FloatType,  'val':0.,   'flags':Instrument.FLAG_GETSET},
                    'I'                         :   {'type':types.FloatType,  'val':0.,   'flags':Instrument.FLAG_GETSET}, #s
                    'D'                         :   {'type':types.FloatType,  'val':0.,   'flags':Instrument.FLAG_GETSET}, #s
                    'read_interval'             :   {'type':types.FloatType,  'val':0.2,  'units':'s','flags':Instrument.FLAG_GETSET},
                    'write_interval'            :   {'type':types.IntType,    'val':1,    'maxval':100,'minval':1,'flags':Instrument.FLAG_GETSET},
                    'value_offset'              :   {'type':types.FloatType,  'val':470.4,'flags':Instrument.FLAG_GETSET},
                    'value_factor'              :   {'type':types.FloatType,  'val':1e3,  'flags':Instrument.FLAG_GETSET},
                    'step_size'                 :   {'type':types.FloatType,  'val':0.01, 'flags':Instrument.FLAG_GETSET},
                    'floating_avg_pts'          :   {'type':types.IntType,    'val':1.,   'maxval':100,'minval':1, 'flags':Instrument.FLAG_GETSET},
                    'max_control_deviation'     :   {'type':types.FloatType,  'val':1.0,  'flags':Instrument.FLAG_GETSET},
                    'control_coarse_step':{'type':types.FloatType, 'val':0.05,'flags':Instrument.FLAG_GETSET},
                    }
        instrument_helper.create_get_set(self,ins_pars)
        self.add_function('start')
        self.add_function('stop')
        self.add_function('step_up')
        self.add_function('step_down')
       
        self.set_setpoint(0)
        self._control_parameter=0
        self._control_parameter_coarse=0

        # override from config       
        cfg_fn = os.path.abspath(
                os.path.join(qt.config['ins_cfg_path'], name+'.cfg'))
        if not os.path.exists(cfg_fn):
            _f = open(cfg_fn, 'w')
            _f.write('')
            _f.close()
        
        self._parlist = ['P', 'I', 'D',
                'setpoint', 'value_factor', 'value_offset','max_value',
                'min_value', 'max_control_deviation','use_stabilizor', 'step_size',
                'control_coarse_step']
        self.ins_cfg = config.Config(cfg_fn)
        self.load_cfg()
        self.save_cfg()
    def __init__(self,name,optimize_yellow=True):
        multiple_optimizer.__init__(self,name)
        ins_pars  = {'starts_min'         :   {'type':types.IntType,'flags':Instrument.FLAG_GETSET, 'val':100},
                    'cr_succes_min'       :   {'type':types.FloatType,'flags':Instrument.FLAG_GETSET, 'val':0.6},
                    'cr_checks_min'       :   {'type':types.IntType,'flags':Instrument.FLAG_GETSET, 'val':100},
                    'threshold_probe'     :   {'type':types.IntType,'flags':Instrument.FLAG_GETSET, 'val':20},
                    'threshold_preselect' :   {'type':types.IntType,'flags':Instrument.FLAG_GETSET, 'val':20},
                    'variance_yellow_min' :   {'type':types.FloatType,'flags':Instrument.FLAG_GETSET, 'val':50},
                    'threshold_init'      :   {'type':types.FloatType,'flags':Instrument.FLAG_GETSET, 'val':15},
                    }
        
        instrument_helper.create_get_set(self,ins_pars)
        self.add_function('set_high_threshold')
        self.add_function('set_low_threshold')
        
        self._stepper_size=0.01
        self._last_optimizer=''
        self.plot_name='lt2_ssro_optimizer_plot'
        
        self._ins_adwin=qt.instruments['adwin']
        self._ins_adwin_lt1=qt.instruments['adwin_lt1']
        self._ins_physical_adwin=qt.instruments['physical_adwin']
        self._ins_ivvi=qt.instruments['ivvi_lt1']

        ##values
        self._get_value_f={
                't'             :    time.time,
                'cr_checks'     :    lambda: self._ins_adwin_lt1.get_teleportation_var('noof_cr_checks'),
                'probe_cts'     :    lambda: self._ins_adwin_lt1.get_teleportation_var('total_CR_counts'),
                'repumps'       :    lambda: self._ins_adwin_lt1.get_teleportation_var('cr_below_threshold_events'),
                'starts'        :    lambda: self._ins_adwin_lt1.get_teleportation_var('noof_starts'),
                'noof_repumps'  :    lambda: self._ins_adwin_lt1.get_teleportation_var('noof_repumps'),
                'repump_counts' :    lambda: self._ins_adwin_lt1.get_teleportation_var('repump_counts'),
                }  
        self._values={}
        for key in self._get_value_f.keys():
            self._values[key]=0
        
        ##optimizers
        #pids
        """
        pid='pidnewfocus'
        pid_ins=qt.instruments[pid]
        self.add_optimizer(pid+'_optimizer',
                          get_control_f=pid_ins.get_value,
                          set_control_f=lambda x: pid_ins.set_setpoint(x),
                          get_value_f= self._get_value_f['probe_cts'],
                          get_norm_f= self._get_value_f['cr_checks'],
                          plot_name=self.plot_name)
        #self.create_stepper_buttons(pid)
        pid='pidmatisse'
        pid_ins_n=qt.instruments[pid]
        self.add_optimizer(pid+'_optimizer',
                          get_control_f=pid_ins_n.get_value,
                          set_control_f=lambda x: pid_ins_n.set_setpoint(x),
                          get_value_f= self._get_value_f['probe_cts'],
                          get_norm_f= self._get_value_f['cr_checks'],
                          plot_name=self.plot_name)
        #self.create_stepper_buttons(pid)
        """
        self._optimize_yellow=optimize_yellow and False
        if self._optimize_yellow:
            pid='pidyellow'
            pid_ins_y=qt.instruments[pid]
            #self.add_optimizer(pid+'_optimizer',
            #                  get_control_f=pid_ins_y.get_value,
            #                  set_control_f=lambda x: self._ins_physical_adwin.Set_FPar(52,x),
            #                  get_value_f= self._get_value_f['repump_counts'],
            #                  get_norm_f= self._get_value_f['noof_repumps'],
            #                  plot_name=self.plot_name)
            #self.create_stepper_buttons(pid)
        
        #gate
        self.add_optimizer('gate_optimizer',
                          get_control_f=self._ins_ivvi.get_dac2,
                          set_control_f=lambda x: self._ins_ivvi.set_dac2(x),
                          get_value_f=self._get_value_f['probe_cts'],
                          get_norm_f= self._get_value_f['cr_checks'],
                          plot_name=self.plot_name)
        
        # override from config       
        cfg_fn = os.path.join(qt.config['ins_cfg_path'], name+'.cfg')
        if not os.path.exists(cfg_fn):
            _f = open(cfg_fn, 'w')
            _f.write('')
            _f.close()
        
        self.ins_cfg = config.Config(cfg_fn)
        self.load_cfg()
        self.save_cfg()
    def __init__(self, name, optimize_yellow=True):
        multiple_optimizer.__init__(self, name)
        ins_pars = {
            'starts_min': {
                'type': types.IntType,
                'flags': Instrument.FLAG_GETSET,
                'val': 100
            },
            'cr_succes_min': {
                'type': types.FloatType,
                'flags': Instrument.FLAG_GETSET,
                'val': 0.6
            },
            'cr_checks_min': {
                'type': types.IntType,
                'flags': Instrument.FLAG_GETSET,
                'val': 100
            },
            'threshold_probe': {
                'type': types.IntType,
                'flags': Instrument.FLAG_GETSET,
                'val': 20
            },
            'threshold_preselect': {
                'type': types.IntType,
                'flags': Instrument.FLAG_GETSET,
                'val': 20
            },
            'variance_yellow_min': {
                'type': types.FloatType,
                'flags': Instrument.FLAG_GETSET,
                'val': 50
            },
            'threshold_init': {
                'type': types.FloatType,
                'flags': Instrument.FLAG_GETSET,
                'val': 15
            },
        }

        instrument_helper.create_get_set(self, ins_pars)
        self.add_function('set_high_threshold')
        self.add_function('set_low_threshold')

        self._stepper_size = 0.01
        self._last_optimizer = ''
        self.plot_name = 'lt2_ssro_optimizer_plot'

        self._ins_adwin = qt.instruments['adwin']
        self._ins_adwin_lt1 = qt.instruments['adwin_lt1']
        self._ins_physical_adwin = qt.instruments['physical_adwin']
        self._ins_ivvi = qt.instruments['ivvi_lt1']

        ##values
        self._get_value_f = {
            't':
            time.time,
            'cr_checks':
            lambda: self._ins_adwin_lt1.get_teleportation_var('noof_cr_checks'
                                                              ),
            'probe_cts':
            lambda: self._ins_adwin_lt1.get_teleportation_var('total_CR_counts'
                                                              ),
            'repumps':
            lambda: self._ins_adwin_lt1.get_teleportation_var(
                'cr_below_threshold_events'),
            'starts':
            lambda: self._ins_adwin_lt1.get_teleportation_var('noof_starts'),
            'noof_repumps':
            lambda: self._ins_adwin_lt1.get_teleportation_var('noof_repumps'),
            'repump_counts':
            lambda: self._ins_adwin_lt1.get_teleportation_var('repump_counts'),
        }
        self._values = {}
        for key in self._get_value_f.keys():
            self._values[key] = 0

        ##optimizers
        #pids
        """
        pid='pidnewfocus'
        pid_ins=qt.instruments[pid]
        self.add_optimizer(pid+'_optimizer',
                          get_control_f=pid_ins.get_value,
                          set_control_f=lambda x: pid_ins.set_setpoint(x),
                          get_value_f= self._get_value_f['probe_cts'],
                          get_norm_f= self._get_value_f['cr_checks'],
                          plot_name=self.plot_name)
        #self.create_stepper_buttons(pid)
        pid='pidmatisse'
        pid_ins_n=qt.instruments[pid]
        self.add_optimizer(pid+'_optimizer',
                          get_control_f=pid_ins_n.get_value,
                          set_control_f=lambda x: pid_ins_n.set_setpoint(x),
                          get_value_f= self._get_value_f['probe_cts'],
                          get_norm_f= self._get_value_f['cr_checks'],
                          plot_name=self.plot_name)
        #self.create_stepper_buttons(pid)
        """
        self._optimize_yellow = optimize_yellow and False
        if self._optimize_yellow:
            pid = 'pidyellow'
            pid_ins_y = qt.instruments[pid]
            #self.add_optimizer(pid+'_optimizer',
            #                  get_control_f=pid_ins_y.get_value,
            #                  set_control_f=lambda x: self._ins_physical_adwin.Set_FPar(52,x),
            #                  get_value_f= self._get_value_f['repump_counts'],
            #                  get_norm_f= self._get_value_f['noof_repumps'],
            #                  plot_name=self.plot_name)
            #self.create_stepper_buttons(pid)

        #gate
        self.add_optimizer('gate_optimizer',
                           get_control_f=self._ins_ivvi.get_dac2,
                           set_control_f=lambda x: self._ins_ivvi.set_dac2(x),
                           get_value_f=self._get_value_f['probe_cts'],
                           get_norm_f=self._get_value_f['cr_checks'],
                           plot_name=self.plot_name)

        # override from config
        cfg_fn = os.path.join(qt.config['ins_cfg_path'], name + '.cfg')
        if not os.path.exists(cfg_fn):
            _f = open(cfg_fn, 'w')
            _f.write('')
            _f.close()

        self.ins_cfg = config.Config(cfg_fn)
        self.load_cfg()
        self.save_cfg()