mathildejutras / mtm-svd-python

This repository contains scripts to apply the MTM-SVD analysis method to climate data and model outputs. It is a direct adaptation of the Matlab script developed by M. Correa-Ramirez.
GNU General Public License v3.0
14 stars 3 forks source link

Error when trying to calculate 3 significance level at the same time #1

Open Liu-Yitao opened 2 years ago

Liu-Yitao commented 2 years ago

I changed the No.101 line of the origin mtm-svd-python.py file from

sl = [.9]

to

sl = [0.99,0.95,0.9]

spectrum_1000

The upper pic is the output plot of the spectrum and the confidence level. The lines of confidence intersected.


Here is part 2 of the script

# 2) Compute the LVF

print('Apply the MTM-SVD...')

# Slepian tapers
nw = 2; # bandwidth
kk = 3; # number of orthogonal windows

o2 = var.copy().values

# Reshape the 2d array to a 1d array
o2ts = o2.reshape((o2.shape[0],o2.shape[1]*o2.shape[2]), order='F')
p, n = o2ts.shape

# Compute the LFV
[freq, lfv] = mtm_svd_lfv(o2ts,nw,kk,dt)

# Compute the confidence intervals
niter = 10000 # minimum of 1000 iterations
sl = [0.99,0.95,0.9]
[conffreq, conflevel] = mtm_svd_conf(o2ts,nw,kk,dt,niter,sl)

# Display the plot to allow the user to choose the frequencies associated with peaks
plt.plot(freq, lfv, '-', c='k')
plt.plot(conffreq, conflevel[0,:], '--', c='tab:red', label=str(sl[0]))
plt.plot(conffreq, conflevel[1,:], '--', c='tab:orange', label=str(sl[1]))
plt.plot(conffreq, conflevel[2,:], '--', c='tab:blue', label=str(sl[2]))
plt.xlim([0.01,.1])
plt.legend()
plt.savefig(f'./spectrum_{model}{niter}.png')
# plt.show()
plt.clf()
mathildejutras commented 2 years ago

Hi,

Thank you for noticing this. I agree it should not look like this. I remember having some issues with the confidence intervals and I thought they were solved, but apparently there are still some. I will look into this. The problem is certainly in the mtm_svd_conf script. Please let me know if you find the issue. I am however confident that the spectrum itself is ok.

Mathilde


From: Liu-Yitao @.> Sent: December 6, 2021 7:21 AM To: mathildejutras/mtm-svd-python @.> Cc: Subscribed @.***> Subject: [mathildejutras/mtm-svd-python] Error when trying to calculate 3 significance level at the same time (Issue #1)

I changed the No.101 line of the origin mtm-svd-python.py file from

sl = [.9]

to

sl = [0.99,0.95,0.9]

[spectrum_1000]https://user-images.githubusercontent.com/59553921/144842865-69c3f41e-80f4-4819-829a-0d34d2ce2568.png

The upper pic is the output plot of the spectrum and the confidence level. The lines of confidence intersected.


Here is part 2 of the script

2) Compute the LVF

print('Apply the MTM-SVD...')

Slepian tapers

nw = 2; # bandwidth kk = 3; # number of orthogonal windows

o2 = var.copy().values

Reshape the 2d array to a 1d array

o2ts = o2.reshape((o2.shape[0],o2.shape[1]*o2.shape[2]), order='F') p, n = o2ts.shape

Compute the LFV

[freq, lfv] = mtm_svd_lfv(o2ts,nw,kk,dt)

Compute the confidence intervals

niter = 10000 # minimum of 1000 iterations sl = [0.99,0.95,0.9] [conffreq, conflevel] = mtm_svd_conf(o2ts,nw,kk,dt,niter,sl)

Display the plot to allow the user to choose the frequencies associated with peaks

plt.plot(freq, lfv, '-', c='k') plt.plot(conffreq, conflevel[0,:], '--', c='tab:red', label=str(sl[0])) plt.plot(conffreq, conflevel[1,:], '--', c='tab:orange', label=str(sl[1])) plt.plot(conffreq, conflevel[2,:], '--', c='tab:blue', label=str(sl[2])) plt.xlim([0.01,.1]) plt.legend() plt.savefig(f'./spectrum_{model}{niter}.png')

plt.show()

plt.clf()

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHubhttps://github.com/mathildejutras/mtm-svd-python/issues/1, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ALY62GZLARU6LA6TEHLG44TUPSTEJANCNFSM5JOPQILA. Triage notifications on the go with GitHub Mobile for iOShttps://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Androidhttps://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.