Mercurial > ~darius > hgwebdir.cgi > pyinst
view datafile.py @ 85:60ad91b4c67c default tip
Add 'quick' option to use a faster sweep time with no averaging.
Useful for testing the hardware is setup correctly without having to wait 3 minutes.
author | Daniel O'Connor <doconnor@gsoft.com.au> |
---|---|
date | Mon, 21 Oct 2024 14:12:50 +1030 |
parents | 91b476ebc0f2 |
children |
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 as e: try: self.opts[key] = float(value) except exceptions.ValueError as e: self.opts[key] = value def __getitem__(self, k): return self.opts[k]