From 4c0f399505e59230e5e3f467bd06c9e2dc9d70ec Mon Sep 17 00:00:00 2001 From: Casper Date: Mon, 9 Aug 2021 09:51:51 +0200 Subject: [PATCH] Added comments and maybe some minor repairs. --- lasp/__init__.py | 26 ++++++++++++++------------ lasp/c/lasp_ps.c | 2 +- lasp/filter/__init__.py | 13 ++++++++----- lasp/filter/filterbank_design.py | 5 ++--- lasp/lasp_record.py | 2 +- lasp/tools/tools.py | 9 ++++++--- 6 files changed, 32 insertions(+), 25 deletions(-) diff --git a/lasp/__init__.py b/lasp/__init__.py index 85eb2d1..a5254ee 100644 --- a/lasp/__init__.py +++ b/lasp/__init__.py @@ -1,12 +1,14 @@ -from .lasp_common import * -from .lasp_avstream import * -from .wrappers import * -from .lasp_atomic import * -from .lasp_imptube import * -from .lasp_measurement import * -from .lasp_octavefilter import * -from .lasp_slm import * -from .lasp_record import * -from .lasp_siggen import * -from .lasp_weighcal import * -from .tools import * +# Comments are what is imported, state of 6-8-2021 + +from .lasp_common import * # P_REF, FreqWeighting, TimeWeighting, getTime, getFreq, Qty, SIQtys, Window, lasp_shelve, this_lasp_shelve, W_REF, U_REF, I_REF, dBFS_REF, AvType +from .lasp_avstream import * # StreamManager, ignoreSigInt, StreamStatus +from .wrappers import * # AvPowerSpectra, SosFilterBank, FilterBank, Siggen, sweep_flag_forward, sweep_flag_backward, sweep_flag_linear, sweep_flag_exponential, load_fft_wisdom, store_fft_wisdom +from .lasp_atomic import * # Atomic +from .lasp_imptube import * # TwoMicImpedanceTube +from .lasp_measurement import * # Measurement, scaleBlockSens +from .lasp_octavefilter import * # FirOctaveFilterBank, FirThirdOctaveFilterBank, OverallFilterBank, SosOctaveFilterBank, SosThirdOctaveFilterBank +from .lasp_slm import * # SLM, Dummy +from .lasp_record import * # RecordStatus, Recording +from .lasp_siggen import * # SignalType, NoiseType, SiggenMessage, SiggenData, Siggen +from .lasp_weighcal import * # WeighCal +from .tools import * # SmoothingType, smoothSpectralData, SmoothingWidth diff --git a/lasp/c/lasp_ps.c b/lasp/c/lasp_ps.c index f78ee68..bc0a244 100644 --- a/lasp/c/lasp_ps.c +++ b/lasp/c/lasp_ps.c @@ -117,7 +117,7 @@ void PowerSpectra_compute(const PowerSpectra* ps, TRACE(15,"fft done"); - /* Scale fft such that power is easily comxputed */ + /* Scale fft such that power is easily computed */ const c scale_fac = d_sqrt(2/win_pow)/nfft; cmat_scale(&fft_work,scale_fac); TRACE(15,"scale done"); diff --git a/lasp/filter/__init__.py b/lasp/filter/__init__.py index 3ee2d04..b70dcd8 100644 --- a/lasp/filter/__init__.py +++ b/lasp/filter/__init__.py @@ -1,5 +1,8 @@ -from .soundpressureweighting import * -from .filterbank_design import * -from .fir_design import * -from .colorednoise import * -from .biquad import * +# Comments what modules are imported are state of 6-8-2021. + +from .soundpressureweighting import * # SPLFilterDesigner +from .filterbank_design import * # OctaveBankDesigner, ThirdOctaveBankDesigner +from .fir_design import * # freqResponse, bandpass_fir_design, lowpass_fir_design, arbitrary_fir_design +from .colorednoise import * # PinkNoise # not imported: BrownianNoise, BlueNoise +from .biquad import * # peaking, biquadTF, notch, lowpass, highpass, highshelve, lowshelve +# Nothing is imported from decimation_fir.py diff --git a/lasp/filter/filterbank_design.py b/lasp/filter/filterbank_design.py index 9cdd62c..efdf720 100644 --- a/lasp/filter/filterbank_design.py +++ b/lasp/filter/filterbank_design.py @@ -81,7 +81,7 @@ class FilterBankDesigner: if self.nominal_txt(x) == nom_txt: return x raise ValueError( - f'Could not find an x-value corresponding to {nom_txt}.') + f'Could not find a nominal frequency corresponding to {nom_txt}. Hint: use \'5k\' instead of \'5000\'.') def sanitize_input(self, input_): if isinstance(input_, int): @@ -492,7 +492,7 @@ class ThirdOctaveBankDesigner(FilterBankDesigner): index_start = x[0] - self.xs[0] index_stop = x[-1] - self.xs[0] return self._nominal_txt[index_start:index_stop+1] - + def band_limits(self, x, filter_class=0): """Returns the third octave band filter limits for filter designator x. @@ -601,4 +601,3 @@ class ThirdOctaveBankDesigner(FilterBankDesigner): else: raise ValueError('Unimplemented sampling frequency for SOS' 'filter design') - diff --git a/lasp/lasp_record.py b/lasp/lasp_record.py index e94f748..ff99b3e 100644 --- a/lasp/lasp_record.py +++ b/lasp/lasp_record.py @@ -160,7 +160,7 @@ class Recording: return # The 'Audio' dataset as specified in lasp_measurement, where data is - # send to. We use gzip as compression, this gives moderate a moderate + # sent to. We use gzip as compression, this gives moderate a moderate # compression to the data. f = self.f blocksize = md.blocksize diff --git a/lasp/tools/tools.py b/lasp/tools/tools.py index 742f7b0..c158b3c 100644 --- a/lasp/tools/tools.py +++ b/lasp/tools/tools.py @@ -101,9 +101,12 @@ def smoothSpectralData(freq, M, sw: SmoothingWidth, # elif st == SmoothingType.tf: # P = P**2 - Psm = np.zeros_like(P) # smoothed power - to be calculated - x0 = 1 if freq[0]==0 else 0 # skip first data point if zero frequency - df = freq[1] - freq[0] # frequency step + # P is power while smoothing. x are indices of P. + Psm = np.zeros_like(P) # Smoothed power - to be calculated + x0 = 1 if freq[0]==0 else 0 # Skip first data point if zero frequency + Psm[0] = P[0] # Reuse old value in case first data.. + # ..point is skipped. Not plotted any way. + df = freq[1] - freq[0] # Frequency step # Loop through data points for x in range(x0, L):