Merge branch 'develop' into DT9837A

This commit is contained in:
Anne de Jong 2020-09-18 08:55:43 +02:00
commit 248fa8d8a4
2 changed files with 32 additions and 25 deletions

View File

@ -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')

View File

@ -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)