Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update series.py #485

Merged
merged 5 commits into from
Jan 3, 2024
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
4 changes: 4 additions & 0 deletions pyleoclim/core/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -3257,11 +3257,15 @@ def wavelet_coherence(self, target_series, method='cwt', settings=None,
if method == 'wwz':
if 'ntau' in settings.keys():
ntau = settings['ntau']
settings.pop('ntau')
else:
ntau = np.min([np.size(ts1.time), np.size(ts2.time), 50])

tau = np.linspace(np.min(self.time), np.max(self.time), ntau)
if 'tau' in settings.keys():
tau = settings['tau']
settings.update({'tau': tau})


args[method].update(settings)

Expand Down
22 changes: 18 additions & 4 deletions pyleoclim/tests/test_core_Series.py
Original file line number Diff line number Diff line change
Expand Up @@ -950,9 +950,8 @@ def test_xwave_t1(self):
def test_xwave_t2(self,mother):
''' Test Series.wavelet_coherence() with CWT with mother wavelet specified via `settings`
'''
nt = 500
ts1 = gen_ts(model='colored_noise', nt=nt)
ts2 = gen_ts(model='colored_noise', nt=nt)
ts1 = gen_ts(model='colored_noise')
ts2 = gen_ts(model='colored_noise')
_ = ts1.wavelet_coherence(ts2,method='cwt',settings={'mother':mother})

def test_xwave_t3(self):
Expand All @@ -971,7 +970,22 @@ def test_xwave_t3(self):
v1_unevenly = np.delete(ts2.value, deleted_idx1)
ts3 = pyleo.Series(time=t_unevenly, value=v_unevenly)
ts4 = pyleo.Series(time=t1_unevenly, value=v1_unevenly)
scal = ts3.wavelet_coherence(ts4,method='wwz')
_ = ts3.wavelet_coherence(ts4,method='wwz')

def test_xwave_t5(self):
''' Test Series.wavelet_coherence() with WWZ with specified ntau
'''
ts1 = gen_ts(model='colored_noise')
ts2 = gen_ts(model='colored_noise')
_ = ts1.wavelet_coherence(ts2,method='wwz',settings={'ntau':10})

def test_xwave_t6(self):
''' Test Series.wavelet_coherence() with WWZ with specified ntau
'''
ts1 = gen_ts(model='colored_noise')
ts2 = gen_ts(model='colored_noise')
tau = ts1.time[::10]
_ = ts1.wavelet_coherence(ts2,method='wwz',settings={'tau':tau})

class TestUISeriesWavelet():
''' Test the wavelet functionalities
Expand Down