From 54173b6eccbac253d315ae5fc0a0f682c1fab764 Mon Sep 17 00:00:00 2001 From: "J.A. de Jong - ASCEE" Date: Fri, 3 Jan 2020 22:00:50 +0100 Subject: [PATCH] Did some renaming to make sure FIR filterbanks can coexist with SOS filterbanks --- lasp/filter/__init__.py | 9 ++++----- lasp/filter/{dec_fir.py => decimation_fir.py} | 0 .../{bandpass_fir.py => filterbank_design.py} | 2 +- ...s_limits.py => filterbank_standard_limits.py} | 0 ...eighting_fir.py => soundpressureweighting.py} | 3 ++- lasp/lasp_octavefilter.py | 16 ++++++++-------- lasp/lasp_slm.py | 2 +- lasp/lasp_weighcal.py | 4 +--- 8 files changed, 17 insertions(+), 19 deletions(-) rename lasp/filter/{dec_fir.py => decimation_fir.py} (100%) rename lasp/filter/{bandpass_fir.py => filterbank_design.py} (99%) rename lasp/filter/{bandpass_limits.py => filterbank_standard_limits.py} (100%) rename lasp/filter/{freqweighting_fir.py => soundpressureweighting.py} (97%) diff --git a/lasp/filter/__init__.py b/lasp/filter/__init__.py index db972a0..c0d9165 100644 --- a/lasp/filter/__init__.py +++ b/lasp/filter/__init__.py @@ -1,6 +1,5 @@ +from .soundpressureweighting import * +from .filterbank_design import OctaveBankDesigner, ThirdOctaveBankDesigner +from .filterbank_standard_limits import octave_band_limits, third_octave_band_limits +from .fir_design import * -from .freqweighting_fir import A, C -from .bandpass_fir import OctaveBankDesigner, ThirdOctaveBankDesigner -from .bandpass_limits import octave_band_limits, third_octave_band_limits - -__all__ = ['A', 'Z'] diff --git a/lasp/filter/dec_fir.py b/lasp/filter/decimation_fir.py similarity index 100% rename from lasp/filter/dec_fir.py rename to lasp/filter/decimation_fir.py diff --git a/lasp/filter/bandpass_fir.py b/lasp/filter/filterbank_design.py similarity index 99% rename from lasp/filter/bandpass_fir.py rename to lasp/filter/filterbank_design.py index f1d5124..1d43101 100644 --- a/lasp/filter/bandpass_fir.py +++ b/lasp/filter/filterbank_design.py @@ -51,7 +51,7 @@ class FilterBankDesigner: """ return self.fm(x)*self.G**(1/(2*self.b)) - def createFilter(self, fs, x): + def createFirFilter(self, fs, x): """ Create a FIR filter for band designator b and sampling frequency fs. Decimation should be obtained from decimation() method. diff --git a/lasp/filter/bandpass_limits.py b/lasp/filter/filterbank_standard_limits.py similarity index 100% rename from lasp/filter/bandpass_limits.py rename to lasp/filter/filterbank_standard_limits.py diff --git a/lasp/filter/freqweighting_fir.py b/lasp/filter/soundpressureweighting.py similarity index 97% rename from lasp/filter/freqweighting_fir.py rename to lasp/filter/soundpressureweighting.py index 0ecf929..ffa056d 100644 --- a/lasp/filter/freqweighting_fir.py +++ b/lasp/filter/soundpressureweighting.py @@ -3,7 +3,8 @@ """! Author: J.A. de Jong - ASCEE -Description: Filter design for frequency weightings A and C. +Description: Filter design for frequency weighting curves (i.e. A and C +weighting) """ from .fir_design import freqResponse, arbitrary_fir_design import numpy as np diff --git a/lasp/lasp_octavefilter.py b/lasp/lasp_octavefilter.py index 3a1c341..dd9b146 100644 --- a/lasp/lasp_octavefilter.py +++ b/lasp/lasp_octavefilter.py @@ -6,14 +6,14 @@ Author: J.A. de Jong - ASCEE Provides the FIR implementation of the octave filter bank """ -__all__ = ['OctaveFilterBank', 'ThirdOctaveFilterBank'] +__all__ = ['FirOctaveFilterBank', 'FirThirdOctaveFilterBank'] -from .filter.bandpass_fir import OctaveBankDesigner, ThirdOctaveBankDesigner +from .filter.filterbank_design import OctaveBankDesigner, ThirdOctaveBankDesigner from .wrappers import Decimator, FilterBank as pyxFilterBank import numpy as np -class FilterBank: +class FirFilterBank: """ Single channel octave filter bank implementation """ @@ -65,7 +65,7 @@ class FilterBank: # These are the filters that do not require lasp_decimation # prior to filtering nominals_txt.append(self.nominal_txt(x)) - firs[:, i] = self.createFilter(fs, x) + firs[:, i] = self.createFirFilter(fs, x) filterbank = {'fb': pyxFilterBank(firs, 1024), 'xs': xs, 'nominals': nominals_txt} @@ -136,17 +136,17 @@ class FilterBank: return output -class OctaveFilterBank(FilterBank, OctaveBankDesigner): +class FirOctaveFilterBank(FirFilterBank, OctaveBankDesigner): """ Filter bank which uses FIR filtering for each octave frequency band """ def __init__(self, fs): OctaveBankDesigner.__init__(self) - FilterBank.__init__(self, fs) + FirFilterBank.__init__(self, fs) -class ThirdOctaveFilterBank(FilterBank, ThirdOctaveBankDesigner): +class FirThirdOctaveFilterBank(FirFilterBank, ThirdOctaveBankDesigner): """ Filter bank which uses FIR filtering for each one-third octave frequency band. @@ -154,4 +154,4 @@ class ThirdOctaveFilterBank(FilterBank, ThirdOctaveBankDesigner): def __init__(self, fs): ThirdOctaveBankDesigner.__init__(self) - FilterBank.__init__(self, fs) + FirFilterBank.__init__(self, fs) diff --git a/lasp/lasp_slm.py b/lasp/lasp_slm.py index 644a328..930e265 100644 --- a/lasp/lasp_slm.py +++ b/lasp/lasp_slm.py @@ -47,7 +47,7 @@ class SLM: self._Lmax = 0. # Storage for computing the equivalent level - self._sq = 0. + self._sq = 0. # Square of the level data, storage self._N = 0 self._Leq = 0. diff --git a/lasp/lasp_weighcal.py b/lasp/lasp_weighcal.py index 2be8bd2..3d17989 100644 --- a/lasp/lasp_weighcal.py +++ b/lasp/lasp_weighcal.py @@ -4,10 +4,8 @@ Weighting and calibration filter in one @author: J.A. de Jong - ASCEE """ -from .filter.freqweighting_fir import A, C from .lasp_common import FreqWeighting -from .filter.fir_design import (arbitrary_fir_design, - freqResponse as frp) +from .filter import (A, C, arbitrary_fir_design, freqResponse as frp) from lasp.lasp_config import ones, empty from .wrappers import FilterBank import numpy as np