From 959bcafca303ddaa89ffcfd2d9f3c13c9b6f732f Mon Sep 17 00:00:00 2001 From: "J.A. de Jong - Redu-Sone B.V., ASCEE V.O.F" Date: Thu, 25 Feb 2021 12:15:37 +0100 Subject: [PATCH] Added quiescent tail to sweep implementation --- lasp/__init__.py | 1 + lasp/c/lasp_siggen.c | 14 +++++++++----- lasp/c/lasp_siggen.h | 6 ++++-- lasp/lasp_measurement.py | 2 ++ lasp/wrappers.pyx | 10 +++++----- 5 files changed, 21 insertions(+), 12 deletions(-) diff --git a/lasp/__init__.py b/lasp/__init__.py index 60b611a..bb7dfc5 100644 --- a/lasp/__init__.py +++ b/lasp/__init__.py @@ -1,6 +1,7 @@ from .lasp_atomic import * from .lasp_avstream import * from .lasp_common import * +from .lasp_imptube import * from .lasp_measurement import * from .lasp_octavefilter import * from .lasp_slm import * diff --git a/lasp/c/lasp_siggen.c b/lasp/c/lasp_siggen.c index b2d50cf..d9610b4 100644 --- a/lasp/c/lasp_siggen.c +++ b/lasp/c/lasp_siggen.c @@ -98,7 +98,7 @@ Siggen* Siggen_Noise_create(const d fs, const d level_dB, Sosfilterbank* colorfi } Siggen* Siggen_Sweep_create(const d fs,const d fl_,const d fu_, - const d Ts, const us flags, const d level_dB) { + const d Ts,const d Tq, const us flags, const d level_dB) { fsTRACE(15); Siggen* sweep = Siggen_create(SWEEP, fs, level_dB); @@ -119,13 +119,17 @@ Siggen* Siggen_Sweep_create(const d fs,const d fl_,const d fu_, const d Dt = 1/fs; // Deltat - // Estimate N: + // Estimate N, the number of samples in the sweep part (non-quiescent part): const us N = (us) (Ts*fs); + const us Nq = (us) (Tq*fs); iVARTRACE(15, N); - sp->data = vd_alloc(N); - sp->index = 0; - sp->N = N; + sp->data = vd_alloc(N+Nq); vd* data = &(sp->data); + /* Set the last part, the quiescent tail to zero */ + dmat_set(data,0.0); + + sp->N = N+Nq; + sp->index = 0; // Obtain flags and expand d phase = 0; diff --git a/lasp/c/lasp_siggen.h b/lasp/c/lasp_siggen.h index 2b14b63..d5ec290 100644 --- a/lasp/c/lasp_siggen.h +++ b/lasp/c/lasp_siggen.h @@ -62,13 +62,15 @@ us Siggen_getN(const Siggen*); * @param[in] fs: Sampling frequency [Hz] * @param[in] fl: Lower frequency [Hz] * @param[in] fl: Upper frequency [Hz] - * @param[in] Ts: Sweep period [s] + * @param[in] Ts: Sweep time [s] + * @param[in] Tq: Quescent tail time [s]. Choose this value long enough to + * avoid temporal aliasing in case of measuring impulse responses. * @param[in] sweep_flags: Sweep period [s] * @param[in] level: Relative level in [dB], should be between -inf and 0 * @return Siggen* handle */ Siggen* Siggen_Sweep_create(const d fs,const d fl,const d fu, - const d Ts, const us sweep_flags, + const d Ts, const d Tq, const us sweep_flags, const d level); /** diff --git a/lasp/lasp_measurement.py b/lasp/lasp_measurement.py index b6d1f4e..5b598f2 100644 --- a/lasp/lasp_measurement.py +++ b/lasp/lasp_measurement.py @@ -78,6 +78,7 @@ def scaleBlockSens(block, sens): sens: array of sensitivity coeficients for each channel. """ + sens = np.asarray(sens) assert sens.size == block.shape[1] if np.issubdtype(block.dtype.type, np.integer): sw = getSampWidth(block.dtype) @@ -86,6 +87,7 @@ def scaleBlockSens(block, sens): fac = 1. return block.astype(LASP_NUMPY_FLOAT_TYPE) / fac / sens[np.newaxis, :] + class IterRawData: """Iterate over stored blocks if the raw measurement data of a h5 file.""" diff --git a/lasp/wrappers.pyx b/lasp/wrappers.pyx index b7c1163..e9e6fa9 100644 --- a/lasp/wrappers.pyx +++ b/lasp/wrappers.pyx @@ -73,7 +73,7 @@ cdef extern from "lasp_python.h": __all__ = ['AvPowerSpectra', 'SosFilterBank', 'FilterBank', 'Siggen', 'sweep_flag_forward', 'sweep_flag_backward', 'sweep_flag_linear', - 'sweep_flag_exponential', 'sweep_flag_hyperbolic', + 'sweep_flag_exponential', 'load_fft_wisdom', 'store_fft_wisdom'] @@ -627,13 +627,13 @@ cdef class Decimator: cdef extern from "lasp_siggen.h": ctypedef struct c_Siggen "Siggen" us SWEEP_FLAG_FORWARD, SWEEP_FLAG_BACKWARD, SWEEP_FLAG_LINEAR - us SWEEP_FLAG_EXPONENTIAL,SWEEP_FLAG_HYPERBOLIC + us SWEEP_FLAG_EXPONENTIAL c_Siggen* Siggen_Noise_create(d fs, d level_dB, c_Sosfilterbank* colorfilter) c_Siggen* Siggen_Sinewave_create(d fs, d freq, d level_dB) c_Siggen* Siggen_Sweep_create(d fs, d fl, - d fu, d Ts,us sweep_flags, + d fu, d Ts,d Tq, us sweep_flags, d level_dB) us Siggen_getN(const c_Siggen*) void Siggen_genSignal(c_Siggen*, vd* samples) nogil @@ -645,7 +645,6 @@ sweep_flag_backward = SWEEP_FLAG_BACKWARD sweep_flag_linear = SWEEP_FLAG_LINEAR sweep_flag_exponential = SWEEP_FLAG_EXPONENTIAL -sweep_flag_hyperbolic = SWEEP_FLAG_HYPERBOLIC from .filter import PinkNoise @@ -717,11 +716,12 @@ cdef class Siggen: @staticmethod - def sweep(d fs, d fl, d fu, d Ts,us sweep_flags, d level_dB): + def sweep(d fs, d fl, d fu, d Ts, d Tq, us sweep_flags, d level_dB): cdef c_Siggen* c_siggen = Siggen_Sweep_create(fs, fl, fu, Ts, + Tq, sweep_flags, level_dB) if c_siggen == NULL: