We have some problems with the Measurement class. One way or another, changes to measurement files (sensitivity values) from ACME are not stored in the measurement file. Moreover, we concluded that the Measurement interface contains some inconsistencies/unclarities in its interface
This commit is contained in:
parent
2192f5a7fc
commit
0232b8aae0
|
@ -99,12 +99,13 @@ class SIQtys:
|
||||||
@dataclass
|
@dataclass
|
||||||
class CalSetting:
|
class CalSetting:
|
||||||
name: str
|
name: str
|
||||||
cal_value: float
|
cal_value_dB: float
|
||||||
|
cal_value_linear: float
|
||||||
qty: Qty
|
qty: Qty
|
||||||
|
|
||||||
class CalibrationSettings:
|
class CalibrationSettings:
|
||||||
one = CalSetting('94 dB SPL', 1.0, SIQtys.AP)
|
one = CalSetting('94 dB SPL', 94.0 , 1.0, SIQtys.AP)
|
||||||
two = CalSetting('114 dB SPL', 10.0, SIQtys.AP)
|
two = CalSetting('114 dB SPL', 114.0 , 10.0, SIQtys.AP)
|
||||||
|
|
||||||
types = (one, two)
|
types = (one, two)
|
||||||
default = one
|
default = one
|
||||||
|
@ -120,12 +121,15 @@ class CalibrationSettings:
|
||||||
"""
|
"""
|
||||||
cb.clear()
|
cb.clear()
|
||||||
for ty in CalibrationSettings.types:
|
for ty in CalibrationSettings.types:
|
||||||
cb.addItem(f'{ty.name}')
|
cb.addItem(f'{ty.cal_value_dB}')
|
||||||
cb.setCurrentIndex(CalibrationSettings.default_index)
|
cb.setCurrentIndex(CalibrationSettings.default_index)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def getCurrent(cb):
|
def getCurrent(cb):
|
||||||
return CalibrationSettings.types[cb.currentIndex()]
|
if cb.currentIndex() < len(CalibrationSettings.types):
|
||||||
|
return CalibrationSettings.types[cb.currentIndex()]
|
||||||
|
else:
|
||||||
|
return None
|
||||||
|
|
||||||
lasp_appdir = appdirs.user_data_dir('Lasp', 'ASCEE')
|
lasp_appdir = appdirs.user_data_dir('Lasp', 'ASCEE')
|
||||||
|
|
||||||
|
|
|
@ -370,6 +370,8 @@ class Measurement:
|
||||||
sensitivity is applied, converted to floating point acoustic
|
sensitivity is applied, converted to floating point acoustic
|
||||||
pressure values [Pa]."""
|
pressure values [Pa]."""
|
||||||
|
|
||||||
|
print('TODO: THIS SHOULD BE CHANGED, VERY INCONSISTENT AND CONFUSING API')
|
||||||
|
|
||||||
blocks = self.rawData(block)
|
blocks = self.rawData(block)
|
||||||
|
|
||||||
# Apply scaling (sensitivity, integer -> float)
|
# Apply scaling (sensitivity, integer -> float)
|
||||||
|
@ -394,26 +396,6 @@ class Measurement:
|
||||||
"""
|
"""
|
||||||
return self._sens
|
return self._sens
|
||||||
|
|
||||||
def checkOverflow(self):
|
|
||||||
"""Coarse check for overflow in measurement.
|
|
||||||
|
|
||||||
Return:
|
|
||||||
True if overflow is possible, else False
|
|
||||||
"""
|
|
||||||
|
|
||||||
with self.file() as f:
|
|
||||||
for block in self.iterBlocks(f):
|
|
||||||
dtype = block.dtype
|
|
||||||
if dtype.kind == 'i':
|
|
||||||
# minvalue = np.iinfo(dtype).min
|
|
||||||
maxvalue = np.iinfo(dtype).max
|
|
||||||
if np.max(np.abs(block)) >= 0.9*maxvalue:
|
|
||||||
return True
|
|
||||||
else:
|
|
||||||
# Cannot check for floating point values.
|
|
||||||
return False
|
|
||||||
return False
|
|
||||||
|
|
||||||
@sensitivity.setter
|
@sensitivity.setter
|
||||||
def sensitivity(self, sens):
|
def sensitivity(self, sens):
|
||||||
"""Set the sensitivity of the measurement in the file.
|
"""Set the sensitivity of the measurement in the file.
|
||||||
|
@ -437,6 +419,27 @@ class Measurement:
|
||||||
f.attrs['sensitivity'] = sens
|
f.attrs['sensitivity'] = sens
|
||||||
self._sens = sens
|
self._sens = sens
|
||||||
|
|
||||||
|
def checkOverflow(self):
|
||||||
|
"""Coarse check for overflow in measurement.
|
||||||
|
|
||||||
|
Return:
|
||||||
|
True if overflow is possible, else False
|
||||||
|
"""
|
||||||
|
|
||||||
|
with self.file() as f:
|
||||||
|
for block in self.iterBlocks(f):
|
||||||
|
dtype = block.dtype
|
||||||
|
if dtype.kind == 'i':
|
||||||
|
# minvalue = np.iinfo(dtype).min
|
||||||
|
maxvalue = np.iinfo(dtype).max
|
||||||
|
if np.max(np.abs(block)) >= 0.9*maxvalue:
|
||||||
|
return True
|
||||||
|
else:
|
||||||
|
# Cannot check for floating point values.
|
||||||
|
return False
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
def exportAsWave(self, fn=None, force=False, newsampwidth=None, normalize=True):
|
def exportAsWave(self, fn=None, force=False, newsampwidth=None, normalize=True):
|
||||||
"""Export measurement file as wave. In case the measurement data is
|
"""Export measurement file as wave. In case the measurement data is
|
||||||
stored as floats, the values are scaled to the proper integer (PCM)
|
stored as floats, the values are scaled to the proper integer (PCM)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user