Imported Upstream version 3.2.2
[debian/gnuradio] / gr-utils / src / python / gr_plot_char.py
1 #!/usr/bin/env python
2 #
3 # Copyright 2007,2008 Free Software Foundation, Inc.
4
5 # This file is part of GNU Radio
6
7 # GNU Radio is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 3, or (at your option)
10 # any later version.
11
12 # GNU Radio is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 # GNU General Public License for more details.
16
17 # You should have received a copy of the GNU General Public License
18 # along with GNU Radio; see the file COPYING.  If not, write to
19 # the Free Software Foundation, Inc., 51 Franklin Street,
20 # Boston, MA 02110-1301, USA.
21
22
23 try:
24     import scipy
25 except ImportError:
26     print "Please install SciPy to run this script (http://www.scipy.org/)"
27     raise SystemExit, 1
28
29 from optparse import OptionParser
30 from gnuradio.plot_data import plot_data
31
32 def main():
33     usage="%prog: [options] input_filenames"
34     description = "Takes a GNU Radio byte/char binary file and displays the samples versus time. You can set the block size to specify how many points to read in at a time and the start position in the file. By default, the system assumes a sample rate of 1, so in time, each sample is plotted versus the sample number. To set a true time axis, set the sample rate (-R or --sample-rate) to the sample rate used when capturing the samples."
35
36     parser = OptionParser(conflict_handler="resolve", usage=usage, description=description)
37     parser.add_option("-B", "--block", type="int", default=1000,
38                       help="Specify the block size [default=%default]")
39     parser.add_option("-s", "--start", type="int", default=0,
40                       help="Specify where to start in the file [default=%default]")
41     parser.add_option("-R", "--sample-rate", type="float", default=1.0,
42                       help="Set the sampler rate of the data [default=%default]")
43     
44     (options, args) = parser.parse_args ()
45     if len(args) < 1:
46         parser.print_help()
47         raise SystemExit, 1
48     filenames = args
49
50     datatype=scipy.int8
51     dc = plot_data(datatype, filenames, options)
52
53 if __name__ == "__main__":
54     try:
55         main()
56     except KeyboardInterrupt:
57         pass
58