Since the resolution bandwidth is an essential value, it should by default be recorded when taking a trace
|
def MeasureScreen(self, ch=1): |
|
measmode = self.GetMode() |
|
yunit = self.GetUnit() |
|
if measmode == 'SAN': |
|
self.SetContinuous(False) |
|
self.write('INIT') |
|
# sleep for averaging time, otherwise timeout |
|
navg = self.GetAverages() |
|
tt = self.GetSweepTime() |
|
time.sleep(navg * tt) |
|
xvals = self.query('TRAC:DATA:X? TRACE{}'.format(ch)) |
|
yvals = self.query('TRAC? TRACE{}'.format(ch)) |
|
xvals = np.array([float(x) for x in xvals.split(',')]) |
|
yvals = np.array([float(x) for x in yvals.split(',')]) |
|
output = pd.DataFrame() |
|
output['Frequency (Hz)'] = xvals |
|
output['Spectrum (' + yunit + ')'] = yvals |
|
return output |
|
else: |
|
return KeyError('Instrument mode unknown!') |