From 155a2be2d9650dcb8e3407a0f8242b9687c94018 Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Mon, 16 Jul 2012 14:56:43 -0400 Subject: [PATCH] Split igorbinarywave.py off of Hooke into its own package. --- .gitignore | 5 ++ .mailmap | 1 + .update-copyright.conf | 18 ++++ README | 87 +++++++++++++++++++ bin/igorbinarywave.py | 39 +++++++++ igor/__init__.py | 5 ++ .../igorbinarywave.py => igor/binarywave.py | 54 +----------- setup.py | 40 +++++++++ 8 files changed, 196 insertions(+), 53 deletions(-) create mode 100644 .gitignore create mode 100644 .mailmap create mode 100644 .update-copyright.conf create mode 100644 README create mode 100755 bin/igorbinarywave.py create mode 100644 igor/__init__.py rename hooke/util/igorbinarywave.py => igor/binarywave.py (93%) create mode 100644 setup.py diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..7cf134c --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +MANIFEST +build/ +dist/ +igor.egg-info/ +*.pyc diff --git a/.mailmap b/.mailmap new file mode 100644 index 0000000..4a905eb --- /dev/null +++ b/.mailmap @@ -0,0 +1 @@ +W. Trevor King diff --git a/.update-copyright.conf b/.update-copyright.conf new file mode 100644 index 0000000..9ce16c9 --- /dev/null +++ b/.update-copyright.conf @@ -0,0 +1,18 @@ +[project] +name: igor +vcs: Git + +[files] +authors: yes +files: yes +ignored: COPYING, README, .update-copyright.conf, .git*, test/* + +[copyright] +short: %(project)s comes with ABSOLUTELY NO WARRANTY and is licensed under the GNU Lesser General Public License. For details, %%(get-details)s. +long: This file is part of %(project)s. + + %(project)s is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + + %(project)s is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License along with %(project)s. If not, see . diff --git a/README b/README new file mode 100644 index 0000000..f76d225 --- /dev/null +++ b/README @@ -0,0 +1,87 @@ +igor: Interface for reading binary IGOR files. + +Read Igor Binary Waves (.ibw) and ... written by WaveMetrics' IGOR +package. + +Installation +============ + +Packages +-------- + +Gentoo +~~~~~~ + +I've packaged `igor` for Gentoo. You need layman_ and my `wtk +overlay`_. Install with:: + + # emerge -av app-portage/layman + # layman --add wtk + # emerge -av sci-misc/igor + +Dependencies +------------ + +If you're installing by hand or packaging calibcant for another +distribution, you'll need the following dependencies: + +=========== ================= ============================ +Package Debian_ Gentoo_ +=========== ================= ============================ +Numpy_ python-numpy dev-python/numpy +Matplotlib_ python-matplotlib dev-python/matplotlib +Nose_ python-nose dev-python/nose +=========== ================= ============================ + +Installing by hand +------------------ + +`igor` is available as a Git_ repository:: + + $ git clone git://tremily.us/igor.git + +See the homepage_ for details. To install the checkout, run the +standard:: + + $ python setup.py install + + +Usage +===== + +See the module docstrings for simple examples. + + +Testing +======= + +Run internal unit tests with:: + + $ nosetests --with-doctest --doctest-tests igor + + +Licence +======= + +This project is distributed under the `GNU General Public License +Version 3`_ or greater. + + +Author +====== + +W. Trevor King +wking@tremily.us +Copyright 2008-2012 + + +.. _layman: http://layman.sourceforge.net/ +.. _wtk overlay: http://blog.tremily.us/posts/Gentoo_overlay/ +.. _Debian: http://www.debian.org/ +.. _Gentoo: http://www.gentoo.org/ +.. _NumPy: http://numpy.scipy.org/ +.. _Matplotlib: http://matplotlib.sourceforge.net/ +.. _Nose: http://somethingaboutorange.com/mrl/projects/nose/ +.. _Git: http://git-scm.com/ +.. _homepage: http://blog.tremily.us/posts/calibcant/ +.. _GNU General Public License Version 3: http://www.gnu.org/licenses/gpl.txt diff --git a/bin/igorbinarywave.py b/bin/igorbinarywave.py new file mode 100755 index 0000000..435fdca --- /dev/null +++ b/bin/igorbinarywave.py @@ -0,0 +1,39 @@ +#!/usr/bin/env python + +"IBW -> ASCII conversion" + +import optparse +import pprint +import sys + +import numpy + +from igor import __version__ +from igor.binarywave import loadibw + + +p = optparse.OptionParser(version=__version__) + +p.add_option('-f', '--infile', dest='infile', metavar='FILE', + default='-', help='Input IGOR Binary Wave (.ibw) file.') +p.add_option('-o', '--outfile', dest='outfile', metavar='FILE', + default='-', help='File for ASCII output.') +p.add_option('-v', '--verbose', dest='verbose', default=0, + action='count', help='Increment verbosity') +p.add_option('-n', '--not-strict', dest='strict', default=True, + action='store_false', help='Attempt to parse invalid IBW files.') + +options,args = p.parse_args() + +if len(args) > 0 and options.infile == None: + options.infile = args[0] +if options.infile == '-': + options.infile = sys.stdin +if options.outfile == '-': + options.outfile = sys.stdout + +data,bin_info,wave_info = loadibw(options.infile, strict=options.strict) +numpy.savetxt(options.outfile, data, fmt='%g', delimiter='\t') +if options.verbose > 0: + pprint.pprint(bin_info) + pprint.pprint(wave_info) diff --git a/igor/__init__.py b/igor/__init__.py new file mode 100644 index 0000000..f7ea88f --- /dev/null +++ b/igor/__init__.py @@ -0,0 +1,5 @@ +# Copyright + +"Interface for reading binary IGOR files." + +__version__ = '0.2' diff --git a/hooke/util/igorbinarywave.py b/igor/binarywave.py similarity index 93% rename from hooke/util/igorbinarywave.py rename to igor/binarywave.py index a361a76..b2fbe6c 100644 --- a/hooke/util/igorbinarywave.py +++ b/igor/binarywave.py @@ -1,5 +1,3 @@ -#!/usr/bin/python -# # Copyright (C) 2010 W. Trevor King # # This file is part of Hooke. @@ -18,13 +16,7 @@ # License along with Hooke. If not, see # . -"""igorbinarywave provides pure Python interface between IGOR Binary -Wave files and Numpy arrays. - -This is basically a stand-alone package that we bundle into Hooke for -convenience. It is used by the mfp*d drivers, whose data is saved in -IBW files. -""" +"Read IGOR Binary Wave files into Numpy arrays." # Based on WaveMetric's Technical Note 003, "Igor Binary Format" # ftp://ftp.wavemetrics.net/IgorPro/Technical_Notes/TN003.zip @@ -42,9 +34,6 @@ import types import numpy -__version__ = '0.1' - - class Field (object): """Represent a Structure field. @@ -570,44 +559,3 @@ def loadibw(filename, strict=True): def saveibw(filename): raise NotImplementedError - - -if __name__ == '__main__': - """IBW -> ASCII conversion - """ - import optparse - import sys - - p = optparse.OptionParser(version=__version__) - - p.add_option('-f', '--infile', dest='infile', metavar='FILE', - default='-', help='Input IGOR Binary Wave (.ibw) file.') - p.add_option('-o', '--outfile', dest='outfile', metavar='FILE', - default='-', help='File for ASCII output.') - p.add_option('-v', '--verbose', dest='verbose', default=0, - action='count', help='Increment verbosity') - p.add_option('-n', '--not-strict', dest='strict', default=True, - action='store_false', help='Attempt to parse invalid IBW files.') - p.add_option('-t', '--test', dest='test', default=False, - action='store_true', help='Run internal tests and exit.') - - options,args = p.parse_args() - - if options.test == True: - import doctest - num_failures,num_tests = doctest.testmod(verbose=options.verbose) - sys.exit(min(num_failures, 127)) - - if len(args) > 0 and options.infile == None: - options.infile = args[0] - if options.infile == '-': - options.infile = sys.stdin - if options.outfile == '-': - options.outfile = sys.stdout - - data,bin_info,wave_info = loadibw(options.infile, strict=options.strict) - numpy.savetxt(options.outfile, data, fmt='%g', delimiter='\t') - if options.verbose > 0: - import pprint - pprint.pprint(bin_info) - pprint.pprint(wave_info) diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..c63b48b --- /dev/null +++ b/setup.py @@ -0,0 +1,40 @@ +# Copyright + +"igor: interface for reading binary IGOR files." + +from distutils.core import setup +import os.path + +from igor import __version__ + + +package_name = 'igor' +_this_dir = os.path.dirname(__file__) + +setup(name=package_name, + version=__version__, + maintainer='W. Trevor King', + maintainer_email='wking@tremily.us', + url='http://blog.tremily.us/posts/%s/'.format(package_name), + download_url='http://git.tremily.us/?p={}.git;a=snapshot;h=v{};sf=tgz'.format(package_name, __version__), + license='GNU General Public License (GPL)', + platforms=['all'], + description=__doc__, + long_description=open(os.path.join(_this_dir, 'README'), 'r').read(), + classifiers=[ + 'Development Status :: 2 - Pre-Alpha', + 'Intended Audience :: Developers', + 'Operating System :: OS Independent', + 'License :: OSI Approved :: GNU General Public License (GPL)', + 'Programming Language :: Python', + 'Topic :: Scientific/Engineering', + 'Topic :: Software Development :: Libraries :: Python Modules', + ], + packages=[ + 'igor', + ], + scripts=[ + 'bin/igorbinarywave.py', + ], + provides=['igor (%s)' % __version__], + ) -- 2.26.2