lint and mypy fixes
This commit is contained in:
parent
1b2e2070f9
commit
a6b6d23cdb
@ -1,4 +1,4 @@
|
|||||||
from .obr import OBRData
|
from .obr import OBRData as OBRData
|
||||||
|
|
||||||
|
|
||||||
__version__ = '0.1'
|
__version__ = '0.1'
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
from typing import IO, Self
|
from typing import IO
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
import logging
|
import logging
|
||||||
@ -32,14 +32,14 @@ class OBRData:
|
|||||||
"""
|
"""
|
||||||
Time delay (x-axis) for `te` and `tm` data
|
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
|
return tt
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def wl_range_nm(self) -> NDArray[numpy.float64]:
|
def wl_range_nm(self) -> NDArray[numpy.float64]:
|
||||||
freq_range = numpy.asarray([
|
freq_range = numpy.asarray([
|
||||||
self.max_freq_GHz - 1 / (2 * self.dt_ns),
|
self.max_freq_GHz - 1 / (2 * self.dt_ns),
|
||||||
welf.max_freq_GHz,
|
self.max_freq_GHz,
|
||||||
])
|
])
|
||||||
return C0 / freq_range
|
return C0 / freq_range
|
||||||
|
|
||||||
@ -66,7 +66,7 @@ class OBRData:
|
|||||||
return scale * ham
|
return scale * ham
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def read(file: str | IO[bytes] | Path) -> Self:
|
def read(file: str | IO[bytes] | Path) -> 'OBRData':
|
||||||
def fromfile(*args, **kwargs) -> NDArray:
|
def fromfile(*args, **kwargs) -> NDArray:
|
||||||
if not isinstance(file, str | Path):
|
if not isinstance(file, str | Path):
|
||||||
file.seek(0)
|
file.seek(0)
|
||||||
@ -77,11 +77,12 @@ class OBRData:
|
|||||||
logger.warning(f'Unexpected magic bytes: {magic}')
|
logger.warning(f'Unexpected magic bytes: {magic}')
|
||||||
|
|
||||||
metadata = fromfile(dtype=numpy.float64, offset=0x0c, count=4)
|
metadata = fromfile(dtype=numpy.float64, offset=0x0c, count=4)
|
||||||
ng = fromfile(dtype=numpy.float64, offset=0x2e, count=1)
|
ng = fromfile(dtype=numpy.float64, offset=0x2e, count=1)[0]
|
||||||
gain_dB = fromfile(dtype=numpy.int16, offset=0x36, count=1)
|
gain_dB = fromfile(dtype=numpy.int16, offset=0x36, count=1)[0]
|
||||||
dates = fromfile(dtype=numpy.int16, offset=0x46, count=2 * 8)
|
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()
|
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)
|
arr = fromfile(dtype=numpy.float64, offset=0x800)
|
||||||
|
|
||||||
max_freq_GHz = metadata[0]
|
max_freq_GHz = metadata[0]
|
||||||
@ -101,11 +102,13 @@ class OBRData:
|
|||||||
gain_dB = gain_dB,
|
gain_dB = gain_dB,
|
||||||
max_freq_GHz = max_freq_GHz,
|
max_freq_GHz = max_freq_GHz,
|
||||||
ng_setting = ng,
|
ng_setting = ng,
|
||||||
freq_windowed = freq_windowed,
|
freq_windowed = bool(freq_windowed),
|
||||||
meas_date = meas_date,
|
meas_date = meas_date,
|
||||||
calib_date = calib_date,
|
calib_date = calib_date,
|
||||||
_wip_metadata = metadata[1:3],
|
_wip_metadata = metadata[1:3],
|
||||||
|
_raw_sweep_rate = raw_sweep_rate, # TODO translate
|
||||||
)
|
)
|
||||||
|
return result
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
from typing import IO, Self
|
from typing import IO
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
import logging
|
import logging
|
||||||
@ -27,14 +27,14 @@ class OVABINData:
|
|||||||
"""
|
"""
|
||||||
Time delay (x-axis) for `te` and `tm` data
|
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
|
return tt
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def wl_range_nm(self) -> NDArray[numpy.float64]:
|
def wl_range_nm(self) -> NDArray[numpy.float64]:
|
||||||
freq_range = numpy.asarray([
|
freq_range = numpy.asarray([
|
||||||
self.max_freq_GHz - 1 / (2 * self.dt_ns),
|
self.max_freq_GHz - 1 / (2 * self.dt_ns),
|
||||||
welf.max_freq_GHz,
|
self.max_freq_GHz,
|
||||||
])
|
])
|
||||||
return C0 / freq_range
|
return C0 / freq_range
|
||||||
|
|
||||||
@ -61,7 +61,7 @@ class OVABINData:
|
|||||||
return scale * ham
|
return scale * ham
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def read(file: str | IO[bytes] | Path) -> Self:
|
def read(file: str | IO[bytes] | Path) -> 'OVABINData':
|
||||||
raise NotImplementedError('Still WIP')
|
raise NotImplementedError('Still WIP')
|
||||||
def fromfile(*args, **kwargs) -> NDArray:
|
def fromfile(*args, **kwargs) -> NDArray:
|
||||||
if not isinstance(file, str | Path):
|
if not isinstance(file, str | Path):
|
||||||
@ -96,6 +96,7 @@ class OVABINData:
|
|||||||
meas_date = meas_date,
|
meas_date = meas_date,
|
||||||
_wip_metadata = metadata[1:],
|
_wip_metadata = metadata[1:],
|
||||||
)
|
)
|
||||||
|
return result
|
||||||
|
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user