diff --git a/MDANSE/Src/MDANSE/Framework/Configurators/TrajectoryFilterConfigurator.py b/MDANSE/Src/MDANSE/Framework/Configurators/TrajectoryFilterConfigurator.py index 4a9efe9c0..6520c2fb5 100644 --- a/MDANSE/Src/MDANSE/Framework/Configurators/TrajectoryFilterConfigurator.py +++ b/MDANSE/Src/MDANSE/Framework/Configurators/TrajectoryFilterConfigurator.py @@ -43,8 +43,6 @@ def filter_default_attributes(cls, filter=_filter): The filter settings dictionary """ - filter.set_defaults() - return {setting: values["value"] for setting, values in filter.default_settings.items()} _settings = filter_default_attributes.__func__(object()) diff --git a/MDANSE/Src/MDANSE/Mathematics/Signal.py b/MDANSE/Src/MDANSE/Mathematics/Signal.py index 1a9f279b4..868db360f 100644 --- a/MDANSE/Src/MDANSE/Mathematics/Signal.py +++ b/MDANSE/Src/MDANSE/Mathematics/Signal.py @@ -347,9 +347,6 @@ class FrequencyRangeMethod(Enum): @abstractmethod def __init__(self, **kwargs): - if not hasattr(self, "default_settings"): - self.__class__.set_defaults() - # Number of simulation steps self.n_steps = kwargs.pop("n_steps") # Simulation sample frequency in pHz @@ -642,21 +639,18 @@ def energy_to_freq(cls, energy): class Butterworth(Filter): """Interface for the butterworth filter.""" - @classmethod - def set_defaults(cls) -> None: - """Set up the default filter settings.""" - cls.default_settings = { - "order": {"description": "The order of the filter", "value": 1}, - "attenuation_type": { - "description": "Filter attenuation type", - "values": {"lowpass", "highpass", "bandpass", "bandstop"}, - "value": "lowpass", - }, - "cutoff_freq": { - "description": "Cutoff frequency/vibrational energy (may be a 2-length array if bandpass/stop)", - "value": DEFAULT_FILTER_CUTOFF, - }, - } + default_settings = { + "order": {"description": "The order of the filter", "value": 1}, + "attenuation_type": { + "description": "Filter attenuation type", + "values": {"lowpass", "highpass", "bandpass", "bandstop"}, + "value": "lowpass", + }, + "cutoff_freq": { + "description": "Cutoff frequency/vibrational energy (may be a 2-length array if bandpass/stop)", + "value": DEFAULT_FILTER_CUTOFF, + }, + } def __init__(self, **kwargs): super().__init__(**kwargs) @@ -675,26 +669,22 @@ def __init__(self, **kwargs): class ChebyshevTypeI(Filter): """ """ - - @classmethod - def set_defaults(cls) -> None: - """Set up the default filter settings.""" - cls.default_settings = { - "order": {"description": "The order of the filter", "value": 1}, - "max_ripple": { - "description": "Decibel measure of maximum ripple allowed below unit gain in the passband", - "value": 5.0, - }, - "attenuation_type": { - "description": "Filter attenuation type", - "values": {"lowpass", "highpass", "bandpass", "bandstop"}, - "value": "lowpass", - }, - "cutoff_freq": { - "description": "Cutoff frequency/vibrational energy (may be a 2-length array if bandpass/stop)", - "value": DEFAULT_FILTER_CUTOFF, - }, - } + default_settings = { + "order": {"description": "The order of the filter", "value": 1}, + "max_ripple": { + "description": "Decibel measure of maximum ripple allowed below unit gain in the passband", + "value": 5.0, + }, + "attenuation_type": { + "description": "Filter attenuation type", + "values": {"lowpass", "highpass", "bandpass", "bandstop"}, + "value": "lowpass", + }, + "cutoff_freq": { + "description": "Cutoff frequency/vibrational energy (may be a 2-length array if bandpass/stop)", + "value": DEFAULT_FILTER_CUTOFF, + }, + } def __init__(self, **kwargs): super().__init__(**kwargs) @@ -714,26 +704,22 @@ def __init__(self, **kwargs): class ChebyshevTypeII(Filter): """ """ - - @classmethod - def set_defaults(cls) -> None: - """Set up the default filter settings.""" - cls.default_settings = { - "order": {"description": "The order of the filter", "value": 1}, - "min_attenuation": { - "description": "Decibel measure of minimum attenuation required in the stopband", - "value": 20.0, - }, - "attenuation_type": { - "description": "Filter attenuation type", - "values": {"lowpass", "highpass", "bandpass", "bandstop"}, - "value": "lowpass", - }, - "cutoff_freq": { - "description": "Cutoff frequency/vibrational energy (may be a 2-length array if bandpass/stop)", - "value": DEFAULT_FILTER_CUTOFF, - }, - } + default_settings = { + "order": {"description": "The order of the filter", "value": 1}, + "min_attenuation": { + "description": "Decibel measure of minimum attenuation required in the stopband", + "value": 20.0, + }, + "attenuation_type": { + "description": "Filter attenuation type", + "values": {"lowpass", "highpass", "bandpass", "bandstop"}, + "value": "lowpass", + }, + "cutoff_freq": { + "description": "Cutoff frequency/vibrational energy (may be a 2-length array if bandpass/stop)", + "value": DEFAULT_FILTER_CUTOFF, + }, + } def __init__(self, **kwargs): super().__init__(**kwargs) @@ -753,30 +739,26 @@ def __init__(self, **kwargs): class Elliptical(Filter): """ """ - - @classmethod - def set_defaults(cls) -> None: - """Set up the default filter settings.""" - cls.default_settings = { - "order": {"description": "The order of the filter", "value": 1}, - "max_ripple": { - "description": "Decibel measure of maximum ripple allowed below unit gain in the passband", - "value": 5.0, - }, - "min_attenuation": { - "description": "Decibel measure of minimum attenuation required in the stopband", - "value": 20.0, - }, - "attenuation_type": { - "description": "Filter attenuation type", - "values": {"lowpass", "highpass", "bandpass", "bandstop"}, - "value": "lowpass", - }, - "cutoff_freq": { - "description": "Cutoff frequency/vibrational energy (may be a 2-length array if bandpass/stop)", - "value": DEFAULT_FILTER_CUTOFF, - }, - } + default_settings = { + "order": {"description": "The order of the filter", "value": 1}, + "max_ripple": { + "description": "Decibel measure of maximum ripple allowed below unit gain in the passband", + "value": 5.0, + }, + "min_attenuation": { + "description": "Decibel measure of minimum attenuation required in the stopband", + "value": 20.0, + }, + "attenuation_type": { + "description": "Filter attenuation type", + "values": {"lowpass", "highpass", "bandpass", "bandstop"}, + "value": "lowpass", + }, + "cutoff_freq": { + "description": "Cutoff frequency/vibrational energy (may be a 2-length array if bandpass/stop)", + "value": DEFAULT_FILTER_CUTOFF, + }, + } def __init__(self, **kwargs): super().__init__(**kwargs) @@ -797,27 +779,23 @@ def __init__(self, **kwargs): class Bessel(Filter): """ """ - - @classmethod - def set_defaults(cls) -> None: - """Set up the default filter settings.""" - cls.default_settings = { - "order": {"description": "The order of the filter", "value": 1}, - "norm": { - "description": "Filter normalization results in the following behaviour at cutoff - phase: phase response obtains midpoint - delay: group delay in passband is the reciprocal of cutoff - mag: gain magnitude is -3 dB", - "values": {"phase", "delay", "mag"}, - "value": "phase", - }, - "attenuation_type": { - "description": "Filter attenuation type", - "values": {"lowpass", "highpass", "bandpass", "bandstop"}, - "value": "lowpass", - }, - "cutoff_freq": { - "description": "Cutoff frequency/vibrational energy (may be a 2-length array if bandpass/stop)", - "value": DEFAULT_FILTER_CUTOFF, - }, - } + default_settings = { + "order": {"description": "The order of the filter", "value": 1}, + "norm": { + "description": "Filter normalization results in the following behaviour at cutoff - phase: phase response obtains midpoint - delay: group delay in passband is the reciprocal of cutoff - mag: gain magnitude is -3 dB", + "values": {"phase", "delay", "mag"}, + "value": "phase", + }, + "attenuation_type": { + "description": "Filter attenuation type", + "values": {"lowpass", "highpass", "bandpass", "bandstop"}, + "value": "lowpass", + }, + "cutoff_freq": { + "description": "Cutoff frequency/vibrational energy (may be a 2-length array if bandpass/stop)", + "value": DEFAULT_FILTER_CUTOFF, + }, + } def __init__(self, **kwargs): super().__init__(**kwargs) @@ -837,23 +815,19 @@ def __init__(self, **kwargs): class Notch(Filter): """ """ + default_settings = { + "fundamental_freq": { + "description": "Spacing between filter peaks (value must evenly divide sample frequency)", + "value": DEFAULT_FILTER_CUTOFF, + }, + "quality_factor": { + "description": "Specifies bandwidth, proportional to time taken for filter to decay by a factor of 1/e", + "value": 1.0, + }, + } digital_only = True - @classmethod - def set_defaults(cls) -> None: - """Set up the default filter settings.""" - cls.default_settings = { - "fundamental_freq": { - "description": "Spacing between filter peaks (value must evenly divide sample frequency)", - "value": DEFAULT_FILTER_CUTOFF, - }, - "quality_factor": { - "description": "Specifies bandwidth, proportional to time taken for filter to decay by a factor of 1/e", - "value": 1.0, - }, - } - def __init__(self, **kwargs): super().__init__(**kwargs) @@ -873,23 +847,19 @@ def compute_frequencies( class Peak(Filter): """ """ + default_settings = { + "fundamental_freq": { + "description": "Spacing between filter peaks (value must evenly divide sample frequency)", + "value": DEFAULT_FILTER_CUTOFF, + }, + "quality_factor": { + "description": "Specifies bandwidth, proportional to time taken for filter to decay by a factor of 1/e", + "value": 1.0, + }, + } digital_only = True - @classmethod - def set_defaults(cls) -> None: - """Set up the default filter settings.""" - cls.default_settings = { - "fundamental_freq": { - "description": "Spacing between filter peaks (value must evenly divide sample frequency)", - "value": DEFAULT_FILTER_CUTOFF, - }, - "quality_factor": { - "description": "Specifies bandwidth, proportional to time taken for filter to decay by a factor of 1/e", - "value": 1.0, - }, - } - def __init__(self, **kwargs): super().__init__(**kwargs) @@ -909,33 +879,29 @@ def compute_frequencies( class Comb(Filter): """ """ + default_settings = { + "fundamental_freq": { + "description": "Spacing between filter peaks (value must evenly divide sample frequency)", + "value": DEFAULT_FILTER_CUTOFF, + }, + "quality_factor": { + "description": "Specifies bandwidth, proportional to time taken for filter to decay by a factor of 1/e", + "value": 1.0, + }, + "comb_type": { + "description": "Determines whether quality factor applies to notches or peaks", + "values": {"peak", "notch"}, + "value": "notch", + }, + "pass_zero": { + "description": "Determines whether notches or peaks centered on integer multiples of fundamental frequency", + "values": {True, False}, + "value": False, + }, + } digital_only = True - @classmethod - def set_defaults(cls) -> None: - """Set up the default filter settings.""" - cls.default_settings = { - "fundamental_freq": { - "description": "Spacing between filter peaks (value must evenly divide sample frequency)", - "value": DEFAULT_FILTER_CUTOFF, - }, - "quality_factor": { - "description": "Specifies bandwidth, proportional to time taken for filter to decay by a factor of 1/e", - "value": 1.0, - }, - "comb_type": { - "description": "Determines whether quality factor applies to notches or peaks", - "values": {"peak", "notch"}, - "value": "notch", - }, - "pass_zero": { - "description": "Determines whether notches or peaks centered on integer multiples of fundamental frequency", - "values": {True, False}, - "value": False, - }, - } - def __init__(self, **kwargs): super().__init__(**kwargs) diff --git a/MDANSE_GUI/Src/MDANSE_GUI/InputWidgets/TrajectoryFilterWidget.py b/MDANSE_GUI/Src/MDANSE_GUI/InputWidgets/TrajectoryFilterWidget.py index 771691378..de8909756 100644 --- a/MDANSE_GUI/Src/MDANSE_GUI/InputWidgets/TrajectoryFilterWidget.py +++ b/MDANSE_GUI/Src/MDANSE_GUI/InputWidgets/TrajectoryFilterWidget.py @@ -374,7 +374,6 @@ def make_settings_grid(self, filter: Filter, grid: QGridLayout) -> None: filter : Filter Selected filter class (one of [Butterworth, ChebyshevTypeI, ChebyshevTypeII, Elliptical, Bessel, Notch, Peak, Comb]) """ - filter.set_defaults() setting_items = filter.default_settings.items() # Add filter settings to grid layout