Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions pyleoclim/core/ensembleseries.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@
from ..core.multipleseries import MultipleSeries

import warnings
warnings.filterwarnings("ignore")

import seaborn as sns
import matplotlib.pyplot as plt
import numpy as np
Expand Down
28 changes: 15 additions & 13 deletions pyleoclim/core/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -3320,9 +3320,6 @@ def spectral(self, method='lomb_scargle', freq=None, freq_kwargs=None, settings=
fig, ax = psd_cwt_signif.plot(title='PSD using the CWT method')

'''
if not verbose:
warnings.simplefilter('ignore')

settings = {} if settings is None else settings.copy()
spec_func = {
'wwz': specutils.wwz_psd,
Expand Down Expand Up @@ -3383,7 +3380,10 @@ def spectral(self, method='lomb_scargle', freq=None, freq_kwargs=None, settings=
args['cwt'].update({'cwt_res':res})


spec_res = spec_func[method](self.value, self.time, **args[method])
with warnings.catch_warnings():
if not verbose:
warnings.simplefilter('ignore')
spec_res = spec_func[method](self.value, self.time, **args[method])
if type(spec_res) is dict:
spec_res = dict2namedtuple(spec_res)

Expand Down Expand Up @@ -3510,9 +3510,6 @@ def wavelet(self, method='cwt', settings=None, freq=None, freq_kwargs=None, verb
fig, ax = scal4.plot(title='WWZ scalogram with finer time axis')

'''
if not verbose:
warnings.simplefilter('ignore')

# Assign method
if method == 'cwt' and not(self.is_evenly_spaced()):
raise ValueError("The chosen method is cwt but the series is unevenly spaced. You can either interpolate/bin or set method='wwz'.")
Expand Down Expand Up @@ -3556,7 +3553,10 @@ def wavelet(self, method='cwt', settings=None, freq=None, freq_kwargs=None, verb
args[method].update(settings)

# Apply wavelet method
wave_res = wave_func[method](self.value, self.time, **args[method])
with warnings.catch_warnings():
if not verbose:
warnings.simplefilter('ignore')
wave_res = wave_func[method](self.value, self.time, **args[method])

# Export result
if method == 'wwz':
Expand Down Expand Up @@ -3704,9 +3704,6 @@ def wavelet_coherence(self, target_series, method='cwt', settings=None,


'''
if not verbose:
warnings.simplefilter('ignore')

settings = {} if settings is None else settings.copy()

wtc_func = {
Expand Down Expand Up @@ -3740,7 +3737,9 @@ def wavelet_coherence(self, target_series, method='cwt', settings=None,

# put on same time axes if necessary
if method == 'cwt' and not np.array_equal(self.time, target_series.time):
warnings.warn("Series have different time axes. Applying common_time().")
warnings.warn("Series have different time axes. Applying common_time(), which will "
"interpolate/resample the data onto a shared time axis.",
category=tsbase.DataConformationWarning)
ms = MultipleSeries([self, target_series])
common_time_kwargs = {} if common_time_kwargs is None else common_time_kwargs.copy()
ct_args = {'method': 'interp'}
Expand Down Expand Up @@ -3776,7 +3775,10 @@ def wavelet_coherence(self, target_series, method='cwt', settings=None,
args[method].update(settings)

# Apply WTC method
wtc_res = wtc_func[method](ts1.value, ts1.time, ts2.value, ts2.time, **args[method])
with warnings.catch_warnings():
if not verbose:
warnings.simplefilter('ignore')
wtc_res = wtc_func[method](ts1.value, ts1.time, ts2.value, ts2.time, **args[method])

# Export result
coh = Coherence(
Expand Down
10 changes: 10 additions & 0 deletions pyleoclim/utils/tsbase.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,18 @@
'sort_ts',
'is_evenly_spaced',
'reduce_duplicated_timestamps',
'DataConformationWarning',
]

class DataConformationWarning(UserWarning):
'''Warning raised when pyleoclim silently modifies user data (e.g. interpolation,
resampling onto a common time axis) rather than merely commenting on it.

Unlike ordinary UserWarnings, these are not meant to be silenced by verbose=False,
since they signal that the data being analyzed differs from what the user supplied.
'''
pass

# UDUNITS, see: http://cfconventions.org/cf-conventions/cf-conventions#time-coordinate
SECONDS_PER_YEAR = 31556925.974592 # 86400 * 365.24219878

Expand Down
Loading