view agilent_r5071.py @ 30:9ce709b7da4b

Add Q&D example code for Anritsu MS2034A and Agilent R5071.
author Daniel O'Connor <darius@dons.net.au>
date Wed, 21 Sep 2011 14:58:55 +0930
parents
children 6bd941d96c03
line wrap: on
line source

# Docs are at http://ena.tm.agilent.com/e5071c/manuals/webhelp/eng/

import scpi
import pylab

# Connect
inst = scpi.instURL('vxi://203.31.81.47')

# Read ID
inst.write('*IDN?')
inst.read()
# 'Agilent Technologies,E5071C,MY46109815,A.09.54\n'

# Set to 8 byte floats
inst.write(":FORM:DATA REAL")

# Set to little endian
inst.write(':FORM:BORD SWAP')

# Grab frequency data
inst.write(":SENS1:FREQ:DATA?")
freqs = scpi.bindecode(inst.read(), dtype = numpy.float64)

# Grab trace data
inst.write(":CALC1:TRACE1:DATA:FDATA?")
dat = scpi.bindecode(inst.read(), dtype = numpy.float64)

# We only want the real part (no imag for this measurement)
dat = dat[::2]

# Save for later
numpy.savez('GS_preamp_20110929', freqs, dat)

# Load..
f = numpy.load('GS_preamp_20110929.npz')
freqs = f['arr_0']
dat = f['arr_1']

pylab.plot(freqs.dat)