diff --git a/backwash/__init__.py b/backwash/__init__.py index 366701f..0250550 100644 --- a/backwash/__init__.py +++ b/backwash/__init__.py @@ -1,4 +1,4 @@ -from .obr import OBRData +from .obr import OBRData as OBRData __version__ = '0.1' diff --git a/backwash/obr.py b/backwash/obr.py index 27725b4..b6fe524 100644 --- a/backwash/obr.py +++ b/backwash/obr.py @@ -1,4 +1,4 @@ -from typing import IO, Self +from typing import IO from dataclasses import dataclass from pathlib import Path import logging @@ -32,14 +32,14 @@ class OBRData: """ Time delay (x-axis) for `te` and `tm` data """ - tt = numpy.arange(self.tee.size) * self.dt_ns + self.t0half * 2 + tt = numpy.arange(self.te.size, dtype=numpy.float64) * self.dt_ns + self.t0half * 2 return tt @property def wl_range_nm(self) -> NDArray[numpy.float64]: freq_range = numpy.asarray([ self.max_freq_GHz - 1 / (2 * self.dt_ns), - welf.max_freq_GHz, + self.max_freq_GHz, ]) return C0 / freq_range @@ -66,7 +66,7 @@ class OBRData: return scale * ham @staticmethod - def read(file: str | IO[bytes] | Path) -> Self: + def read(file: str | IO[bytes] | Path) -> 'OBRData': def fromfile(*args, **kwargs) -> NDArray: if not isinstance(file, str | Path): file.seek(0) @@ -77,11 +77,12 @@ class OBRData: logger.warning(f'Unexpected magic bytes: {magic}') metadata = fromfile(dtype=numpy.float64, offset=0x0c, count=4) - ng = fromfile(dtype=numpy.float64, offset=0x2e, count=1) - gain_dB = fromfile(dtype=numpy.int16, offset=0x36, count=1) + ng = fromfile(dtype=numpy.float64, offset=0x2e, count=1)[0] + gain_dB = fromfile(dtype=numpy.int16, offset=0x36, count=1)[0] dates = fromfile(dtype=numpy.int16, offset=0x46, count=2 * 8) - t0half = fromfile(dtype=numpy.float64, offset=0x96, count=1) + t0half = fromfile(dtype=numpy.float64, offset=0x96, count=1)[0] freq_windowed = fromfile(dtype=numpy.int8, offset=0xb6, count=1).any() + raw_sweep_rate = fromfile(dtype=numpy.uint8, offset=0xb9, count=2) arr = fromfile(dtype=numpy.float64, offset=0x800) max_freq_GHz = metadata[0] @@ -101,11 +102,13 @@ class OBRData: gain_dB = gain_dB, max_freq_GHz = max_freq_GHz, ng_setting = ng, - freq_windowed = freq_windowed, + freq_windowed = bool(freq_windowed), meas_date = meas_date, calib_date = calib_date, _wip_metadata = metadata[1:3], + _raw_sweep_rate = raw_sweep_rate, # TODO translate ) + return result diff --git a/backwash/ova_bin.py b/backwash/ova_bin.py index caeae6a..0d653bf 100644 --- a/backwash/ova_bin.py +++ b/backwash/ova_bin.py @@ -1,4 +1,4 @@ -from typing import IO, Self +from typing import IO from dataclasses import dataclass from pathlib import Path import logging @@ -27,14 +27,14 @@ class OVABINData: """ Time delay (x-axis) for `te` and `tm` data """ - tt = numpy.arange(self.tee.size) * self.dt_ns + tt = numpy.arange(self.te.size, dtype=numpy.float64) * self.dt_ns return tt @property def wl_range_nm(self) -> NDArray[numpy.float64]: freq_range = numpy.asarray([ self.max_freq_GHz - 1 / (2 * self.dt_ns), - welf.max_freq_GHz, + self.max_freq_GHz, ]) return C0 / freq_range @@ -61,7 +61,7 @@ class OVABINData: return scale * ham @staticmethod - def read(file: str | IO[bytes] | Path) -> Self: + def read(file: str | IO[bytes] | Path) -> 'OVABINData': raise NotImplementedError('Still WIP') def fromfile(*args, **kwargs) -> NDArray: if not isinstance(file, str | Path): @@ -96,6 +96,7 @@ class OVABINData: meas_date = meas_date, _wip_metadata = metadata[1:], ) + return result """