comparison 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
comparison
equal deleted inserted replaced
29:12b6a3a0a481 30:9ce709b7da4b
1 # Docs are at http://ena.tm.agilent.com/e5071c/manuals/webhelp/eng/
2
3 import scpi
4 import pylab
5
6 # Connect
7 inst = scpi.instURL('vxi://203.31.81.47')
8
9 # Read ID
10 inst.write('*IDN?')
11 inst.read()
12 # 'Agilent Technologies,E5071C,MY46109815,A.09.54\n'
13
14 # Set to 8 byte floats
15 inst.write(":FORM:DATA REAL")
16
17 # Set to little endian
18 inst.write(':FORM:BORD SWAP')
19
20 # Grab frequency data
21 inst.write(":SENS1:FREQ:DATA?")
22 freqs = scpi.bindecode(inst.read(), dtype = numpy.float64)
23
24 # Grab trace data
25 inst.write(":CALC1:TRACE1:DATA:FDATA?")
26 dat = scpi.bindecode(inst.read(), dtype = numpy.float64)
27
28 # We only want the real part (no imag for this measurement)
29 dat = dat[::2]
30
31 # Save for later
32 numpy.savez('GS_preamp_20110929', freqs, dat)
33
34 # Load..
35 f = numpy.load('GS_preamp_20110929.npz')
36 freqs = f['arr_0']
37 dat = f['arr_1']
38
39 pylab.plot(freqs.dat)