From 200ee69e2a5dd87b5ee0473e2240277b000fe8a5 Mon Sep 17 00:00:00 2001 From: "J.A. de Jong - Redu-Sone B.V., ASCEE V.O.F" Date: Tue, 22 Mar 2022 11:11:44 +0100 Subject: [PATCH] Renamed shelve to shelf, added some comments. --- lasp/c/lasp_pyarray.h | 4 ++++ lasp/c/lasp_python.h | 13 ++++--------- lasp/device/lasp_device_common.py | 2 +- lasp/filter/biquad.py | 22 +++++++++++----------- 4 files changed, 20 insertions(+), 21 deletions(-) diff --git a/lasp/c/lasp_pyarray.h b/lasp/c/lasp_pyarray.h index 90c9205..c5b39c3 100644 --- a/lasp/c/lasp_pyarray.h +++ b/lasp/c/lasp_pyarray.h @@ -37,6 +37,10 @@ static inline void capsule_cleanup(PyObject *capsule) { * @param data pointer to data, assumes d* for data * @param transfer_ownership If set to true, the created Numpy array will be * responsible for freeing the data. + * @param F_contiguous It set to true, the data is assumed to be column-major + * ordered in memory (which means we can find element d[r,c] by d[n_cols*r+c], + * if set to false. Data is assumed to be row-major ordered (which means we + * find element d[r,c] by d[n_rows*c+r] * * @return Numpy array */ diff --git a/lasp/c/lasp_python.h b/lasp/c/lasp_python.h index bdd1871..27dc8d9 100644 --- a/lasp/c/lasp_python.h +++ b/lasp/c/lasp_python.h @@ -17,17 +17,12 @@ #include "lasp_pyarray.h" /** - * @brief Create a numpy array from a buffer of floating point data + * @brief Create a Numpy array from a dmat structure * - * @param data Pointer - * @param n_rows Number of columns in the data - * @param n_cols Number of rows in the data + * @param mat Pointer to the dmat * @param transfer_ownership If set to true, the created Numpy array will - * obtain ownership of the data and calls free() on destruction. - * @param F_contiguous It set to true, the data is assumed to be column-major - * ordered in memory (which means we can find element d[r,c] by d[n_cols*r+c], - * if set to false. Data is assumed to be row-major ordered (which means we - * find element d[r,c] by d[n_rows*c+r] + * obtain ownership of the data and calls free() on destruction. The dmat will + * have the foreign_data flag set, such that it won't free the data. * * @return */ diff --git a/lasp/device/lasp_device_common.py b/lasp/device/lasp_device_common.py index e357b70..2606215 100644 --- a/lasp/device/lasp_device_common.py +++ b/lasp/device/lasp_device_common.py @@ -35,7 +35,7 @@ class DaqChannel: if 'highpass' in meta: self._highpass = meta['highpass'] except json.JSONDecodeError: - logging.debug('No JSON data found in DaqChannel {self.channel_name}') + logging.debug(f'No JSON data found in DaqChannel {self.channel_name}') @property def qty(self): diff --git a/lasp/filter/biquad.py b/lasp/filter/biquad.py index 2eb7891..dfff947 100644 --- a/lasp/filter/biquad.py +++ b/lasp/filter/biquad.py @@ -23,7 +23,7 @@ y[n] = 1/ba[3] * ( ba[0] * x[n] + ba[1] * x[n-1] + ba[2] * x[n-2] + """ __all__ = ['peaking', 'biquadTF', 'notch', 'lowpass', 'highpass', - 'highshelve', 'lowshelve'] + 'highshelf', 'lowshelf'] from numpy import array, cos, pi, sin, sqrt from scipy.interpolate import interp1d @@ -53,9 +53,9 @@ def peaking(fs, f0, Q, gain): return array([b0/a0, b1/a0, b2/a0, a0/a0, a1/a0, a2/a0]) -def notch(fs, f0, Q): +def notch(fs, f0, Q, gain=None): """ - Notch filter + Notch filter, parameter gain not used Args: fs: Sampling frequency [Hz] @@ -73,9 +73,9 @@ def notch(fs, f0, Q): return array([b0/a0, b1/a0, b2/a0, a0/a0, a1/a0, a2/a0]) -def lowpass(fs, f0, Q): +def lowpass(fs, f0, Q, gain=None): """ - Second order low pass filter + Second order low pass filter, parameter gain not used Args: fs: Sampling frequency [Hz] @@ -93,9 +93,9 @@ def lowpass(fs, f0, Q): return array([b0/a0, b1/a0, b2/a0, a0/a0, a1/a0, a2/a0]) -def highpass(fs, f0, Q): +def highpass(fs, f0, Q, gain=None): """ - Second order high pass filter + Second order high pass filter, parameter gain not used Args: fs: Sampling frequency [Hz] @@ -114,7 +114,7 @@ def highpass(fs, f0, Q): return array([b0/a0, b1/a0, b2/a0, a0/a0, a1/a0, a2/a0]) -def highshelve(fs, f0, Q, gain): +def highshelf(fs, f0, Q, gain): """ High shelving filter @@ -136,7 +136,7 @@ def highshelve(fs, f0, Q, gain): return array([b0/a0, b1/a0, b2/a0, a0/a0, a1/a0, a2/a0]) -def lowshelve(fs, f0, Q, gain): +def lowshelf(fs, f0, Q, gain): """ Low shelving filter @@ -158,7 +158,7 @@ def lowshelve(fs, f0, Q, gain): return array([b0/a0, b1/a0, b2/a0, a0/a0, a1/a0, a2/a0]) -def biquadTF(fs, freq, ba): +def biquadTF(fs, freq, sos): """ Computes the transfer function of the biquad. @@ -171,6 +171,6 @@ def biquadTF(fs, freq, ba): TODO: This code is not yet tested """ - freq2, h = sosfreqz(ba, worN=freq, fs=fs) + freq2, h = sosfreqz(sos, worN=freq.size, fs=fs) interpolator = interp1d(freq2, h, kind='quadratic') return interpolator(freq)