- 积分
- 9444
- 贡献
-
- 精华
- 在线时间
- 小时
- 注册时间
- 2011-11-18
- 最后登录
- 1970-1-1
|
登录后查看更多精彩内容~
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
由于英文水平有限,读了几遍之后也没有搞明白。
其实,吴洪宝那本书的小波分析哪些章节我已经读了很多次了,开始对小波原理有点理解,但是不透彻。
去李建平老师主页上下载了一个小波分析的程序,看了一下程序的注释,产生了一些疑问。
第一个疑问:
程序中:s0,究竟是要设置等于2dt,还是设置等于dt?
第二个疑问:npad 究竟是什么东西?什么意思?究竟要设置多少才合理?
第三个疑问:运行程序得到的结果都是一维数据,应该无法做出小波实部,或者小波功率谱分布图(如下图)吧?
小波分析的原理很难,正在自学,求做过的高手指教一下。
第四:有没有大神做过之后,用grads画图,可不可以给我一个gs和ctl文件作为参考?
如果我想画出功率谱,我应该输出哪些变量数组?
运行测试程序,得到的结果如下:
Sample output for "wavetest.f" (27 Nov 1999)
Compiling and running "wavetest":
> f77 cfftpack.f chisqr.f wavelet.f wavetest.f -o wavetest
> wavetest
Sample output:
NOTE: your output may differ slightly (<1%)
due to different compilers or floating-point representation.
sst(1)= -0.15 sst(n) = -0.06
n= 504
dt= 0.25
mother= 0
param= 6.
s0= 0.25
dj= 0.25
jtot= 44
npad= 1024
Let w = wave(n/2,j)
j Scale Period ABS(w)^2 phase(w) 5%signif Global GWS5%sig
1 0.250 0.258 0.000 116.357 7.230 0.000 2.689
2 0.297 0.307 0.000 116.564 0.813 0.000 0.305
3 0.354 0.365 0.000 118.295 0.371 0.001 0.141
4 0.420 0.434 0.003 122.777 0.277 0.007 0.106
5 0.500 0.517 0.012 132.364 0.263 0.029 0.102
6 0.595 0.614 0.022 143.603 0.286 0.043 0.112
7 0.707 0.730 0.023 141.647 0.337 0.058 0.134
8 0.841 0.869 0.050 135.089 0.418 0.096 0.169
9 1.000 1.033 0.259 148.135 0.537 0.177 0.221
10 1.189 1.229 0.335 172.986 0.704 0.269 0.295
11 1.414 1.461 0.456 -125.342 0.931 0.396 0.398
12 1.682 1.737 0.983 -117.802 1.236 0.548 0.539
13 2.000 2.066 0.445 -159.262 1.635 0.785 0.729
14 2.378 2.457 0.201 153.529 2.140 1.276 0.977
15 2.828 2.922 0.022 13.591 2.758 1.954 1.292
16 3.364 3.475 0.016 58.034 3.481 2.569 1.676
17 4.000 4.132 0.944 -165.529 4.285 2.270 2.125
18 4.757 4.914 2.964 -146.529 5.130 2.109 2.625
19 5.657 5.844 0.734 -140.449 5.968 2.357 3.157
20 6.727 6.949 0.206 66.755 6.750 1.703 3.700
21 8.000 8.264 0.309 120.272 7.442 1.368 4.236
22 9.514 9.828 1.300 131.020 8.025 1.318 4.753
23 11.314 11.688 2.055 137.350 8.496 1.605 5.246
24 13.454 13.899 2.273 129.854 8.865 1.823 5.716
25 16.000 16.529 0.237 119.806 9.146 1.311 6.167
26 19.027 19.656 0.361 -116.176 9.355 1.424 6.603
27 22.627 23.375 0.130 -50.341 9.509 1.154 7.027
28 26.909 27.798 1.415 12.274 9.621 1.295 7.440
29 32.000 33.057 0.850 14.676 9.702 0.643 7.838
30 38.055 39.312 0.559 -34.619 9.760 0.587 8.214
31 45.255 46.750 1.005 -42.794 9.802 1.008 8.560
32 53.817 55.596 0.285 2.065 9.831 0.539 8.867
33 64.000 66.115 0.700 91.352 9.852 0.728 9.128
34 76.109 78.624 1.477 117.662 9.867 1.363 9.341
35 90.510 93.500 1.247 133.609 9.878 1.169 9.508
36 107.635 111.191 0.666 173.291 9.885 0.621 9.634
37 128.000 132.230 0.921 -172.955 9.891 0.914 9.726
38 152.219 157.248 0.171 -162.954 9.894 0.161 9.790
39 181.019 187.001 0.143 -114.740 9.897 0.140 9.834
40 215.269 222.383 1.092 -112.308 9.899 1.092 9.863
41 256.000 264.459 2.003 -112.306 9.900 2.003 9.881
42 304.437 314.497 0.296 -112.306 9.901 0.296 9.893
43 362.039 374.002 0.001 -112.306 9.902 0.001 9.899
44 430.539 444.766 0.000 -112.306 9.902 0.000 9.902
Scale-average degrees of freedom = 6.441
Scale-avg 5% significance level = 0.439
Reconstructed variance= 0.51547
Original variance = 0.53817
Ratio = 0.95783 (this is low due to padding with zeroes)
Reconstructed mean= 0.000000
Original mean = -0.000020
Root-mean-square difference of time series= 0.002309
小波分析源程序如下:
C****************************************************************************
C WAVETEST: Example Fortran program for WAVELET, using NINO3 SST dataset
C
C COMPILE: f77 chisqr.f cfftpack.f wavelet.f wavetest.f
C
C See "http://paos.colorado.edu/research/wavelets/"
C
C Copyright (C) 1998, Christopher Torrence and Gilbert P. Compo
C This software may be used, copied, or redistributed as long as it is not
C sold and this copyright notice is reproduced on each copy made. This
C routine is provided as is without any express or implied warranties
C whatsoever.
C
C Modified: November 1999 by Arjan van Dijk to include IMPLICIT NONE and
C to convert all routines to DOUBLE precision.
C****************************************************************************
PROGRAM wavetest
IMPLICIT none
INTEGER n,subscale,jtot
DOUBLE PRECISION dt,s0,dj
C these parameters depend on the particular time series
PARAMETER (n=504,dt=0.25D0,s0=dt)
PARAMETER (subscale=4)
PARAMETER (dj=1.D0/subscale,jtot=11*subscale)
C Note: for accurate reconstruction and wavelet-derived variance
C do not pad with zeroes, set s0=dt (for Paul set s0=dt/4), and use
C a large "jtot" (even though the extra scales will be within
C the cone of influence).
C For plotting purposes, it is only necessary to use
C s0=2dt (for Morlet) and "jtot" from Eqn(10) Torrence&Compo(1998).
!这一段不太懂,求大神帮助。
INTEGER mother,ibase2,npad
DOUBLE PRECISION sst(n),recon_sst(n),param,pi
DOUBLE PRECISION scale(jtot),period(jtot),coi(n)
DOUBLE COMPLEX wave(n,jtot)
INTEGER i,j,isigtest,javg1,javg2
DOUBLE PRECISION lag1,siglvl,dof(jtot)
DOUBLE PRECISION fft_theor(jtot),signif(jtot),ymean,variance
DOUBLE PRECISION recon_mean,recon_vari
DOUBLE PRECISION Cdelta,psi0
DOUBLE PRECISION global_ws(jtot),global_signif(jtot)
DOUBLE PRECISION savg_dof(jtot),savg_signif(jtot),sstENSO(n)
pi = 4.D0*ATAN(1.D0)
ibase2 = NINT(LOG(DBLE(n))/LOG(2.D0))+1
npad = INT(2.D0**ibase2)
C npad = n ! this is for no padding with zeroes
!npad的设置也不太明白。
C*************************************************** Wavelet transform
C** let the WAVELET subroutine choose the defaults for these:
mother = 0
param = 6.D0
C** read in the NINO3 SST data
OPEN(UNIT=11,FILE='sst_nino3.dat',STATUS='old')
READ(11,*) sst
CLOSE(11)
PRINT'(/,"sst(1)=",F6.2," sst(n) = ",F6.2,/)',sst(1),sst(n)
C** get the wavelet transform
CALL WAVELET(n,sst,dt,mother,param,s0,dj,jtot,npad,
& wave,scale,period,coi)
C*************************************************** Significance testing
C** local significance test
isigtest = 0
lag1 = 0.72D0
siglvl = 0.05D0
CALL WAVE_SIGNIF (isigtest,n,sst,dt,mother,param,dj,jtot,
& scale,period,lag1,siglvl,dof,fft_theor,signif,
& ymean,variance,Cdelta,psi0)
C** global wavelet spectrum & significance test
isigtest = 1
lag1 = 0.72D0
siglvl = 0.05D0
DO 10 j=1,jtot
DO 20 i=1,n
global_ws(j) = global_ws(j) + ABS(wave(i,j))**2
20 CONTINUE
global_ws(j) = global_ws(j)/n
dof(j) = n - scale(j)
10 CONTINUE
CALL WAVE_SIGNIF (isigtest,n,sst,dt,mother,param,dj,jtot,
& scale,period,lag1,siglvl,dof,fft_theor,global_signif,
& ymean,variance,Cdelta,psi0)
C** scale-average time series & significance test
isigtest = 2
lag1 = 0.72D0
siglvl = 0.05D0
C scale average between 2 and 7.9 years
savg_dof(1) = 2.0D0
savg_dof(2) = 7.9D0
C find the "j"-values that correspond to savg_dof(1) & savg_dof(2)
javg1 = 0
javg2 = 0
DO 30 j=1,jtot
IF ((scale(j).GE.savg_dof(1)).AND.(javg1.EQ.0)) javg1 = j
IF (scale(j).LE.savg_dof(2)) javg2 = j
30 CONTINUE
C call wave_signif first, to get the value of "Cdelta"
CALL WAVE_SIGNIF (isigtest,n,sst,dt,mother,param,dj,jtot,
& scale,period,lag1,siglvl,savg_dof,fft_theor,savg_signif,
& ymean,variance,Cdelta,psi0)
C construct the scale-averaged time series [Eqn(24)]
DO 50 i=1,n
sstENSO(i) = 0.D0
DO 60 j=javg1,javg2
sstENSO(i) = sstENSO(i) + (ABS(wave(i,j))**2)/scale(j)
60 CONTINUE
sstENSO(i) = dj*dt*sstENSO(i)/Cdelta
50 CONTINUE
C************************************************************* print results
PRINT*,' n=',n
PRINT*,' dt=',dt
PRINT*,' mother=',mother
PRINT*,' param=',param
PRINT*,' s0=',s0
PRINT*,' dj=',dj
PRINT*,' jtot=',jtot
PRINT*,' npad=',npad
PRINT'(/,"Let w = wave(n/2,j)",/)'
PRINT'(A4,7A10)',"j","Scale","Period","ABS(w)^2","phase(w)",
& "5%signif","Global","GWS5%sig"
PRINT'(I4,7F10.3)',(j,scale(j),period(j),
& ABS(wave(n/2,j))**2,
& ATAN2(DIMAG(wave(n/2,j)),DBLE(wave(n/2,j)))*180.D0/pi,
& signif(j),global_ws(j),global_signif(j),j=1,jtot)
PRINT'(/,A,F10.3)',
& ' Scale-average degrees of freedom = ',savg_dof(1)
PRINT'(A,F10.3,/)',
& ' Scale-avg 5% significance level = ',savg_signif(1)
C************************************************************ Reconstruction
C** construct the wavelet derived variance (Parseval's theorem) [Eqn(14)]
C Cdelta & psi0 are returned from WAVE_SIGNIF
recon_vari = 0.D0
DO 900 i=1,n
DO 1000 j=1,jtot
recon_vari = recon_vari + (ABS(wave(i,j))**2)/scale(j)
1000 CONTINUE
900 CONTINUE
recon_vari = dj*dt*recon_vari/(Cdelta*n)
PRINT'(A,F14.5)',' Reconstructed variance=',recon_vari
PRINT'(A,F14.5)',' Original variance =',variance
PRINT'(A,F14.5,A,/)',' Ratio = ',recon_vari/variance,
& ' (this is low due to padding with zeroes)'
C** reconstruct the time series [Eqn(11)]
C check mean and RMS difference of reconstructed time series
recon_mean=0.D0
recon_vari = 0.D0
DO 1100 i=1,n
recon_sst(i)=0.D0
DO 1200 j=1,jtot
recon_sst(i) = recon_sst(i)+(DBLE(wave(i,j)))/SQRT(scale(j))
1200 CONTINUE
recon_sst(i) = dj*SQRT(dt)*recon_sst(i)/(Cdelta*psi0)
recon_vari = recon_vari+(sst(i)-ymean-recon_sst(i))**2
recon_mean = recon_mean + recon_sst(i)
1100 CONTINUE
recon_mean = recon_mean/n
recon_vari = SQRT(recon_vari/n)
PRINT'(A,F14.6)',' Reconstructed mean=',recon_mean
PRINT'(A,F14.6)',' Original mean =',ymean
PRINT'(A,F14.6,/)',' Root-mean-square difference of time series=',
& recon_vari
END
谢谢大家帮忙!
|
评分
-
查看全部评分
|