Added quiescent tail to sweep implementation

This commit is contained in:
Anne de Jong 2021-02-25 12:15:37 +01:00
parent a1e4a63043
commit 959bcafca3
5 changed files with 21 additions and 12 deletions

View File

@ -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 *

View File

@ -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;

View File

@ -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);
/**

View File

@ -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."""

View File

@ -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: