From 5a051d21a1e5f7bfb4591d1b9e4d2031391badd6 Mon Sep 17 00:00:00 2001 From: Casper Date: Tue, 10 Sep 2024 13:40:47 +0200 Subject: [PATCH] Measurement.fromnpy(): accept sensitivity as scalar or 0-dim numpy.ndarray --- python_src/lasp/__init__.py | 6 +++--- python_src/lasp/lasp_measurement.py | 11 ++++------- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/python_src/lasp/__init__.py b/python_src/lasp/__init__.py index d28c3e8..58c09c8 100644 --- a/python_src/lasp/__init__.py +++ b/python_src/lasp/__init__.py @@ -10,11 +10,11 @@ from .lasp_cpp import * # from .lasp_imptube import * # TwoMicImpedanceTube from .lasp_measurement import * # Measurement, scaleBlockSens -from .lasp_octavefilter import * +from .lasp_octavefilter import * # OverallFilterBank, SosOctaveFilterBank, SosThirdOctaveFilterBank from .lasp_slm import * # SLM, Dummy from .lasp_record import * # RecordStatus, Recording -from .lasp_daqconfigs import * -from .lasp_measurementset import * +from .lasp_daqconfigs import * # DaqConfigurations +from .lasp_measurementset import * # MeasurementSet # from .lasp_siggen import * # SignalType, NoiseType, SiggenMessage, SiggenData, Siggen # from .lasp_weighcal import * # WeighCal diff --git a/python_src/lasp/lasp_measurement.py b/python_src/lasp/lasp_measurement.py index 1843360..3463900 100644 --- a/python_src/lasp/lasp_measurement.py +++ b/python_src/lasp/lasp_measurement.py @@ -77,9 +77,9 @@ class MeasurementType(Enum): Measurement flags related to the measurement. Stored as bit flags in the measurement file. This is for possible changes in the API later. """ - # Not specific measurement type + # Not specific measurement type NotSpecific = 0 - + # Measurement serves as an insertion loss reference measurement ILReference = 1 << 0 @@ -1156,11 +1156,8 @@ class Measurement: if data.ndim != 2: data = data[:, np.newaxis] - try: - len(sensitivity) - except: - raise ValueError("Sensitivity should be given as array-like data type") - sensitivity = np.asarray(sensitivity) + if not (isinstance(sensitivity, np.ndarray) and sensitivity.ndim >= 1): + sensitivity = np.asarray(sensitivity)[np.newaxis] nchannels = data.shape[1] if nchannels != sensitivity.shape[0]: