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
class CalSetting:
name: str
cal_value: float
cal_value_dB: float
cal_value_linear: float
qty: Qty
class CalibrationSettings:
one = CalSetting('94 dB SPL', 1.0, SIQtys.AP)
two = CalSetting('114 dB SPL', 10.0, SIQtys.AP)
one = CalSetting('94 dB SPL', 94.0 , 1.0, SIQtys.AP)
two = CalSetting('114 dB SPL', 114.0 , 10.0, SIQtys.AP)
types = (one, two)
default = one
@ -120,12 +121,15 @@ class CalibrationSettings:
"""
cb.clear()
for ty in CalibrationSettings.types:
cb.addItem(f'{ty.name}')
cb.addItem(f'{ty.cal_value_dB}')
cb.setCurrentIndex(CalibrationSettings.default_index)
@staticmethod
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')

View File

@ -370,6 +370,8 @@ class Measurement:
sensitivity is applied, converted to floating point acoustic
pressure values [Pa]."""
print('TODO: THIS SHOULD BE CHANGED, VERY INCONSISTENT AND CONFUSING API')
blocks = self.rawData(block)
# Apply scaling (sensitivity, integer -> float)
@ -394,26 +396,6 @@ class Measurement:
"""
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
def sensitivity(self, sens):
"""Set the sensitivity of the measurement in the file.
@ -437,6 +419,27 @@ class Measurement:
f.attrs['sensitivity'] = 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):
"""Export measurement file as wave. In case the measurement data is
stored as floats, the values are scaled to the proper integer (PCM)