Mercurial > ~darius > hgwebdir.cgi > pyinst
view datafile.py @ 47:fa728cf34f50
- Calculate ENR (based on table on the back of our noise source)
- Accept options to set frequency, span, etc
- Actually call the setup routine
author | Daniel O'Connor <darius@dons.net.au> |
---|---|
date | Thu, 31 Jan 2013 11:24:49 +1030 |
parents | 3d2306e39700 |
children | 91b476ebc0f2 |
line wrap: on
line source
import exceptions import numpy class DataFile(object): def __init__(self, fname): f = file(fname) self.opts = {} for line in f: key, value = line.strip().split(' ', 1) if key == "XDATA": self.freqs = numpy.fromstring(value, sep = ', ') continue if key == "YDATA": self.powers = numpy.fromstring(value, sep = ', ') continue try: self.opts[key] = int(value) except exceptions.ValueError, e: try: self.opts[key] = float(value) except exceptions.ValueError, e: self.opts[key] = value def __getitem__(self, k): return self.opts[k]