From 2d05019f61ac91d43444545d365c265de3d99539 Mon Sep 17 00:00:00 2001 From: "J.A. de Jong - Redu-Sone B.V., ASCEE V.O.F" Date: Sun, 23 May 2021 15:13:11 +0200 Subject: [PATCH] Bugfixes: smoothing, measurement file attribute channelNames is now definite. Improved error messages --- lasp/lasp_avstream.py | 6 +++++- lasp/lasp_common.py | 4 ++-- lasp/lasp_measurement.py | 6 ++++-- lasp/lasp_record.py | 2 +- lasp/lasp_siggen.py | 6 +++++- lasp/tools/tools.py | 2 -- setup.py | 16 +--------------- 7 files changed, 18 insertions(+), 24 deletions(-) diff --git a/lasp/lasp_avstream.py b/lasp/lasp_avstream.py index 6b9c0ed..8beb4b4 100644 --- a/lasp/lasp_avstream.py +++ b/lasp/lasp_avstream.py @@ -192,6 +192,8 @@ class AvStreamProcess(mp.Process): output to the devices. """ + super().__init__() + self.pipe = pipe self.msg_qlist = msg_qlist self.indata_qlist = indata_qlist @@ -203,7 +205,9 @@ class AvStreamProcess(mp.Process): # In, out, duplex self.streams = {t: None for t in list(AvType)} - super().__init__() + # When this is set, a kill on the main process will also kill the + # siggen process. Highly wanted feature + self.daemon = True def run(self): """ diff --git a/lasp/lasp_common.py b/lasp/lasp_common.py index 10a1b31..3490e5e 100644 --- a/lasp/lasp_common.py +++ b/lasp/lasp_common.py @@ -79,7 +79,7 @@ class SIQtys: unit_name='No unit / full scale', unit_symb='-', level_unit=('dBFS',), - level_ref_name=('Full scale sine wave',), + level_ref_name=('Relative to full scale sine wave',), level_ref_value=(dBFS_REF,) ) AP = Qty(name='Acoustic Pressure', @@ -98,7 +98,7 @@ class SIQtys: level_ref_value=(1.0,), ) types = (N, AP, V) - default = AP + default = N default_index = 0 @staticmethod diff --git a/lasp/lasp_measurement.py b/lasp/lasp_measurement.py index 3373a26..76d0c25 100644 --- a/lasp/lasp_measurement.py +++ b/lasp/lasp_measurement.py @@ -211,12 +211,14 @@ class Measurement: # Due to a previous bug, the channel names were not stored # consistently, i.e. as 'channel_names' and later camelcase. try: - self._channelNames = f.attrs['channel_names'] + self._channelNames = f.attrs['channelNames'] except KeyError: try: - self._channelNames = f.attrs['channelNames'] + self._channelNames = f.attrs['channel_names'] + logging.info("Measurement file obtained which stores channel names with *old* attribute 'channel_names'") except KeyError: # No channel names found in measurement file + logging.info('No channel name data found in measurement') self._channelNames = [f'Unnamed {i}' for i in range(self.nchannels)] # comment = read-write thing diff --git a/lasp/lasp_record.py b/lasp/lasp_record.py index 6407e5a..e94f748 100644 --- a/lasp/lasp_record.py +++ b/lasp/lasp_record.py @@ -194,7 +194,7 @@ class Recording: f.attrs['nchannels'] = nchannels f.attrs['blocksize'] = blocksize f.attrs['sensitivity'] = [ch.sensitivity for ch in md.in_ch] - f.attrs['channel_names'] = [ch.channel_name for ch in md.in_ch] + f.attrs['channelNames'] = [ch.channel_name for ch in md.in_ch] f.attrs['time'] = time.time() self.blocksize = blocksize self.fs = md.fs diff --git a/lasp/lasp_siggen.py b/lasp/lasp_siggen.py index bbff602..1f73647 100644 --- a/lasp/lasp_siggen.py +++ b/lasp/lasp_siggen.py @@ -111,6 +111,11 @@ class SiggenProcess(mp.Process): dataq: The queue to put generated signal on pipe: Control and status messaging pipe """ + super().__init__() + + # When this is set, a kill on the main process will also kill the + # siggen process. Highly wanted feature + self.daemon = True self.dataq = dataq self.siggendata = siggendata @@ -123,7 +128,6 @@ class SiggenProcess(mp.Process): self.nblocks_buffer = max( 1, int(QUEUE_BUFFER_TIME * fs/ nframes_per_block) ) - super().__init__() def newSiggen(self, siggendata: SiggenData): """ diff --git a/lasp/tools/tools.py b/lasp/tools/tools.py index 57721ca..07b88ca 100644 --- a/lasp/tools/tools.py +++ b/lasp/tools/tools.py @@ -154,8 +154,6 @@ def smoothSpectralData(freq, M, sw: SmoothingWidth, if st == SmoothingType.levels: Psm = 10*np.log10(Psm) - elif st == SmoothingType.tf: - Psm = np.sqrt(Psm) return Psm diff --git a/setup.py b/setup.py index 409e566..902c565 100644 --- a/setup.py +++ b/setup.py @@ -1,24 +1,10 @@ -#!/usr/bin/env python3 +#!/usr/bin/env python3.8 # -*- coding: utf-8 -*- """ @author: J.A. de Jong - ASCEE """ from setuptools import setup, find_packages - -# class CMakeExtension(Extension): -# """ -# An extension to run the cmake build -# -# This simply overrides the base extension class so that setuptools -# doesn't try to build your sources for you -# """ -# -# def __init__(self, name, sources=[]): -# -# super().__init__(name=name, sources=sources) - - setup( name="LASP", version="1.0",