Пример #1
0
    def _start_clicked_cb(self, widget):
        logging.debug('Starting measurement')

        self.set_sensitive(False)

        mname = self._name_entry.get_text()
        if mname == '':
            mname = 'auto'
        delay = self._delay.get_value() / 1000.0

        s = scriptgenerator.LoopGenerator(name=mname, delay=delay)
        self._add_loop_var(s, 'z', self._sweep_z)
        self._add_loop_var(s, 'y', self._sweep_y)
        self._add_loop_var(s, 'x', self._sweep_x)
        self._add_measurement(s, 'v1', self._measure_1)
        self._add_measurement(s, 'v2', self._measure_2)
        s.add_finish()

        fn = os.path.join(qt.cmd("qt.config['tempdir']"),
                          'meas%d.py' % self._measurement_id)
        self._measurement_id += 1
        f = open(fn, 'w')
        f.write(s.get_script())
        f.close()

        cmd = 'qt.Script(%r)()' % fn
        qt.interpreter.ip_queue(cmd, callback=do_print)

        self._measurement_start = time.time()
Пример #2
0
    def _start_clicked_cb(self, widget):
        logging.debug('Starting measurement')

        self.set_sensitive(False)

        mname = self._name_entry.get_text()
        if mname == '':
            mname = 'auto'
        delay = self._delay.get_value() / 1000.0

        s = scriptgenerator.LoopGenerator(name=mname, delay=delay)
        self._add_loop_var(s, 'z', self._sweep_z)
        self._add_loop_var(s, 'y', self._sweep_y)
        self._add_loop_var(s, 'x', self._sweep_x)
        self._add_measurement(s, 'v1', self._measure_1)
        self._add_measurement(s, 'v2', self._measure_2)
        s.add_finish()

        fn = os.path.join(qt.cmd("qt.config['tempdir']"), 'meas%d.py' % self._measurement_id)
        self._measurement_id += 1
        f = open(fn, 'w')
        f.write(s.get_script())
        f.close()

        cmd = 'qt.Script(%r)()' % fn
        qt.interpreter.ip_queue(cmd, callback=do_print)

        self._measurement_start = time.time()
Пример #3
0
    def _update_cb(self, sender, ins_param, val):
        if ins_param not in self._watch:
            return

        info = self._watch[ins_param]
        ins = info['instrument']
        param = info['parameter']
        strval = qt.format_parameter_value(info['options'], val)
        self._tree_model.set(info['iter'], 2, strval)

        if not info.get('graph', False):
            return

        cols = self._get_ncols(info, val)
        plotname = 'watch_%s.%s' % (ins.get_name(), param)

        # Create temp file and setup plotting
        if 'tempfile' not in info:
            info['tempfile'] = temp.File(mode='w')

            cmd = 'qt.plot_file("%s", name="%s", clear=True)' % (
                info['tempfile'].name, plotname)
            qt.cmd(cmd, callback=lambda *x: True)
            for i in range(cols - 2):
                cmd = 'qt.plot_file("%s", name="%s", valdim=%d)' % (
                    info['tempfile'].name, plotname, i + 2)
                qt.cmd(cmd, callback=lambda *x: True)
        else:
            info['tempfile'].reopen()

        # Allocate array, fill xs and ys with first point, shift otherwise
        if 'data' not in info or info['data'] is None:
            d = np.ones([info['points'], cols])
            info['data'] = d
            r = self._get_row(info, val)
            for i in range(cols):
                d[:, i] = r[i]
        else:
            info['data'][:-1, :] = info['data'][1:, :]

        r = self._get_row(info, val, prevrow=info['data'][-2, :])
        info['data'][-1, :] = r

        np.savetxt(info['tempfile'].get_file(), info['data'])
        info['tempfile'].close()
        cmd = 'qt.plots["%s"].update()' % (plotname, )
        qt.cmd(cmd)
Пример #4
0
    def _update_cb(self, sender, ins_param, val):
        if ins_param not in self._watch:
            return

        info = self._watch[ins_param]
        ins = info['instrument']
        param = info['parameter']
        strval = qt.format_parameter_value(info['options'], val)
        self._tree_model.set(info['iter'], 2, strval)

        if not info.get('graph', False):
            return

        cols = self._get_ncols(info, val)
        plotname = 'watch_%s.%s' % (ins.get_name(), param)

        # Create temp file and setup plotting
        if 'tempfile' not in info:
            info['tempfile'] = temp.File(mode='w')

            cmd = 'qt.plot_file("%s", name="%s", clear=True)' % (info['tempfile'].name, plotname)
            qt.cmd(cmd, callback=lambda *x: True)
            for i in range(cols - 2):
                cmd = 'qt.plot_file("%s", name="%s", valdim=%d)' % (info['tempfile'].name, plotname, i+2)
                qt.cmd(cmd, callback=lambda *x: True)
        else:
            info['tempfile'].reopen()

        # Allocate array, fill xs and ys with first point, shift otherwise
        if 'data' not in info or info['data'] is None:
            d = np.ones([info['points'], cols])
            info['data'] = d
            r = self._get_row(info, val)
            for i in range(cols):
                d[:,i] = r[i]
        else:
            info['data'][:-1,:] = info['data'][1:,:]

        r = self._get_row(info, val, prevrow=info['data'][-2,:])
        info['data'][-1,:] = r

        np.savetxt(info['tempfile'].get_file(), info['data'])
        info['tempfile'].close()
        cmd = 'qt.plots["%s"].update()' % (plotname, )
        qt.cmd(cmd)
Пример #5
0
    def _update_cb(self, sender, ins_param, val):
        if ins_param not in self._watch:
            return

        info = self._watch[ins_param]
        ins = info['instrument']
        param = info['parameter']
        strval = qt.format_parameter_value(info['options'], val)
        self._tree_model.set(info['iter'], 2, strval)

        if not info.get('graph', False):
            return

        plotname = 'watch_%s.%s' % (ins.get_name(), param)
        if 'data' not in info or info['data'] is None:
            cols = self._get_ncols(info, val)
            d = np.zeros([info['points'], cols], dtype=np.float)
            r = self._get_row(info, val)
            d[0, :] = self._get_row(info, val)
            info['data'] = d
            info['tempfile'] = temp.File(mode='w')

            cmd = 'qt.plot_file("%s", name="%s", clear=True)' % (
                info['tempfile'].name, plotname)
            qt.cmd(cmd, callback=lambda *x: do_print(x))
            for i in range(cols - 2):
                cmd = 'qt.plot_file("%s", name="%s", valdim=%d)' % (
                    info['tempfile'].name, plotname, i + 2)
                qt.cmd(cmd, callback=lambda *x: do_print(x))

        else:
            info['tempfile'].reopen()

        info['data'][0:-1, :] = info['data'][1:, :]
        r = self._get_row(info, val, prevrow=info['data'][-2, :])
        info['data'][-1, :] = self._get_row(info,
                                            val,
                                            prevrow=info['data'][-2, :])
        np.savetxt(info['tempfile'].get_file(), info['data'])
        info['tempfile'].close()
        cmd = 'qt.plots["%s"].update()' % (plotname, )
        qt.cmd(cmd)
Пример #6
0
    def _update_cb(self, sender, ins_param, val):
        if ins_param not in self._watch:
            return

        info = self._watch[ins_param]
        ins = info['instrument']
        param = info['parameter']
        strval = qt.format_parameter_value(info['options'], val)
        self._tree_model.set(info['iter'], 2, strval)

        if not info.get('graph', False):
            return

        plotname = 'watch_%s.%s' % (ins.get_name(), param)
        if 'data' not in info or info['data'] is None:
            cols = self._get_ncols(info, val)
            d = np.zeros([info['points'], cols], dtype=np.float)
            r = self._get_row(info, val)
            d[0,:] = self._get_row(info, val)
            info['data'] = d
            info['tempfile'] = temp.File(mode='w')

            cmd = 'qt.plot_file("%s", name="%s", clear=True)' % (info['tempfile'].name, plotname)
            qt.cmd(cmd, callback=lambda *x: do_print(x))
            for i in range(cols - 2):
                cmd = 'qt.plot_file("%s", name="%s", valdim=%d)' % (info['tempfile'].name, plotname, i+2)
                qt.cmd(cmd, callback=lambda *x: do_print(x))

        else:
            info['tempfile'].reopen()

        info['data'][0:-1,:] = info['data'][1:,:]
        r = self._get_row(info, val, prevrow=info['data'][-2,:])
        info['data'][-1,:] = self._get_row(info, val, prevrow=info['data'][-2,:])
        np.savetxt(info['tempfile'].get_file(), info['data'])
        info['tempfile'].close()
        cmd = 'qt.plots["%s"].update()' % (plotname, )
        qt.cmd(cmd)