From 69517112595e78ed9e5e742a29c15e5881607135 Mon Sep 17 00:00:00 2001 From: Tom Donoghue Date: Wed, 10 Apr 2024 00:57:18 -0400 Subject: [PATCH] fix up verboseness & warnings --- specparam/objs/event.py | 9 ++++----- specparam/objs/group.py | 4 ++-- specparam/objs/results.py | 9 ++++++--- specparam/objs/time.py | 15 +++++++++++++-- 4 files changed, 25 insertions(+), 12 deletions(-) diff --git a/specparam/objs/event.py b/specparam/objs/event.py index 7710c5c1..19c85168 100644 --- a/specparam/objs/event.py +++ b/specparam/objs/event.py @@ -68,8 +68,8 @@ def __init__(self, *args, **kwargs): BaseObject3D.__init__(self, aperiodic_mode=kwargs.pop('aperiodic_mode', 'fixed'), periodic_mode=kwargs.pop('periodic_mode', 'gaussian'), - debug_mode=kwargs.pop('debug_mode', 'False'), - verbose=kwargs.pop('verbose', 'True')) + debug_mode=kwargs.pop('debug_mode', False), + verbose=kwargs.pop('verbose', True)) SpectralFitAlgorithm.__init__(self, *args, **kwargs) @@ -222,8 +222,7 @@ def to_df(self, peak_org=None): def _check_width_limits(self): """Check and warn about bandwidth limits / frequency resolution interaction.""" - # Only check & warn on first spectrogram + # Only check & warn on first spectrum # This is to avoid spamming standard output for every spectrogram in the set - if np.all(self.spectrograms[0] == self.spectrogram): - #if self.power_spectra[0, 0] == self.power_spectrum[0]: + if np.all(self.power_spectrum == self.spectrograms[0, :, 0]): super()._check_width_limits() diff --git a/specparam/objs/group.py b/specparam/objs/group.py index 834024ad..4b633dd1 100644 --- a/specparam/objs/group.py +++ b/specparam/objs/group.py @@ -74,8 +74,8 @@ def __init__(self, *args, **kwargs): BaseObject2D.__init__(self, aperiodic_mode=kwargs.pop('aperiodic_mode', 'fixed'), periodic_mode=kwargs.pop('periodic_mode', 'gaussian'), - debug_mode=kwargs.pop('debug_mode', 'False'), - verbose=kwargs.pop('verbose', 'True')) + debug_mode=kwargs.pop('debug_mode', False), + verbose=kwargs.pop('verbose', True)) SpectralFitAlgorithm.__init__(self, *args, **kwargs) diff --git a/specparam/objs/results.py b/specparam/objs/results.py index 4189acf0..f94507c4 100644 --- a/specparam/objs/results.py +++ b/specparam/objs/results.py @@ -339,7 +339,8 @@ class BaseResults2D(BaseResults): def __init__(self, aperiodic_mode, periodic_mode, debug_mode=False, verbose=True): - BaseResults.__init__(self, aperiodic_mode, periodic_mode, debug_mode=False, verbose=True) + BaseResults.__init__(self, aperiodic_mode, periodic_mode, + debug_mode=debug_mode, verbose=verbose) self._reset_group_results() @@ -615,7 +616,8 @@ class BaseResults2DT(BaseResults2D): def __init__(self, aperiodic_mode, periodic_mode, debug_mode=False, verbose=True): - BaseResults2D.__init__(self, aperiodic_mode, periodic_mode, debug_mode=False, verbose=True) + BaseResults2D.__init__(self, aperiodic_mode, periodic_mode, + debug_mode=debug_mode, verbose=verbose) self._reset_time_results() @@ -756,7 +758,8 @@ class BaseResults3D(BaseResults2DT): def __init__(self, aperiodic_mode, periodic_mode, debug_mode=False, verbose=True): - BaseResults2DT.__init__(self, aperiodic_mode, periodic_mode, debug_mode=False, verbose=True) + BaseResults2DT.__init__(self, aperiodic_mode, periodic_mode, + debug_mode=debug_mode, verbose=verbose) self._reset_event_results() diff --git a/specparam/objs/time.py b/specparam/objs/time.py index 125ac578..4ad99fae 100644 --- a/specparam/objs/time.py +++ b/specparam/objs/time.py @@ -1,5 +1,7 @@ """Time model object and associated code for fitting the model to spectrograms.""" +import numpy as np + from specparam.objs import SpectralModel from specparam.objs.base import BaseObject2DT from specparam.objs.algorithm import SpectralFitAlgorithm @@ -60,8 +62,8 @@ def __init__(self, *args, **kwargs): BaseObject2DT.__init__(self, aperiodic_mode=kwargs.pop('aperiodic_mode', 'fixed'), periodic_mode=kwargs.pop('periodic_mode', 'gaussian'), - debug_mode=kwargs.pop('debug_mode', 'False'), - verbose=kwargs.pop('verbose', 'True')) + debug_mode=kwargs.pop('debug_mode', False), + verbose=kwargs.pop('verbose', True)) SpectralFitAlgorithm.__init__(self, *args, **kwargs) @@ -156,3 +158,12 @@ def to_df(self, peak_org=None): df = dict_to_df(self.get_results()) return df + + + def _check_width_limits(self): + """Check and warn about bandwidth limits / frequency resolution interaction.""" + + # Only check & warn on first power spectrum + # This is to avoid spamming standard output for every spectrum in the group + if np.all(self.power_spectrum == self.spectrogram[:, 0]): + super()._check_width_limits()