Ejemplo n.º 1
0
    def __init__(self,
                 parent,
                 details,
                 ID,
                 status,
                 name,
                 kind='1d',
                 ls=23,
                 gw=384,
                 gh=192,
                 pl=320,
                 bl=12,
                 ll=128,
                 ih=96):
        super(sweepInstance, self).__init__()
        # info/control bar at top
        self.parent = parent
        self.det = details
        self.status = status
        self.name = name
        self.ID = ID
        self.kind = kind  # '1d' or '2d'

        self.measurements_completed = 0
        self.total_time = 0.0  # total amount of time spent sweeping.
        self.current_rate = 0.0  # current sweep rate
        self.finished_time = None  # None = not finished
        self.was_paused = False  # Used to skip paused time when counting average rate
        self.completed = False  # has it finished?

        self.np_swept = 0.0  # amount of setting swept while not paused
        self.np_time = 0.0  # amount of time passed while not paused

        self.ls = ls  # line spacing
        self.gw = gw  # graph width
        self.gh = gh  # graph height

        self.pl = pl  # plot(2d) sidelength
        self.bl = bl  # bar (and bar spacing) length
        self.ll = ll  # label length

        self.setting_details = self.det['setting_details']
        self.colormap = None
        self.custom_map = None

        # parameters
        self.parameter_names = []

        # dataset
        if kind == '1d':
            independents = [
                self.det['custom_name']
                if self.det['custom_name'] else self.det['xlabel']
            ]
        else:
            independents = [
                'xnum', 'ynum', self.det['fast_custom_name']
                if self.det['fast_custom_name'] else self.det['xlabel'],
                self.det['slow_custom_name']
                if self.det['slow_custom_name'] else self.det['ylabel']
            ]

        dependents = [setting.name for setting in self.setting_details]

        self.data_set = DataSet(
            self.det['dv_name'],
            self.det['dv_loc'],
            independents,
            dependents,
        )

        # comment, paremeters
        # self.comment_list    = []
        # self.parameter_list  = []
        # self.parameter_names = []
        # self.has_written     = False

        # dataset location (None = not set yet)
        # self.dataset_location = None

        o = array([0, ls * 5])  # origin
        self.graphs = {}
        n = 0
        if self.kind == '1d':
            lbl = [setting.ID for setting in self.setting_details]
        elif self.kind == '2d':
            lbl = [setting.ID for setting in self.setting_details]
        for pos in range(len(lbl)):
            ylabel = self.setting_details[pos].name
            ID = self.setting_details[pos].ID
            if kind == '1d':
                x = o[0] + (gw + ls) * (n % 3)
                xlabel = self.det['custom_name'] if self.det[
                    'custom_name'] else self.det['xlabel']
                y = o[1] + (gh + ls) * int(floor(
                    n / 3.0))  # rectangular graphs for 1d
                self.graphs.update([[
                    ID,
                    plotInstance(xlabel,
                                 ylabel,
                                 None,
                                 parent=self,
                                 geometry=[x, y, gw, gh])
                ]])

            elif kind == '2d':
                xname = self.det['fast_custom_name'] if self.det[
                    'fast_custom_name'] else self.det['xlabel']
                yname = self.det['slow_custom_name'] if self.det[
                    'slow_custom_name'] else self.det['ylabel']
                #print(xname,yname)
                x = o[0] + (n % 3) * (pl + 7 * ls + ih)  #(ls*2+pl+bl*3+ll)
                y = o[1] + int(floor(n / 3.0)) * (
                    pl + 2 * ls + ih)  #(gw+ls) *  # square graphs for 2d
                self.graphs.update([[
                    ID,
                    colorplotShell(xname,
                                   yname,
                                   self.det['xnum'],
                                   self.det['ynum'],
                                   [self.det['xstart'], self.det['xstop']],
                                   [self.det['ystart'], self.det['ystop']],
                                   parent=self,
                                   geometry=[
                                       x, y, ls + pl + bl * 3 + ll, pl + ls
                                   ],
                                   name=self.det['setting_details'][pos].name,
                                   ls=ls,
                                   pl=pl,
                                   bl=bl,
                                   ll=ll)
                ]])

            n += 1

        if self.kind == '2d':
            self.current_delay = self.det['xdelay']

        # User defined input handling
        if self.kind == '1d':
            self.inputs = self.det['inputs']
            self.to_sweep = self.det['to_sweep']
        if self.kind == '2d':
            self.inputs_fast = self.det['inputs_fast']
            self.to_sweep_fast = self.det['to_sweep_fast']
            self.inputs_slow = self.det['inputs_slow']
            self.to_sweep_slow = self.det['to_sweep_slow']

        self.first_meas = True
        self.doUI()
        self.time = time.time()