Mercurial > ~darius > hgwebdir.cgi > pyinst
view datafile.py @ 81:1947d10f9395
- Search for signal frequency iteratively to improve accuracy.
- Use narrower bandwidths (via FFT filter) for close in measurements.
- Work around bug in firmware when using FFT filter.
- Actually _raise_ the exception when the signal power is too low.
author | Daniel O'Connor <doconnor@gsoft.com.au> |
---|---|
date | Fri, 27 Sep 2024 16:56:44 +0930 |
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]