diff --git a/src/lasp/lasp_common.py b/src/lasp/lasp_common.py index 773ea41..8c25a02 100644 --- a/src/lasp/lasp_common.py +++ b/src/lasp/lasp_common.py @@ -82,6 +82,12 @@ class Qty: return (self.name == other.name and self.unit_name == other.unit_name) + def toInt(self): + """ + Convert quantity to its specific enum integer value + """ + return self.cpp_enum.value + @unique diff --git a/src/lasp/lasp_measurement.py b/src/lasp/lasp_measurement.py index 1b1607c..f62a8d4 100644 --- a/src/lasp/lasp_measurement.py +++ b/src/lasp/lasp_measurement.py @@ -51,6 +51,7 @@ from scipy.io import wavfile import os, time, wave, logging from .lasp_common import SIQtys, Qty, getFreq from .lasp_cpp import Window, DaqChannel, LASP_VERSION_MAJOR +from typing import List def getSampWidth(dtype): @@ -311,14 +312,14 @@ class Measurement: return chcfg @channelConfig.setter - def channelConfig(self, chcfg): + def channelConfig(self, chcfg: List[DaqChannel]): chname = [] sens = [] qtys = [] for ch in chcfg: chname.append(ch.name) sens.append(ch.sensitivity) - qtys.append(SIQtys.fromInt(ch.qty)) + qtys.append(SIQtys.fromCppEnum(ch.qty)) self.channelNames = chname self.sensitivity = sens @@ -332,11 +333,14 @@ class Measurement: def qtys(self, newqtys): if not len(newqtys) == len(self._qtys): raise ValueError('Invalid number of quantities') - qtys_json = [qty.to_json() for qty in newqtys] + qtys_int = [qty.toInt() for qty in newqtys] # Use setAttribute here, but thos store the jsonified version as well, # which we have to overwrite again with the deserialized ones. This is # actually not a very nice way of coding. - self.setAttribute('qtys', qtys_json) + with self.file('r+') as f: + # Update comment attribute in the file + f.attrs['qtys_enum_idx'] = qtys_int + self._qtys = newqtys @contextmanager diff --git a/src/lasp/pybind11/lasp_pyindatahandler.cpp b/src/lasp/pybind11/lasp_pyindatahandler.cpp index 69af06f..aa3fb02 100644 --- a/src/lasp/pybind11/lasp_pyindatahandler.cpp +++ b/src/lasp/pybind11/lasp_pyindatahandler.cpp @@ -1,5 +1,5 @@ +/* #define DEBUGTRACE_ENABLED */ #include -#define DEBUGTRACE_ENABLED #include "arma_npy.h" #include "debugtrace.hpp" #include "lasp_ppm.h"