⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 specana.py

📁 对Spectrum Analyzer进行编辑
💻 PY
字号:
# specAna.py
#   Defines the SpecAna class
#
# Paul Lettieri
# Started March 2007
#
# $Id: specAna.py,v 1.1 2007/03/09 02:34:48 lettieri Exp $


try:
    import visa
except:
    print   '''WARNING: Could not import visa; either its not installed,
                or this computer does not have a GPIB card;  either way,
            '''


class SpecAna:
    '''Spectrum Analyzer Class

        Finds the first Rohde&Schwarz device on your GPIB,
        and assumes it to be a spectrum analyzer, which then
        may be programmed through various accessors.

        NOTE: Should be expanded to allow for other brands,
        and or other Rohde&Schwarz type devices
    '''
    def __init__(self):
        self.sa = []
        try:
            instr = visa.get_instruments_list()
            for i in instr:
                if i[:4]=='GPIB':
                    self.sa = visa.instrument(i)
                    if self.sa.ask("*IDN?")[:13] == 'Rohde&Schwarz':
                        break
                    self.sa.close()
            print "Found %s at %s" % (self.sa.ask("*IDN?"),i)
        except:
            print "WARNING: Could not locate a R&S spectrum analyzer"

    def close(self):
        if self.sa:
            self.sa.close()

    def setFreq(self,freq):
        if self.sa:
            self.sa.write("FREQ:CENT %f Hz" % freq)

    def setSpan(self,freq):
        if self.sa:
            self.sa.write("FREQ:SPAN %f Hz" % freq)

    def setAvg(self):
        if self.sa:
            self.sa.write("DISP:TRAC:MODE AVER")

    def getSweepTime(self):
        if self.sa:
            return self.sa.ask("SWE:TIME?")
        else:
            return 0

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -