6215628175bdde07d805217fba0ba1387e4f8b0e
[igor.git] / bin / igorbinarywave.py
1 #!/usr/bin/env python
2 #
3 # Copyright (C) 2012 W. Trevor King <wking@tremily.us>
4 #
5 # This file is part of igor.
6 #
7 # igor is free software: you can redistribute it and/or modify it under the
8 # terms of the GNU Lesser General Public License as published by the Free
9 # Software Foundation, either version 3 of the License, or (at your option) any
10 # later version.
11 #
12 # igor is distributed in the hope that it will be useful, but WITHOUT ANY
13 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14 # A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
15 # details.
16 #
17 # You should have received a copy of the GNU Lesser General Public License
18 # along with igor.  If not, see <http://www.gnu.org/licenses/>.
19
20 "IBW -> ASCII conversion"
21
22 import pprint
23
24 import numpy
25
26 from igor.binarywave import load
27 from igor.script import Script
28
29
30 def run(args):
31     wave = load(args.infile)
32     numpy.savetxt(args.outfile, wave['wave']['wData'], fmt='%g', delimiter='\t')
33     if args.verbose > 0:
34         wave['wave'].pop('wData')
35         pprint.pprint(wave)
36
37 s = Script(description=__doc__)
38 s._run = run
39 s.run()