示例#1
0
    def __init__(self, sa, sacm, lo, parent=None):
        QMainWindow.__init__(self, parent)
        self.setupUi(self)

        #instruments
        self.sa = sa
        self.sacm = sacm
        self.lo = lo
        self.lo.set_output(False)
        self.lo.set_power(self.sa.lo_power)

        #reading over time plot
        self.curvewidget.add_toolbar(self.addToolBar("Curve"))
        self.curvewidget.register_all_image_tools()
        self.plot = self.curvewidget.plot
        self.plot.set_titles(title="Power vs. Time",
                             xlabel="Time (s)",
                             ylabel="Power")

        self.ch1_plot = make.mcurve(np.array([]),
                                    np.array([]),
                                    label='Magnitude')  #Make Ch1 curve
        self.plot.add_item(self.ch1_plot)
        self.data = []
        self.tl = []
        self.t0 = time.time()
        self.first_update = True

        #spectrum plot
        self.spec_plot = self.spectrumCurvewidget.plot
        self.spectrumCurvewidget.register_all_image_tools()
        self.spec_plot.set_titles(title='Power vs. Frequency',
                                  xlabel='Frequency (GHz)',
                                  ylabel='Power')
        self.spectrum = make.mcurve(np.array([]), np.array([]))
        self.spec_plot.add_item(self.spectrum)
        self.spec = []
        self.fd = []
        self.sweeping = [False, False]

        self.sweep_end = self.endSweepSpinBox.value()

        #register UI listeners
        self.ctimer = QTimer(
        )  #Setup autoupdating timer to call update_plots at 10Hz
        self.ctimer.timeout.connect(self.update_ui)
        self.ctimer.start(100)
        self.dBmLabel.hide()
        self.calibratedOuputCheckBox.clicked.connect(
            self.cali_output_checkbox_clicked)
        self.updateRateSpinBox.setValue(10.0)
        self.updateRateSpinBox.editingFinished.connect(
            self.update_rate_changed)
        self.frequencySpinBox.editingFinished.connect(self.frequency_changed)
        self.endSweepSpinBox.editingFinished.connect(self.end_changed)
        self.clearButton.clicked.connect(self.clear_plot)
        self.sweepButton.clicked.connect(self.sweep)

        self.frequency_changed()
示例#2
0
文件: Scope2.py 项目: ziqianli/slab
 def init_plots(self):
     self.plots["plot"] = self.curvewidget.plot
     self.curvewidget.add_toolbar(self.toolBar)
     self.curvewidget.register_all_curve_tools()
     x = np.linspace(-5,5,1000)
     y1 = np.cos(x)
     y2 = np.sin(x)
     self.plots["ch1"] = make.mcurve(x, y1, label="Ch1")
     self.plots["plot"].add_item(self.plots["ch1"])
     self.plots["ch2"] = make.mcurve(x, y2, label="Ch2")
     self.plots["plot"].add_item(self.plots["ch2"])
示例#3
0
    def __init__(self, sa, sacm, lo, parent = None):    
        QMainWindow.__init__(self, parent)
        self.setupUi(self)
        
        #instruments
        self.sa = sa
        self.sacm = sacm
        self.lo = lo
        self.lo.set_output(False)
        self.lo.set_power(self.sa.lo_power)
 
        #reading over time plot
        self.curvewidget.add_toolbar(self.addToolBar("Curve"))
        self.curvewidget.register_all_image_tools()
        self.plot = self.curvewidget.plot   
        self.plot.set_titles(title="Power vs. Time", xlabel="Time (s)", ylabel="Power")
       
        self.ch1_plot = make.mcurve(np.array([]),np.array([]),label='Magnitude') #Make Ch1 curve
        self.plot.add_item(self.ch1_plot)
        self.data=[]
        self.tl = []
        self.t0 = time.time()
        self.first_update = True
        
        #spectrum plot
        self.spec_plot = self.spectrumCurvewidget.plot
        self.spectrumCurvewidget.register_all_image_tools()
        self.spec_plot.set_titles(title='Power vs. Frequency', xlabel='Frequency (GHz)', ylabel='Power')
        self.spectrum = make.mcurve(np.array([]), np.array([]))
        self.spec_plot.add_item(self.spectrum)
        self.spec = []
        self.fd = []
        self.sweeping = [False, False]
        
        self.sweep_end = self.endSweepSpinBox.value()

        #register UI listeners
        self.ctimer = QTimer()      #Setup autoupdating timer to call update_plots at 10Hz
        self.ctimer.timeout.connect(self.update_ui)
        self.ctimer.start(100)
        self.dBmLabel.hide()
        self.calibratedOuputCheckBox.clicked.connect(self.cali_output_checkbox_clicked)
        self.updateRateSpinBox.setValue(10.0)
        self.updateRateSpinBox.editingFinished.connect(self.update_rate_changed)
        self.frequencySpinBox.editingFinished.connect(self.frequency_changed)
        self.endSweepSpinBox.editingFinished.connect(self.end_changed)
        self.clearButton.clicked.connect(self.clear_plot)
        self.sweepButton.clicked.connect(self.sweep)
        
        self.frequency_changed()
示例#4
0
    def update_nwa_plots(self, xlabel="", ylabel=""):
        if self.x is None or self.y is None: return

        if not self.nwaplotsInitialized:
            self.nwaplotsInitialized = True
            self.nwa_curve = make.mcurve(self.x, self.y, label='Magnitude')
            self.nwaplot.add_item(self.nwa_curve)
            self.nwaplot.set_titles(title="", xlabel=xlabel, ylabel=ylabel)

        self.update_lineplot(self.nwaplot, self.nwa_curve, (self.x, self.y))
示例#5
0
    def update_nwa_plots(self, xlabel="", ylabel=""):
        if self.x is None or self.y is None: return

        if not self.nwaplotsInitialized:
            self.nwaplotsInitialized=True
            self.nwa_curve = make.mcurve(self.x, self.y, label='Magnitude')
            self.nwaplot.add_item(self.nwa_curve)
            self.nwaplot.set_titles(title="", xlabel=xlabel, ylabel=ylabel)

        self.update_lineplot(self.nwaplot , self.nwa_curve, (self.x, self.y))
示例#6
0
def plotyy(x1, y1, x2, y2):
    """
    Plot curves with two different y axes
    
    Example:
        
    import numpy as np
    x = np.linspace(-5, 5, 1000)
    plotyy(x, np.sin(x), x, np.cos(x))
    ylabel("sinus", "cosinus")
    show()
    """
    axe = gca()
    curve1 = make.mcurve(x1, y1, yaxis='left')
    curve2 = make.mcurve(x2, y2, yaxis='right')
    axe.ycolor = (curve1.curveparam.line.color, curve2.curveparam.line.color)
    axe.add_plot(curve1)
    axe.add_plot(curve2)
    _show_if_interactive()
    return [curve1, curve2]
示例#7
0
def plotyy(x1, y1, x2, y2):
    """
    Plot curves with two different y axes
    
    Example:
        
    import numpy as np
    x = np.linspace(-5, 5, 1000)
    plotyy(x, np.sin(x), x, np.cos(x))
    ylabel("sinus", "cosinus")
    show()
    """
    axe = gca()
    curve1 = make.mcurve(x1, y1, yaxis='left')
    curve2 = make.mcurve(x2, y2, yaxis='right')
    axe.ycolor = (curve1.curveparam.line.color, curve2.curveparam.line.color)
    axe.add_plot(curve1)
    axe.add_plot(curve2)
    _show_if_interactive()
    return [curve1, curve2]
示例#8
0
    def setup_plot(self, title, xlabel, ylabel):
        #        self.curvewidget = CurveWidget()
        #        self.setCentralWidget(self.curvewidget)

        self.curvewidget.add_toolbar(self.addToolBar("Curve"))
        self.curvewidget.register_all_image_tools()
        self.plot = self.curvewidget.plot
        x = np.linspace(-5, 5, 1000)  #Create some sample curves
        y1 = np.cos(x)
        self.plot_item = make.mcurve(x, y1, label='Magnitude')  #Make Ch1 curve
        self.plot.add_item(self.plot_item)
        self.plot.set_titles(title=title, xlabel=xlabel, ylabel=ylabel)
示例#9
0
    def setup_plot(self, title, xlabel, ylabel):
#        self.curvewidget = CurveWidget()
#        self.setCentralWidget(self.curvewidget)
        
        self.curvewidget.add_toolbar(self.addToolBar("Curve"))
        self.curvewidget.register_all_image_tools()
        self.plot = self.curvewidget.plot   
        x=np.linspace(-5,5,1000)        #Create some sample curves
        y1=np.cos(x)
        self.plot_item = make.mcurve(x, y1,label='Magnitude') #Make Ch1 curve
        self.plot.add_item(self.plot_item)
        self.plot.set_titles(title=title, xlabel=xlabel, ylabel=ylabel)
示例#10
0
文件: get_point.py 项目: HaMF/guiqwt
def get_point( *args ):
    """
    Plot curves and return selected point(s) coordinates
    """
    win = CurveDialog(_("Select one point then press OK to accept"), edit=True)
    default = win.add_tool(SelectPointTool, title="Test", on_active_item=True,
                           mode="create", end_callback=test_function)
    default.activate()
    plot = win.get_plot()
    for cx, cy in args:
        item = make.mcurve(cx, cy)
        plot.add_item(item)
    plot.set_active_item(item)
    win.show()
    if win.exec_():
        return default.get_coordinates()
示例#11
0
def semilogy(*args, **kwargs):
    """
    Plot curves with logarithmic y-axis scale
    
    Example:
        
    import numpy as np
    x = np.linspace(-5, 5, 1000)
    semilogy(x, np.sin(12*x), "g-")
    show()
    """
    axe = gca()
    axe.yscale = 'log'
    curve = make.mcurve(*args, **kwargs)
    axe.add_plot(curve)
    _show_if_interactive()
    return [curve]
示例#12
0
def semilogy(*args, **kwargs):
    """
    Plot curves with logarithmic y-axis scale
    
    Example:
        
    import numpy as np
    x = np.linspace(-5, 5, 1000)
    semilogy(x, np.sin(12*x), "g-")
    show()
    """
    axe = gca()
    axe.yscale = 'log'
    curve = make.mcurve(*args, **kwargs)
    axe.add_plot(curve)
    _show_if_interactive()
    return [curve]
示例#13
0
def loglog(*args, **kwargs):
    """
    Plot curves with logarithmic x-axis and y-axis scales
    
    Example::
        
        import numpy as np
        x = np.linspace(-5, 5, 1000)
        loglog(x, np.sin(12*x), "g-")
        show()
    """
    axe = gca()
    axe.xscale = "log"
    axe.yscale = "log"
    curve = make.mcurve(*args, **kwargs)
    axe.add_plot(curve)
    _show_if_interactive()
    return [curve]
示例#14
0
def get_point(*args):
    """
    Plot curves and return selected point(s) coordinates
    """
    win = CurveDialog(_("Select one point then press OK to accept"), edit=True)
    default = win.add_tool(SelectPointTool,
                           title="Test",
                           on_active_item=True,
                           mode="create",
                           end_callback=test_function)
    default.activate()
    plot = win.get_plot()
    for cx, cy in args:
        item = make.mcurve(cx, cy)
        plot.add_item(item)
    plot.set_active_item(item)
    win.show()
    if win.exec_():
        return default.get_coordinates()
示例#15
0
def plot(*args, **kwargs):
    """
    Plot curves
    
    Example:
    
    import numpy as np
    x = np.linspace(-5, 5, 1000)
    plot(x, np.sin(x), "r+")
    plot(x, np.cos(x), "g-")
    show()
    """
    axe = gca()
    curves = make.mcurve(*args, **kwargs)
    if not isinstance(curves, list):
        curves = [curves]
    for curve in curves:
        axe.add_plot(curve)
    _show_if_interactive()
    return curves
示例#16
0
def plot(*args, **kwargs):
    """
    Plot curves
    
    Example:
    
    import numpy as np
    x = np.linspace(-5, 5, 1000)
    plot(x, np.sin(x), "r+")
    plot(x, np.cos(x), "g-")
    show()
    """
    axe = gca()
    curves = make.mcurve(*args, **kwargs)
    if not isinstance(curves, list):
        curves = [curves]
    for curve in curves:
        axe.add_plot(curve)
    _show_if_interactive()
    return curves
示例#17
0
    def __init__(self):
        SlabWindow.__init__(self, nwa_DataThread, config_file=None)
        self.setupSlabWindow()
        self.register_script("run_script", self.go_button, self.abort_button)
        self.start_thread()

        #Connect controls
        self.connect(self.powerSpinBox, SIGNAL("valueChanged(double)"),
                lambda i: self.set_param("power", i))
        self.connect(self.sweep_ptsSpinBox, SIGNAL("valueChanged(int)"),
                lambda i: self.set_param("sweep_pts", i))
        self.connect(self.ifbwSpinBox, SIGNAL("valueChanged(double)"),
                lambda i: self.set_param("ifbw", i))               
        self.connect(self.avgsSpinBox, SIGNAL("valueChanged(int)"),
                lambda i: self.set_param("avgs", i)) 
        self.connect(self.centerstartSpinBox, SIGNAL("valueChanged(double)"),
                lambda i: self.set_param("centerstart", i)) 
        self.connect(self.spanstopSpinBox, SIGNAL("valueChanged(double)"),
                lambda i: self.set_param("spanstop", i)) 
        self.connect(self.centerspanstartstopCheckBox, SIGNAL("stateChanged(double)"),
                lambda i: self.set_param("centerspanstartstop", i)) 
        self.connect(self.saveCheckBox, SIGNAL("stateChanged(int)"),
                lambda i: self.set_param("save", i)) 
        self.connect(self.centerspanstartstopCheckBox, SIGNAL("stateChanged(int)"),self.on_centerspanstartstopChanged)

        self.connect(self.autoCheckBox, SIGNAL("stateChanged(int)"),
                lambda i: self.set_param("auto", i)) 
        self.connect(self.traceNumSpinBox, SIGNAL("valueChanged(int)"),
                lambda i: self.set_param("tracenum", i)) 

        
        self.exptpath='S:\\_Data\\'
        self.exptpathButton.clicked.connect(self.selectexptpath)
        self.exptpathLineEdit.textChanged.connect(self.update_filenumber)
        self.prefixLineEdit.textChanged.connect(self.update_filenumber)
        
        #Initialize Parameters
        self.set_param("power", -20)
        self.set_param("sweep_pts",1601)
        self.set_param("ifbw",1e3)
        self.set_param("avgs",1)
        self.set_param("centerstart",10.)
        self.set_param("spanstop",1000.)
        self.set_param("centerspanstartstop",1)
        self.set_param("save",0)
        self.set_param("exptpath",self.exptpath)
        self.set_param("prefix",'trace')
        self.set_param("filenumber",0)
        self.set_param("delay",0)
        
        self.set_param("tracenum",0)
        self.set_param("auto",True)

        #Proxy widgets into datathread
        self.plot_manager['tracenum']=self.traceNumSpinBox
        self.plot_manager['temperatureLabel']=self.temperatureLabel
        
        
        #Make some default data
        self.freqs=np.linspace(self.params['centerstart']-self.params['spanstop']/2.,self.params['centerstart']+self.params['spanstop']/2.,self.params['sweep_pts'])        
        self.mags=np.zeros(len(self.freqs)) 
        self.phases=np.zeros(len(self.freqs))
        
        #Initialize Plots
        self.plot_manager["dataplot"] = self.dataCurveWidget.plot        
        self.dataCurveWidget.add_toolbar(self.addToolBar("Curve"))
        self.dataCurveWidget.register_all_image_tools()
        self.plot_manager["dataplot"].set_titles(title="Data Curve", xlabel="Frequency (GHz)", ylabel="S21")       
        self.plot_manager["datacurve"] = make.mcurve(self.freqs, self.mags,label='Magnitude') #Make Ch1 curve
        self.plot_manager["dataplot"].add_item(self.plot_manager["datacurve"])
示例#18
0
    def __init__(self):
        SlabWindow.__init__(self, nwa_DataThread, config_file=None)
        self.setupSlabWindow()
        self.register_script("run_script", self.go_button, self.abort_button)
        self.start_thread()

        #Connect controls
        self.connect(self.powerSpinBox, SIGNAL("valueChanged(double)"),
                     lambda i: self.set_param("power", i))
        self.connect(self.sweep_ptsSpinBox, SIGNAL("valueChanged(int)"),
                     lambda i: self.set_param("sweep_pts", i))
        self.connect(self.ifbwSpinBox, SIGNAL("valueChanged(double)"),
                     lambda i: self.set_param("ifbw", i))
        self.connect(self.avgsSpinBox, SIGNAL("valueChanged(int)"),
                     lambda i: self.set_param("avgs", i))
        self.connect(self.centerstartSpinBox, SIGNAL("valueChanged(double)"),
                     lambda i: self.set_param("centerstart", i))
        self.connect(self.spanstopSpinBox, SIGNAL("valueChanged(double)"),
                     lambda i: self.set_param("spanstop", i))
        self.connect(self.centerspanstartstopCheckBox,
                     SIGNAL("stateChanged(double)"),
                     lambda i: self.set_param("centerspanstartstop", i))
        self.connect(self.saveCheckBox, SIGNAL("stateChanged(int)"),
                     lambda i: self.set_param("save", i))
        self.connect(self.centerspanstartstopCheckBox,
                     SIGNAL("stateChanged(int)"),
                     self.on_centerspanstartstopChanged)

        self.connect(self.autoCheckBox, SIGNAL("stateChanged(int)"),
                     lambda i: self.set_param("auto", i))
        self.connect(self.traceNumSpinBox, SIGNAL("valueChanged(int)"),
                     lambda i: self.set_param("tracenum", i))

        self.exptpath = 'S:\\_Data\\'
        self.exptpathButton.clicked.connect(self.selectexptpath)
        self.exptpathLineEdit.textChanged.connect(self.update_filenumber)
        self.prefixLineEdit.textChanged.connect(self.update_filenumber)

        #Initialize Parameters
        self.set_param("power", -20)
        self.set_param("sweep_pts", 1601)
        self.set_param("ifbw", 1e3)
        self.set_param("avgs", 1)
        self.set_param("centerstart", 10.)
        self.set_param("spanstop", 1000.)
        self.set_param("centerspanstartstop", 1)
        self.set_param("save", 0)
        self.set_param("exptpath", self.exptpath)
        self.set_param("prefix", 'trace')
        self.set_param("filenumber", 0)
        self.set_param("delay", 0)

        self.set_param("tracenum", 0)
        self.set_param("auto", True)

        #Proxy widgets into datathread
        self.plot_manager['tracenum'] = self.traceNumSpinBox
        self.plot_manager['temperatureLabel'] = self.temperatureLabel

        #Make some default data
        self.freqs = np.linspace(
            self.params['centerstart'] - self.params['spanstop'] / 2.,
            self.params['centerstart'] + self.params['spanstop'] / 2.,
            self.params['sweep_pts'])
        self.mags = np.zeros(len(self.freqs))
        self.phases = np.zeros(len(self.freqs))

        #Initialize Plots
        self.plot_manager["dataplot"] = self.dataCurveWidget.plot
        self.dataCurveWidget.add_toolbar(self.addToolBar("Curve"))
        self.dataCurveWidget.register_all_image_tools()
        self.plot_manager["dataplot"].set_titles(title="Data Curve",
                                                 xlabel="Frequency (GHz)",
                                                 ylabel="S21")
        self.plot_manager["datacurve"] = make.mcurve(
            self.freqs, self.mags, label='Magnitude')  #Make Ch1 curve
        self.plot_manager["dataplot"].add_item(self.plot_manager["datacurve"])