annotate agilent_r5071.py @ 41:df1b4d7e988f

Reword text to be clearer.
author Daniel O'Connor <darius@dons.net.au>
date Wed, 28 Sep 2011 13:35:45 +0930
parents 9ce709b7da4b
children 6bd941d96c03
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
30
9ce709b7da4b Add Q&D example code for Anritsu MS2034A and Agilent R5071.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
1 # Docs are at http://ena.tm.agilent.com/e5071c/manuals/webhelp/eng/
9ce709b7da4b Add Q&D example code for Anritsu MS2034A and Agilent R5071.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
2
9ce709b7da4b Add Q&D example code for Anritsu MS2034A and Agilent R5071.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
3 import scpi
9ce709b7da4b Add Q&D example code for Anritsu MS2034A and Agilent R5071.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
4 import pylab
9ce709b7da4b Add Q&D example code for Anritsu MS2034A and Agilent R5071.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
5
9ce709b7da4b Add Q&D example code for Anritsu MS2034A and Agilent R5071.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
6 # Connect
9ce709b7da4b Add Q&D example code for Anritsu MS2034A and Agilent R5071.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
7 inst = scpi.instURL('vxi://203.31.81.47')
9ce709b7da4b Add Q&D example code for Anritsu MS2034A and Agilent R5071.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
8
9ce709b7da4b Add Q&D example code for Anritsu MS2034A and Agilent R5071.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
9 # Read ID
9ce709b7da4b Add Q&D example code for Anritsu MS2034A and Agilent R5071.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
10 inst.write('*IDN?')
9ce709b7da4b Add Q&D example code for Anritsu MS2034A and Agilent R5071.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
11 inst.read()
9ce709b7da4b Add Q&D example code for Anritsu MS2034A and Agilent R5071.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
12 # 'Agilent Technologies,E5071C,MY46109815,A.09.54\n'
9ce709b7da4b Add Q&D example code for Anritsu MS2034A and Agilent R5071.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
13
9ce709b7da4b Add Q&D example code for Anritsu MS2034A and Agilent R5071.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
14 # Set to 8 byte floats
9ce709b7da4b Add Q&D example code for Anritsu MS2034A and Agilent R5071.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
15 inst.write(":FORM:DATA REAL")
9ce709b7da4b Add Q&D example code for Anritsu MS2034A and Agilent R5071.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
16
9ce709b7da4b Add Q&D example code for Anritsu MS2034A and Agilent R5071.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
17 # Set to little endian
9ce709b7da4b Add Q&D example code for Anritsu MS2034A and Agilent R5071.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
18 inst.write(':FORM:BORD SWAP')
9ce709b7da4b Add Q&D example code for Anritsu MS2034A and Agilent R5071.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
19
9ce709b7da4b Add Q&D example code for Anritsu MS2034A and Agilent R5071.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
20 # Grab frequency data
9ce709b7da4b Add Q&D example code for Anritsu MS2034A and Agilent R5071.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
21 inst.write(":SENS1:FREQ:DATA?")
9ce709b7da4b Add Q&D example code for Anritsu MS2034A and Agilent R5071.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
22 freqs = scpi.bindecode(inst.read(), dtype = numpy.float64)
9ce709b7da4b Add Q&D example code for Anritsu MS2034A and Agilent R5071.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
23
9ce709b7da4b Add Q&D example code for Anritsu MS2034A and Agilent R5071.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
24 # Grab trace data
9ce709b7da4b Add Q&D example code for Anritsu MS2034A and Agilent R5071.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
25 inst.write(":CALC1:TRACE1:DATA:FDATA?")
9ce709b7da4b Add Q&D example code for Anritsu MS2034A and Agilent R5071.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
26 dat = scpi.bindecode(inst.read(), dtype = numpy.float64)
9ce709b7da4b Add Q&D example code for Anritsu MS2034A and Agilent R5071.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
27
9ce709b7da4b Add Q&D example code for Anritsu MS2034A and Agilent R5071.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
28 # We only want the real part (no imag for this measurement)
9ce709b7da4b Add Q&D example code for Anritsu MS2034A and Agilent R5071.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
29 dat = dat[::2]
9ce709b7da4b Add Q&D example code for Anritsu MS2034A and Agilent R5071.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
30
9ce709b7da4b Add Q&D example code for Anritsu MS2034A and Agilent R5071.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
31 # Save for later
9ce709b7da4b Add Q&D example code for Anritsu MS2034A and Agilent R5071.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
32 numpy.savez('GS_preamp_20110929', freqs, dat)
9ce709b7da4b Add Q&D example code for Anritsu MS2034A and Agilent R5071.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
33
9ce709b7da4b Add Q&D example code for Anritsu MS2034A and Agilent R5071.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
34 # Load..
9ce709b7da4b Add Q&D example code for Anritsu MS2034A and Agilent R5071.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
35 f = numpy.load('GS_preamp_20110929.npz')
9ce709b7da4b Add Q&D example code for Anritsu MS2034A and Agilent R5071.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
36 freqs = f['arr_0']
9ce709b7da4b Add Q&D example code for Anritsu MS2034A and Agilent R5071.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
37 dat = f['arr_1']
9ce709b7da4b Add Q&D example code for Anritsu MS2034A and Agilent R5071.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
38
9ce709b7da4b Add Q&D example code for Anritsu MS2034A and Agilent R5071.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
39 pylab.plot(freqs.dat)