Bugfix of channel names in measurement. Set default frequency weighting to Z, in stead of A, on advice of Casper

This commit is contained in:
Anne de Jong 2021-05-20 22:17:22 +02:00
parent 377291ccf4
commit b3ce37591f
3 changed files with 20 additions and 12 deletions

View File

@ -336,11 +336,11 @@ class FreqWeighting:
"""
Frequency weighting types
"""
Z = ('Z', 'Z-weighting')
A = ('A', 'A-weighting')
C = ('C', 'C-weighting')
Z = ('Z', 'Z-weighting')
types = (A, C, Z)
default = A
default = Z
default_index = 0
@staticmethod

View File

@ -208,11 +208,16 @@ class Measurement:
self.N = (self.nblocks * self.blocksize)
self.T = self.N / self.samplerate
# Due to a previous bug, the channel names were not stored
# consistently, i.e. as 'channel_names' and later camelcase.
try:
self._channel_names = f.attrs['channel_names']
self._channelNames = f.attrs['channel_names']
except KeyError:
# No channel names found in measurement file
self._channel_names = [f'Unnamed {i}' for i in range(self.nchannels)]
try:
self._channelNames = f.attrs['channelNames']
except KeyError:
# No channel names found in measurement file
self._channelNames = [f'Unnamed {i}' for i in range(self.nchannels)]
# comment = read-write thing
try:
@ -232,7 +237,6 @@ class Measurement:
self._time = f.attrs['time']
try:
qtys_json = f.attrs['qtys']
# Load quantity data
@ -244,10 +248,14 @@ class Measurement:
self._qtys = [SIQtys.default for i in range(self.nchannels)]
def setAttribute(self, atrname, value):
"""
Set an attribute in the measurement file, and keep a local copy in
memory for efficient accessing.
"""
with self.file('r+') as f:
# Update comment attribute in the file
f.attrs[atrname] = value
setattr(self, '_' + atrname, value)
setattr(self, '_' + atrname, value)
@property
def name(self):
@ -256,7 +264,7 @@ class Measurement:
@property
def channelNames(self):
return self._channel_names
return self._channelNames
@channelNames.setter
def channelNames(self, newchnames):

View File

@ -27,16 +27,16 @@ setup(
long_description_content_type="text/markdown",
# ext_modules=[CMakeExtension('lasp/wrappers.so'),
# ],
package_data={'lasp': ['wrappers.so']},
#package_data={'lasp': ['wrappers.so']},
author='J.A. de Jong - ASCEE',
author_email="j.a.dejong@ascee.nl",
install_requires=['matplotlib>=1.0',
'scipy>=1.0', 'numpy>=1.0', 'h5py',
'dataclasses_json',
'scipy>=1.0', 'numpy>=1.0', 'h5py==3.2.0',
'dataclasses_json', 'cython',
],
license='MIT',
description="Library for Acoustic Signal Processing",
keywords="",
url="https://www.ascee.nl/lasp/", # project home page, if any
url="https://www.ascee.nl/lasp/", # project home page
)