Esempio n. 1
0
 def __init__(self,
              parent,
              cxn=None,
              path=[],
              dataset=None,
              toolbar=True,
              timer=None,
              settings={}):
     """
     A Qt widget that plots a labrad dataset, using Matplotlib.
     """
     # run qwidget init
     Qt.QWidget.__init__(self, parent)
     # create the qt basics
     self.figure = Figure()
     self.canvas = FigureCanvas(self.figure)
     self.canvas.setSizePolicy(Qt.QSizePolicy.Expanding,
                               Qt.QSizePolicy.Expanding)
     if toolbar:
         self.toolbar = NavigationToolbar(self.canvas, None)
     else:
         self.toolbar = None
     self.layout = Qt.QVBoxLayout()
     self.layout.addWidget(self.canvas)
     if self.toolbar:
         self.layout.addWidget(self.toolbar)
     self.setLayout(self.layout)
     self.groupBoxLayout = Qt.QHBoxLayout()
     self.layout.addLayout(self.groupBoxLayout)
     self.makeOptionsBox()
     self.groupBoxes = []
     self.settings = settings
     # matplotlib variables
     self.rebuildPlot = False
     self.subplots = []
     self.lines = []
     # labrad variables
     self.path = path
     self.dataset = dataset
     # start the labrad connection
     if cxn is None:
         import labrad
         cxnDef = labrad.connectAsync(name=labrad.util.getNodeName() +
                                      ' Plot Widget')
         cxnDef.addCallback(self.setCxn)
         self.cxn = None
     else:
         self.setCxn(cxn)
     # give us a timer
     if timer is None:
         self.updateTimer = Qt.QTimer()
         self.updateTimer.timeout.connect(self.timerFunc)
         self.waitingOnLabrad = True
         self.updateTimer.start(UPDATE_PERIOD * 1000)
     else:
         self.updateTimer = timer
         self.updateTimer.timeout.connect(self.timerFunc)
         self.waitinOnLabrad = True
Esempio n. 2
0
 def __init__(self, path=None):
     Qt.QMainWindow.__init__(self)
     self.init_qt()
     self.path = path
     try:
         import labrad
         cxnDef = labrad.connectAsync(name=labrad.util.getNodeName() + ' SuperMonitor')
     except AttributeError:
         import labrad.async
         cxnDef = labrad.async.connectAsync(name=labrad.util.getNodeName() + ' SuperMonitor')
Esempio n. 3
0
 def __init__(self, parent, cxn=None, path=[], dataset=None, toolbar=True, timer=None, settings={}):
     """
     A Qt widget that plots a labrad dataset, using Matplotlib.
     """
     # run qwidget init
     Qt.QWidget.__init__(self, parent)
     # create the qt basics
     self.figure = Figure()
     self.canvas = FigureCanvas(self.figure)
     self.canvas.setSizePolicy(Qt.QSizePolicy.Expanding, Qt.QSizePolicy.Expanding)
     if toolbar:
         self.toolbar = NavigationToolbar(self.canvas, None)
     else:
         self.toolbar = None
     self.layout = Qt.QVBoxLayout()
     self.layout.addWidget(self.canvas)
     if self.toolbar:
         self.layout.addWidget(self.toolbar)
     self.setLayout(self.layout)
     self.groupBoxLayout = Qt.QHBoxLayout()
     self.layout.addLayout(self.groupBoxLayout)
     self.makeOptionsBox()
     self.groupBoxes = []
     self.settings = settings
     # matplotlib variables
     self.rebuildPlot = False
     self.subplots = []
     self.lines = []
     # labrad variables
     self.path = path
     self.dataset = dataset
     # start the labrad connection
     if cxn is None:
         import labrad
         cxnDef = labrad.connectAsync(name=labrad.util.getNodeName() + ' Plot Widget')
         cxnDef.addCallback(self.setCxn)
         self.cxn = None
     else:
         self.setCxn(cxn)
     # give us a timer
     if timer is None:
         self.updateTimer = Qt.QTimer()
         self.updateTimer.timeout.connect(self.timerFunc)
         self.waitingOnLabrad=True
         self.updateTimer.start(UPDATE_PERIOD * 1000)
     else:
         self.updateTimer = timer
         self.updateTimer.timeout.connect(self.timerFunc)
         self.waitinOnLabrad=True
Esempio n. 4
0
 def err_cxn(self, failure):
     print "Connection failure!"
     message = "Could not connect to LabRAD:\n" + ':\n'.join(failure.getErrorMessage().split(':'))
     label = Qt.QLabel(message)
     label.setAlignment(QtCore.Qt.AlignHCenter)
     label.setStyleSheet("* {font-weight: bold; font-size: 15pt;}")
     self.setCentralWidget(label)
     # wait and do it again
     d = Deferred()
     reactor.callLater(1, d.callback, 1)
     yield d
     try:
         import labrad
         cxnDef = labrad.connectAsync(name=labrad.util.getNodeName() + ' SuperMonitor')
     except AttributeError:
         import labrad.async
Esempio n. 5
0
    def __init__(self,
                 parent,
                 cxn=None,
                 path=None,
                 dataset=None,
                 timer=None,
                 drLoggerName=None):
        """A Qt widget that plots a labrad dataset, using Matplotlib.

        Intended for use with the DR Logger.
        :param parent: Parent widget
        :param cxn: LabRAD connection
        :param list[str] path: data vault path
        :param str or int dataset: dataset name or number
        :param timer: Qt timer to use for updating--timeout signal is used.
            If None, create our own timer.
        :param str drLoggerName: name of the DR logger server to monitor
        """
        # run qwidget init
        Qt.QWidget.__init__(self, parent)
        # create the qt basics
        self.drLoggerName = drLoggerName
        self.drLoggerCounter = 0
        self.layout = Qt.QHBoxLayout(self)
        self.optionsLayout = Qt.QVBoxLayout()
        self.layout.addLayout(self.optionsLayout)
        self.makeOptionsBox()
        # the plots will be in a tabbed window thing
        self.tab = Qt.QTabWidget(self)
        self.layout.addWidget(self.tab)
        # labrad variables
        self.path = path if path is not None else []
        self.dataset = dataset
        self.waitingOnLabrad = False
        # start the labrad connection
        if cxn is None:
            self.ownCxn = True
            import labrad
            import labrad.util
            try:
                cxnDef = labrad.connectAsync(name=labrad.util.getNodeName() +
                                             ' Plot Widget')
            except AttributeError:
                import labrad. async
                cxnDef = labrad. async .connectAsync(
                    name=labrad.util.getNodeName() + ' Plot Widget')
Esempio n. 6
0
    def __init__(self, parent, cxn=None, path=None, dataset=None, timer=None, drLoggerName=None):
        """A Qt widget that plots a labrad dataset, using Matplotlib.

        Intended for use with the DR Logger.
        :param parent: Parent widget
        :param cxn: LabRAD connection
        :param list[str] path: data vault path
        :param str or int dataset: dataset name or number
        :param timer: Qt timer to use for updating--timeout signal is used.
            If None, create our own timer.
        :param str drLoggerName: name of the DR logger server to monitor
        """
        # run qwidget init
        Qt.QWidget.__init__(self, parent)
        # create the qt basics
        self.drLoggerName = drLoggerName
        self.drLoggerCounter = 0
        self.layout = Qt.QHBoxLayout(self)
        self.optionsLayout = Qt.QVBoxLayout()
        self.layout.addLayout(self.optionsLayout)
        self.makeOptionsBox()
        # the plots will be in a tabbed window thing
        self.tab = Qt.QTabWidget(self)
        self.layout.addWidget(self.tab)
        # labrad variables
        self.path = path if path is not None else []
        self.dataset = dataset
        self.waitingOnLabrad = False
        # start the labrad connection
        if cxn is None:
            self.ownCxn = True
            import labrad
            import labrad.util
            try:
                cxnDef = labrad.connectAsync(name=labrad.util.getNodeName() + ' Plot Widget')
            except AttributeError:
                import labrad.async
                cxnDef = labrad.async.connectAsync(name=labrad.util.getNodeName() + ' Plot Widget')
Esempio n. 7
0
def DACcorrectorAsync(fpganame,
                      channel,
                      connection=None,
                      lowpass=gaussfilter,
                      bandwidth=0.13,
                      errorClass='quiet'):
    """
    Returns a DACcorrection object for the given DAC board.
    The argument has the same form as the
    dms.python_fpga_server.connect argument
    """
    if connection:
        cxn = connection
    else:
        cxn = yield labrad.connectAsync()

    ds = cxn.data_vault
    ctx = ds.context()

    yield ds.cd(['', keys.SESSIONNAME, fpganame], True, context=ctx)

    corrector = DACcorrection(fpganame, channel, lowpass, bandwidth)

    if not isinstance(channel, str):
        channel = keys.CHANNELNAMES[channel]

    dataset = yield getDataSets(cxn, fpganame, channel, errorClass)
    if dataset != []:
        dataset = dataset[0]
        print 'Loading pulse calibration from %s.' % dataset
        yield ds.open(dataset, context=ctx)
        datapoints = (yield ds.get(context=ctx)).asarray
        corrector.loadCal(datapoints)
    if not connection:
        yield cxn.disconnect()

    returnValue(corrector)
Esempio n. 8
0
def IQcorrectorAsync(fpganame,
                     connection,
                     zerocor=True,
                     pulsecor=True,
                     iqcor=True,
                     lowpass=cosinefilter,
                     bandwidth=0.4,
                     errorClass='quiet'):
    """
    Returns a DACcorrection object for the given DAC board.
    The argument has the same form as the
    dms.python_fpga_server.connect argument
    """
    if connection:
        cxn = connection
    else:
        cxn = yield labrad.connectAsync()

    ds = cxn.data_vault
    ctx = ds.context()

    yield ds.cd(['', keys.SESSIONNAME, fpganame], True, context=ctx)

    corrector = IQcorrection(fpganame, lowpass, bandwidth)

    # Load Zero Calibration
    if zerocor:
        datasets = yield getDataSets(cxn, fpganame, keys.ZERONAME, errorClass)
        for dataset in datasets:
            filename = yield ds.open(dataset, context=ctx)
            print 'Loading zero calibration from %s:' % filename[1]
            datapoints = (yield ds.get(context=ctx)).asarray
            corrector.loadZeroCal(datapoints, dataset)

    #Load pulse response
    if pulsecor:
        dataset = yield getDataSets(cxn, fpganame, keys.PULSENAME, errorClass)
        if dataset != []:
            dataset = dataset[0]
            filename = yield ds.open(dataset, context=ctx)
            print 'Loading pulse calibration from %s:' % filename[1]
            setupType = yield ds.get_parameter(keys.IQWIRING, context=ctx)
            print '  %s' % setupType
            IisB = (setupType == keys.SETUPTYPES[2])
            datapoints = (yield ds.get(context=ctx)).asarray
            carrierfreq = (yield ds.get_parameter(keys.PULSECARRIERFREQ,
                                                  context=ctx))['GHz']
            corrector.loadPulseCal(datapoints, carrierfreq, dataset, IisB)

    # Load Sideband Calibration
    if iqcor:
        datasets = yield getDataSets(cxn, fpganame, keys.IQNAME, errorClass)
        for dataset in datasets:
            filename = yield ds.open(dataset, context=ctx)
            print 'Loading sideband calibration from %s:' % filename[1]
            sidebandStep = \
                (yield ds.get_parameter('Sideband frequency step',
                                        context=ctx))['GHz']
            sidebandCount = \
                yield ds.get_parameter('Number of sideband frequencies',
                                        context=ctx)
            datapoints = (yield ds.get(context=ctx)).asarray
            corrector.loadSidebandCal(datapoints, sidebandStep, dataset)

    if not connection:
        yield cxn.disconnect()

    returnValue(corrector)
Esempio n. 9
0
def recalibrateAsync(boardname,
                     carrierMin,
                     carrierMax,
                     zeroCarrierStep=0.025,
                     sidebandCarrierStep=0.05,
                     sidebandMax=0.35,
                     sidebandStep=0.05,
                     corrector=None):
    cxn = yield labrad.connectAsync()
    ds = cxn.data_vault
    reg = cxn.registry
    reg.cd(['', keys.SESSIONNAME, boardname])
    anritsuID = yield reg.get(keys.ANRITSUID)
    anritsuPower = (yield reg.get(keys.ANRITSUPOWER))['dBm']
    if corrector is None:
        corrector = yield IQcorrectorAsync(boardname, cxn)
    if corrector.board != boardname:
        print 'Provided corrector is not for %s.' % boardname
        print 'Loading new corrector. Provided corrector will not be updated.'
        corrector = yield IQcorrectorAsync(boardname, cxn)

    if zeroCarrierStep is not None:
        #check if a corrector has been provided and if it is up to date
        #or if we have to load a new one.
        if not aequal(
                corrector.zeroCalFiles,
            (yield getDataSets(cxn, boardname, keys.ZERONAME, 'quiet'))):
            print 'Provided correcetor is outdated.'
            print 'Loading new corrector. Provided corrector will not be updated.'
            corrector = yield IQcorrectorAsync(boardname, cxn)

        # do the zero calibration
        dataset = yield calibrate.zeroScanCarrier(
            cxn, {
                'carrierMin': carrierMin,
                'carrierMax': carrierMax,
                'carrierStep': zeroCarrierStep
            }, boardname)
        # load it into the corrector
        yield ds.open(dataset)
        datapoints = (yield ds.get()).asarray
        corrector.loadZeroCal(datapoints, dataset)
        # eliminate obsolete zero calibrations
        datasets = corrector.eliminateZeroCals()
        # and save which ones are being used now
        yield reg.cd(['', keys.SESSIONNAME, boardname], True)
        yield reg.set(keys.ZERONAME, datasets)
    if sidebandCarrierStep is not None:
        #check if a corrector has been provided and if it is up to date
        #or if we have to load a new one.
        if not (aequal(corrector.sidebandCalFiles,
          (yield getDataSets(cxn, boardname, keys.IQNAME, 'quiet'))) and \
          aequal(array([corrector.pulseCalFile]),
               (yield getDataSets(cxn, boardname, keys.PULSENAME, 'quiet')))):
            print 'Provided correcetor is outdated.'
            print 'Loading new corrector. Provided corrector will not be updated.'
            corrector = yield IQcorrectorAsync(boardname, cxn)

        # do the pulse calibration
        dataset = yield calibrate.sidebandScanCarrier(
            cxn, {
                'carrierMin': carrierMin,
                'carrierMax': carrierMax,
                'sidebandCarrierStep': sidebandCarrierStep,
                'sidebandFreqStep': sidebandStep,
                'sidebandFreqCount': int(sidebandMax / sidebandStep + 0.5) * 2
            }, boardname, corrector)
        # load it into the corrector
        yield ds.open(dataset)
        sidebandStep = \
            (yield ds.get_parameter('Sideband frequency step'))['GHz']
        sidebandCount = \
            yield ds.get_parameter('Number of sideband frequencies')
        datapoints = (yield ds.get()).asarray
        corrector.loadSidebandCal(datapoints, sidebandStep, dataset)
        # eliminate obsolete zero calibrations
        datasets = corrector.eliminateSidebandCals()
        # and save which ones are being used now
        yield reg.cd(['', keys.SESSIONNAME, boardname], True)
        yield reg.set(keys.IQNAME, datasets)
    cxn.disconnect()
    returnValue(corrector)