HP3562A/coord_decoder.py

Fri, 21 Dec 2007 23:51:36 +0100

author
David Douard <david.douard@logilab.fr>
date
Fri, 21 Dec 2007 23:51:36 +0100
changeset 18
c691b040e8c9
parent 16
de9122b5680a
permissions
-rw-r--r--

added a (very) beginning HPGL parser (with a simplist matplotlib backend)

16
de9122b5680a Several improvements (code refactoring) + add stuff to decode binary coordinate data block ("DCBN" command)
David Douard <david.douard@logilab.fr>
parents:
diff changeset
1 # -*- coding: utf-8 -*-
de9122b5680a Several improvements (code refactoring) + add stuff to decode binary coordinate data block ("DCBN" command)
David Douard <david.douard@logilab.fr>
parents:
diff changeset
2 """
de9122b5680a Several improvements (code refactoring) + add stuff to decode binary coordinate data block ("DCBN" command)
David Douard <david.douard@logilab.fr>
parents:
diff changeset
3 state_decoder
de9122b5680a Several improvements (code refactoring) + add stuff to decode binary coordinate data block ("DCBN" command)
David Douard <david.douard@logilab.fr>
parents:
diff changeset
4 =============
de9122b5680a Several improvements (code refactoring) + add stuff to decode binary coordinate data block ("DCBN" command)
David Douard <david.douard@logilab.fr>
parents:
diff changeset
5
de9122b5680a Several improvements (code refactoring) + add stuff to decode binary coordinate data block ("DCBN" command)
David Douard <david.douard@logilab.fr>
parents:
diff changeset
6 Module for decoding the internal state of the HP3562A DSA, using the
de9122b5680a Several improvements (code refactoring) + add stuff to decode binary coordinate data block ("DCBN" command)
David Douard <david.douard@logilab.fr>
parents:
diff changeset
7 GPIB command "DSBN" (Dump State BiNary).
de9122b5680a Several improvements (code refactoring) + add stuff to decode binary coordinate data block ("DCBN" command)
David Douard <david.douard@logilab.fr>
parents:
diff changeset
8
de9122b5680a Several improvements (code refactoring) + add stuff to decode binary coordinate data block ("DCBN" command)
David Douard <david.douard@logilab.fr>
parents:
diff changeset
9 This file can be exectued as a python script. Use '-h' for more informations.
de9122b5680a Several improvements (code refactoring) + add stuff to decode binary coordinate data block ("DCBN" command)
David Douard <david.douard@logilab.fr>
parents:
diff changeset
10 """
de9122b5680a Several improvements (code refactoring) + add stuff to decode binary coordinate data block ("DCBN" command)
David Douard <david.douard@logilab.fr>
parents:
diff changeset
11
de9122b5680a Several improvements (code refactoring) + add stuff to decode binary coordinate data block ("DCBN" command)
David Douard <david.douard@logilab.fr>
parents:
diff changeset
12 from HP3562A import format_header, decode_float, decode_string, decode_header, read_trace
de9122b5680a Several improvements (code refactoring) + add stuff to decode binary coordinate data block ("DCBN" command)
David Douard <david.douard@logilab.fr>
parents:
diff changeset
13 from HP3562A.trace_decoder import decode_trace, HEADER as TRACE_HEADER
de9122b5680a Several improvements (code refactoring) + add stuff to decode binary coordinate data block ("DCBN" command)
David Douard <david.douard@logilab.fr>
parents:
diff changeset
14 from HP3562A.enum_types import *
de9122b5680a Several improvements (code refactoring) + add stuff to decode binary coordinate data block ("DCBN" command)
David Douard <david.douard@logilab.fr>
parents:
diff changeset
15
de9122b5680a Several improvements (code refactoring) + add stuff to decode binary coordinate data block ("DCBN" command)
David Douard <david.douard@logilab.fr>
parents:
diff changeset
16 HEADER = [("Y coordinates", EYCOORD, 'h', 2),
de9122b5680a Several improvements (code refactoring) + add stuff to decode binary coordinate data block ("DCBN" command)
David Douard <david.douard@logilab.fr>
parents:
diff changeset
17 ("# of disp elements", int, "h", 2),
de9122b5680a Several improvements (code refactoring) + add stuff to decode binary coordinate data block ("DCBN" command)
David Douard <david.douard@logilab.fr>
parents:
diff changeset
18 ("First element", int, "h", 2),
de9122b5680a Several improvements (code refactoring) + add stuff to decode binary coordinate data block ("DCBN" command)
David Douard <david.douard@logilab.fr>
parents:
diff changeset
19 ("Total elements", int, 'h', 2),
de9122b5680a Several improvements (code refactoring) + add stuff to decode binary coordinate data block ("DCBN" command)
David Douard <david.douard@logilab.fr>
parents:
diff changeset
20 ("Display sampling", EDISPSMP, 'h', 2),
de9122b5680a Several improvements (code refactoring) + add stuff to decode binary coordinate data block ("DCBN" command)
David Douard <david.douard@logilab.fr>
parents:
diff changeset
21 ("Scaling", ESCAL, 'h', 2),
de9122b5680a Several improvements (code refactoring) + add stuff to decode binary coordinate data block ("DCBN" command)
David Douard <david.douard@logilab.fr>
parents:
diff changeset
22 ("Data pointer", long, 'l', 4),
de9122b5680a Several improvements (code refactoring) + add stuff to decode binary coordinate data block ("DCBN" command)
David Douard <david.douard@logilab.fr>
parents:
diff changeset
23 ("In data", long, 'l', 4),
de9122b5680a Several improvements (code refactoring) + add stuff to decode binary coordinate data block ("DCBN" command)
David Douard <david.douard@logilab.fr>
parents:
diff changeset
24 ("Log/linear x-axis", bool, 'h', 2),
de9122b5680a Several improvements (code refactoring) + add stuff to decode binary coordinate data block ("DCBN" command)
David Douard <david.douard@logilab.fr>
parents:
diff changeset
25 ("Sampled display data", bool, 'h', 2),
de9122b5680a Several improvements (code refactoring) + add stuff to decode binary coordinate data block ("DCBN" command)
David Douard <david.douard@logilab.fr>
parents:
diff changeset
26 ("Plot/Graph mode", bool, 'h', 2),
de9122b5680a Several improvements (code refactoring) + add stuff to decode binary coordinate data block ("DCBN" command)
David Douard <david.douard@logilab.fr>
parents:
diff changeset
27 ("Phase wrap", bool, 'h', 2),
de9122b5680a Several improvements (code refactoring) + add stuff to decode binary coordinate data block ("DCBN" command)
David Douard <david.douard@logilab.fr>
parents:
diff changeset
28 ("Not used", None, None, 36),
de9122b5680a Several improvements (code refactoring) + add stuff to decode binary coordinate data block ("DCBN" command)
David Douard <david.douard@logilab.fr>
parents:
diff changeset
29 ("X scale factor", decode_float, None, 4),
de9122b5680a Several improvements (code refactoring) + add stuff to decode binary coordinate data block ("DCBN" command)
David Douard <david.douard@logilab.fr>
parents:
diff changeset
30 ("Grid min Y scale", decode_float, None, 4),
de9122b5680a Several improvements (code refactoring) + add stuff to decode binary coordinate data block ("DCBN" command)
David Douard <david.douard@logilab.fr>
parents:
diff changeset
31 ("Grid max Y scale", decode_float, None, 4),
de9122b5680a Several improvements (code refactoring) + add stuff to decode binary coordinate data block ("DCBN" command)
David Douard <david.douard@logilab.fr>
parents:
diff changeset
32 ("/div", decode_float, None, 4),
de9122b5680a Several improvements (code refactoring) + add stuff to decode binary coordinate data block ("DCBN" command)
David Douard <david.douard@logilab.fr>
parents:
diff changeset
33 ("Min value of data", decode_float, None, 4),
de9122b5680a Several improvements (code refactoring) + add stuff to decode binary coordinate data block ("DCBN" command)
David Douard <david.douard@logilab.fr>
parents:
diff changeset
34 ("Max value of data", decode_float, None, 4),
de9122b5680a Several improvements (code refactoring) + add stuff to decode binary coordinate data block ("DCBN" command)
David Douard <david.douard@logilab.fr>
parents:
diff changeset
35 ("Y cumulative min", decode_float, None, 4),
de9122b5680a Several improvements (code refactoring) + add stuff to decode binary coordinate data block ("DCBN" command)
David Douard <david.douard@logilab.fr>
parents:
diff changeset
36 ("Y cumulative max", decode_float, None, 4),
de9122b5680a Several improvements (code refactoring) + add stuff to decode binary coordinate data block ("DCBN" command)
David Douard <david.douard@logilab.fr>
parents:
diff changeset
37 ("Y scale factor", decode_float, None, 4),
de9122b5680a Several improvements (code refactoring) + add stuff to decode binary coordinate data block ("DCBN" command)
David Douard <david.douard@logilab.fr>
parents:
diff changeset
38 ("Not used", None, None, 16),
de9122b5680a Several improvements (code refactoring) + add stuff to decode binary coordinate data block ("DCBN" command)
David Douard <david.douard@logilab.fr>
parents:
diff changeset
39 ("Stop value", decode_float, None, 8),
de9122b5680a Several improvements (code refactoring) + add stuff to decode binary coordinate data block ("DCBN" command)
David Douard <david.douard@logilab.fr>
parents:
diff changeset
40 ("Left grid", decode_float, None, 8),
de9122b5680a Several improvements (code refactoring) + add stuff to decode binary coordinate data block ("DCBN" command)
David Douard <david.douard@logilab.fr>
parents:
diff changeset
41 ("Right grid", decode_float, None, 8),
de9122b5680a Several improvements (code refactoring) + add stuff to decode binary coordinate data block ("DCBN" command)
David Douard <david.douard@logilab.fr>
parents:
diff changeset
42 ("Left data", decode_float, None, 8),
de9122b5680a Several improvements (code refactoring) + add stuff to decode binary coordinate data block ("DCBN" command)
David Douard <david.douard@logilab.fr>
parents:
diff changeset
43 ("Right data", decode_float, None, 8),
de9122b5680a Several improvements (code refactoring) + add stuff to decode binary coordinate data block ("DCBN" command)
David Douard <david.douard@logilab.fr>
parents:
diff changeset
44 ]
de9122b5680a Several improvements (code refactoring) + add stuff to decode binary coordinate data block ("DCBN" command)
David Douard <david.douard@logilab.fr>
parents:
diff changeset
45
de9122b5680a Several improvements (code refactoring) + add stuff to decode binary coordinate data block ("DCBN" command)
David Douard <david.douard@logilab.fr>
parents:
diff changeset
46 def decode_coord(data):
de9122b5680a Several improvements (code refactoring) + add stuff to decode binary coordinate data block ("DCBN" command)
David Douard <david.douard@logilab.fr>
parents:
diff changeset
47 """
de9122b5680a Several improvements (code refactoring) + add stuff to decode binary coordinate data block ("DCBN" command)
David Douard <david.douard@logilab.fr>
parents:
diff changeset
48 Decode the data (as generated by the HP3562A DSA in response to a
de9122b5680a Several improvements (code refactoring) + add stuff to decode binary coordinate data block ("DCBN" command)
David Douard <david.douard@logilab.fr>
parents:
diff changeset
49 "DSBN" command), and returns a dict (header)
de9122b5680a Several improvements (code refactoring) + add stuff to decode binary coordinate data block ("DCBN" command)
David Douard <david.douard@logilab.fr>
parents:
diff changeset
50
de9122b5680a Several improvements (code refactoring) + add stuff to decode binary coordinate data block ("DCBN" command)
David Douard <david.douard@logilab.fr>
parents:
diff changeset
51 header is the dictionnary of the header of the dumped data block,
de9122b5680a Several improvements (code refactoring) + add stuff to decode binary coordinate data block ("DCBN" command)
David Douard <david.douard@logilab.fr>
parents:
diff changeset
52 """
de9122b5680a Several improvements (code refactoring) + add stuff to decode binary coordinate data block ("DCBN" command)
David Douard <david.douard@logilab.fr>
parents:
diff changeset
53 header, idx = decode_header(data, HEADER)
de9122b5680a Several improvements (code refactoring) + add stuff to decode binary coordinate data block ("DCBN" command)
David Douard <david.douard@logilab.fr>
parents:
diff changeset
54 trace_header, idx = decode_header(data, TRACE_HEADER, idx)
de9122b5680a Several improvements (code refactoring) + add stuff to decode binary coordinate data block ("DCBN" command)
David Douard <david.douard@logilab.fr>
parents:
diff changeset
55 trace = read_trace(data, idx, trace_header["Number of elements"])
de9122b5680a Several improvements (code refactoring) + add stuff to decode binary coordinate data block ("DCBN" command)
David Douard <david.douard@logilab.fr>
parents:
diff changeset
56 return header, trace_header, trace
de9122b5680a Several improvements (code refactoring) + add stuff to decode binary coordinate data block ("DCBN" command)
David Douard <david.douard@logilab.fr>
parents:
diff changeset
57
de9122b5680a Several improvements (code refactoring) + add stuff to decode binary coordinate data block ("DCBN" command)
David Douard <david.douard@logilab.fr>
parents:
diff changeset
58
de9122b5680a Several improvements (code refactoring) + add stuff to decode binary coordinate data block ("DCBN" command)
David Douard <david.douard@logilab.fr>
parents:
diff changeset
59 def main():
de9122b5680a Several improvements (code refactoring) + add stuff to decode binary coordinate data block ("DCBN" command)
David Douard <david.douard@logilab.fr>
parents:
diff changeset
60 import sys
de9122b5680a Several improvements (code refactoring) + add stuff to decode binary coordinate data block ("DCBN" command)
David Douard <david.douard@logilab.fr>
parents:
diff changeset
61 import optparse
de9122b5680a Several improvements (code refactoring) + add stuff to decode binary coordinate data block ("DCBN" command)
David Douard <david.douard@logilab.fr>
parents:
diff changeset
62 import numpy
de9122b5680a Several improvements (code refactoring) + add stuff to decode binary coordinate data block ("DCBN" command)
David Douard <david.douard@logilab.fr>
parents:
diff changeset
63
de9122b5680a Several improvements (code refactoring) + add stuff to decode binary coordinate data block ("DCBN" command)
David Douard <david.douard@logilab.fr>
parents:
diff changeset
64 opt = optparse.OptionParser("A simple tool for displaying dumped coord data block")
de9122b5680a Several improvements (code refactoring) + add stuff to decode binary coordinate data block ("DCBN" command)
David Douard <david.douard@logilab.fr>
parents:
diff changeset
65 opt.add_option('-f', '--filename', default=None,
de9122b5680a Several improvements (code refactoring) + add stuff to decode binary coordinate data block ("DCBN" command)
David Douard <david.douard@logilab.fr>
parents:
diff changeset
66 dest='filename',
de9122b5680a Several improvements (code refactoring) + add stuff to decode binary coordinate data block ("DCBN" command)
David Douard <david.douard@logilab.fr>
parents:
diff changeset
67 help='Output filename. If not set, read from stdin')
de9122b5680a Several improvements (code refactoring) + add stuff to decode binary coordinate data block ("DCBN" command)
David Douard <david.douard@logilab.fr>
parents:
diff changeset
68 opt.add_option('-m', '--mode', default='binary',
de9122b5680a Several improvements (code refactoring) + add stuff to decode binary coordinate data block ("DCBN" command)
David Douard <david.douard@logilab.fr>
parents:
diff changeset
69 dest='mode',
de9122b5680a Several improvements (code refactoring) + add stuff to decode binary coordinate data block ("DCBN" command)
David Douard <david.douard@logilab.fr>
parents:
diff changeset
70 help='Dumping mode (may be "binary" [default], "ascii" or "ansi")',
de9122b5680a Several improvements (code refactoring) + add stuff to decode binary coordinate data block ("DCBN" command)
David Douard <david.douard@logilab.fr>
parents:
diff changeset
71 )
de9122b5680a Several improvements (code refactoring) + add stuff to decode binary coordinate data block ("DCBN" command)
David Douard <david.douard@logilab.fr>
parents:
diff changeset
72 opt.add_option('-d', '--display-header', default=False,
de9122b5680a Several improvements (code refactoring) + add stuff to decode binary coordinate data block ("DCBN" command)
David Douard <david.douard@logilab.fr>
parents:
diff changeset
73 action="store_true",
de9122b5680a Several improvements (code refactoring) + add stuff to decode binary coordinate data block ("DCBN" command)
David Douard <david.douard@logilab.fr>
parents:
diff changeset
74 dest="displayheader",
de9122b5680a Several improvements (code refactoring) + add stuff to decode binary coordinate data block ("DCBN" command)
David Douard <david.douard@logilab.fr>
parents:
diff changeset
75 help="Display the trace header")
de9122b5680a Several improvements (code refactoring) + add stuff to decode binary coordinate data block ("DCBN" command)
David Douard <david.douard@logilab.fr>
parents:
diff changeset
76 opt.add_option('-P', '--noplot-trace', default=True,
de9122b5680a Several improvements (code refactoring) + add stuff to decode binary coordinate data block ("DCBN" command)
David Douard <david.douard@logilab.fr>
parents:
diff changeset
77 action="store_false",
de9122b5680a Several improvements (code refactoring) + add stuff to decode binary coordinate data block ("DCBN" command)
David Douard <david.douard@logilab.fr>
parents:
diff changeset
78 dest="plot",
de9122b5680a Several improvements (code refactoring) + add stuff to decode binary coordinate data block ("DCBN" command)
David Douard <david.douard@logilab.fr>
parents:
diff changeset
79 help="Do not display the plot of the trace")
de9122b5680a Several improvements (code refactoring) + add stuff to decode binary coordinate data block ("DCBN" command)
David Douard <david.douard@logilab.fr>
parents:
diff changeset
80 opt.add_option('-x', '--xmode', default='lin',
de9122b5680a Several improvements (code refactoring) + add stuff to decode binary coordinate data block ("DCBN" command)
David Douard <david.douard@logilab.fr>
parents:
diff changeset
81 dest='xmode',
de9122b5680a Several improvements (code refactoring) + add stuff to decode binary coordinate data block ("DCBN" command)
David Douard <david.douard@logilab.fr>
parents:
diff changeset
82 help='X coordinate mode (may be "lin" [default] or "log")')
de9122b5680a Several improvements (code refactoring) + add stuff to decode binary coordinate data block ("DCBN" command)
David Douard <david.douard@logilab.fr>
parents:
diff changeset
83 opt.add_option('-y', '--ymode', default='lin',
de9122b5680a Several improvements (code refactoring) + add stuff to decode binary coordinate data block ("DCBN" command)
David Douard <david.douard@logilab.fr>
parents:
diff changeset
84 dest='ymode',
de9122b5680a Several improvements (code refactoring) + add stuff to decode binary coordinate data block ("DCBN" command)
David Douard <david.douard@logilab.fr>
parents:
diff changeset
85 help='Y coordinate mode (may be "lin" [default], "log" or "db")')
de9122b5680a Several improvements (code refactoring) + add stuff to decode binary coordinate data block ("DCBN" command)
David Douard <david.douard@logilab.fr>
parents:
diff changeset
86
de9122b5680a Several improvements (code refactoring) + add stuff to decode binary coordinate data block ("DCBN" command)
David Douard <david.douard@logilab.fr>
parents:
diff changeset
87 options, argv = opt.parse_args(sys.argv)
de9122b5680a Several improvements (code refactoring) + add stuff to decode binary coordinate data block ("DCBN" command)
David Douard <david.douard@logilab.fr>
parents:
diff changeset
88
de9122b5680a Several improvements (code refactoring) + add stuff to decode binary coordinate data block ("DCBN" command)
David Douard <david.douard@logilab.fr>
parents:
diff changeset
89
de9122b5680a Several improvements (code refactoring) + add stuff to decode binary coordinate data block ("DCBN" command)
David Douard <david.douard@logilab.fr>
parents:
diff changeset
90 if options.filename is None:
de9122b5680a Several improvements (code refactoring) + add stuff to decode binary coordinate data block ("DCBN" command)
David Douard <david.douard@logilab.fr>
parents:
diff changeset
91 print "Can't deal stdin for now..."
de9122b5680a Several improvements (code refactoring) + add stuff to decode binary coordinate data block ("DCBN" command)
David Douard <david.douard@logilab.fr>
parents:
diff changeset
92 sys.exit(1)
de9122b5680a Several improvements (code refactoring) + add stuff to decode binary coordinate data block ("DCBN" command)
David Douard <david.douard@logilab.fr>
parents:
diff changeset
93 try:
de9122b5680a Several improvements (code refactoring) + add stuff to decode binary coordinate data block ("DCBN" command)
David Douard <david.douard@logilab.fr>
parents:
diff changeset
94 coord_header, header, data = decode_coord(open(options.filename, 'rb').read())
de9122b5680a Several improvements (code refactoring) + add stuff to decode binary coordinate data block ("DCBN" command)
David Douard <david.douard@logilab.fr>
parents:
diff changeset
95 except Exception, e:
de9122b5680a Several improvements (code refactoring) + add stuff to decode binary coordinate data block ("DCBN" command)
David Douard <david.douard@logilab.fr>
parents:
diff changeset
96 print "ERROR: can't read %s an interpret it as a HP3562 trace"%options.filename
de9122b5680a Several improvements (code refactoring) + add stuff to decode binary coordinate data block ("DCBN" command)
David Douard <david.douard@logilab.fr>
parents:
diff changeset
97 print e
de9122b5680a Several improvements (code refactoring) + add stuff to decode binary coordinate data block ("DCBN" command)
David Douard <david.douard@logilab.fr>
parents:
diff changeset
98 sys.exit(1)
de9122b5680a Several improvements (code refactoring) + add stuff to decode binary coordinate data block ("DCBN" command)
David Douard <david.douard@logilab.fr>
parents:
diff changeset
99
de9122b5680a Several improvements (code refactoring) + add stuff to decode binary coordinate data block ("DCBN" command)
David Douard <david.douard@logilab.fr>
parents:
diff changeset
100 if options.displayheader:
de9122b5680a Several improvements (code refactoring) + add stuff to decode binary coordinate data block ("DCBN" command)
David Douard <david.douard@logilab.fr>
parents:
diff changeset
101 print format_header(coord_header, HEADER, 100)
de9122b5680a Several improvements (code refactoring) + add stuff to decode binary coordinate data block ("DCBN" command)
David Douard <david.douard@logilab.fr>
parents:
diff changeset
102 print format_header(header, TRACE_HEADER, 100)
de9122b5680a Several improvements (code refactoring) + add stuff to decode binary coordinate data block ("DCBN" command)
David Douard <david.douard@logilab.fr>
parents:
diff changeset
103 if options.plot:
de9122b5680a Several improvements (code refactoring) + add stuff to decode binary coordinate data block ("DCBN" command)
David Douard <david.douard@logilab.fr>
parents:
diff changeset
104 f0 = header['Start freq value']
de9122b5680a Several improvements (code refactoring) + add stuff to decode binary coordinate data block ("DCBN" command)
David Douard <david.douard@logilab.fr>
parents:
diff changeset
105 dx = header['Delta X-axis']
de9122b5680a Several improvements (code refactoring) + add stuff to decode binary coordinate data block ("DCBN" command)
David Douard <david.douard@logilab.fr>
parents:
diff changeset
106 n = header['Number of elements']
de9122b5680a Several improvements (code refactoring) + add stuff to decode binary coordinate data block ("DCBN" command)
David Douard <david.douard@logilab.fr>
parents:
diff changeset
107 x = numpy.linspace(f0, f0+dx*n, len(data))
de9122b5680a Several improvements (code refactoring) + add stuff to decode binary coordinate data block ("DCBN" command)
David Douard <david.douard@logilab.fr>
parents:
diff changeset
108 y = data.copy()
de9122b5680a Several improvements (code refactoring) + add stuff to decode binary coordinate data block ("DCBN" command)
David Douard <david.douard@logilab.fr>
parents:
diff changeset
109
de9122b5680a Several improvements (code refactoring) + add stuff to decode binary coordinate data block ("DCBN" command)
David Douard <david.douard@logilab.fr>
parents:
diff changeset
110 ym = coord_header['Min value of data']
de9122b5680a Several improvements (code refactoring) + add stuff to decode binary coordinate data block ("DCBN" command)
David Douard <david.douard@logilab.fr>
parents:
diff changeset
111 yM = coord_header['Max value of data']
de9122b5680a Several improvements (code refactoring) + add stuff to decode binary coordinate data block ("DCBN" command)
David Douard <david.douard@logilab.fr>
parents:
diff changeset
112 ys = coord_header['Y scale factor']
de9122b5680a Several improvements (code refactoring) + add stuff to decode binary coordinate data block ("DCBN" command)
David Douard <david.douard@logilab.fr>
parents:
diff changeset
113
de9122b5680a Several improvements (code refactoring) + add stuff to decode binary coordinate data block ("DCBN" command)
David Douard <david.douard@logilab.fr>
parents:
diff changeset
114 y[y<ym] = ym
de9122b5680a Several improvements (code refactoring) + add stuff to decode binary coordinate data block ("DCBN" command)
David Douard <david.douard@logilab.fr>
parents:
diff changeset
115 y *= ys
de9122b5680a Several improvements (code refactoring) + add stuff to decode binary coordinate data block ("DCBN" command)
David Douard <david.douard@logilab.fr>
parents:
diff changeset
116
de9122b5680a Several improvements (code refactoring) + add stuff to decode binary coordinate data block ("DCBN" command)
David Douard <david.douard@logilab.fr>
parents:
diff changeset
117 import pylab
de9122b5680a Several improvements (code refactoring) + add stuff to decode binary coordinate data block ("DCBN" command)
David Douard <david.douard@logilab.fr>
parents:
diff changeset
118 pylab.ylabel(header['Amplitude units'])
de9122b5680a Several improvements (code refactoring) + add stuff to decode binary coordinate data block ("DCBN" command)
David Douard <david.douard@logilab.fr>
parents:
diff changeset
119 pylab.grid()
de9122b5680a Several improvements (code refactoring) + add stuff to decode binary coordinate data block ("DCBN" command)
David Douard <david.douard@logilab.fr>
parents:
diff changeset
120 pylab.plot(x, y)
de9122b5680a Several improvements (code refactoring) + add stuff to decode binary coordinate data block ("DCBN" command)
David Douard <david.douard@logilab.fr>
parents:
diff changeset
121 pylab.xlabel('frequency (%s)'%header["X axis units"])
de9122b5680a Several improvements (code refactoring) + add stuff to decode binary coordinate data block ("DCBN" command)
David Douard <david.douard@logilab.fr>
parents:
diff changeset
122 pylab.ylabel("%s (%s)"%(coord_header['Y coordinates'], header['Amplitude units']) )
de9122b5680a Several improvements (code refactoring) + add stuff to decode binary coordinate data block ("DCBN" command)
David Douard <david.douard@logilab.fr>
parents:
diff changeset
123 pylab.show()
de9122b5680a Several improvements (code refactoring) + add stuff to decode binary coordinate data block ("DCBN" command)
David Douard <david.douard@logilab.fr>
parents:
diff changeset
124
de9122b5680a Several improvements (code refactoring) + add stuff to decode binary coordinate data block ("DCBN" command)
David Douard <david.douard@logilab.fr>
parents:
diff changeset
125 if __name__ == "__main__":
de9122b5680a Several improvements (code refactoring) + add stuff to decode binary coordinate data block ("DCBN" command)
David Douard <david.douard@logilab.fr>
parents:
diff changeset
126 main()

mercurial