Skip to content

Commit

Permalink
Merge pull request #485 from neillinehan/patch-1
Browse files Browse the repository at this point in the history
Update series.py
  • Loading branch information
CommonClimate authored Jan 3, 2024
2 parents 8cfc01e + 22c74e2 commit 645f839
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
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

0 comments on commit 645f839

Please sign in to comment.