<div dir="ltr"><div>Well, one obvious issue is that the 1st and last two values are [I assume] missing [_FillValues] values.</div><div><br></div><div>197901 9969209968386869046778552952102584320.000000<br>197902 9969209968386869046778552952102584320.000000<br>197903 10.643162<br>197904 37.253376</div><div>[SNIP]</div><div>201709 10.624535<br>201710 1.700483<br>201711 9969209968386869046778552952102584320.000000<br>201712 9969209968386869046778552952102584320.000000</div><div>===</div><div><br></div><div>The underlying function code [fortran] uses an FFT. Missing values are not allowed in FFT functions. Hence, they must be eliminated.</div><div><br></div><div>The attached eliminates those values.</div><div><b>%> ncl YanYan_wavelet.ncl</b><br></div><div><br></div><div> <br></div><div>Note that setting the assorted input values may be more art-than-science.</div><div>Setting these appropriately is the user's responsibility. It may require some iteration.</div><div>ncl-talk is not an expert on wavelets. <br></div><div><br></div><div>Good luck<br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Feb 4, 2020 at 8:40 PM Yan Yan via ncl-talk <<a href="mailto:ncl-talk@ucar.edu">ncl-talk@ucar.edu</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div><div>Hi there,<br></div><div><br></div><div>I ran into some problems lately when using wavelet analysis in NCL. Here they are. <br></div><div><br></div><div>I was using wavelet to analyze an EOF PC1, which is in monthly resolution. Two problems stuck out.<br></div><div>One is when I dtrend it, the result time series became constant, -8.520693e+34. The following wavelet gave me a time series with power being all "inf". I couldn't plot the power spectrum. This was obvious the input problem, so I changed the input into the PC1 without detrending, which gave me the same problem, the power of the wavelet time series still showed "inf".<br></div><div><br></div><div>I suspect there is something wrong with this input time series, but I don't know enough to identify what the problem is, and how to deal with it.<br></div><div>PC1 data is attached. Can somebody point me to the right direction on this?<br></div><div><br></div><div>Also, the following is the code I used, which is basically using NCL example code. Since data is monthly, I tried 1. and 1./12 for dt, both gave me the same "inf" power.<br></div><div><br></div><div>wts = eof_ts(0,:) <br> ; wts = dtrend(wts,False)<br> mother = 0<br> param = 6.0<br> dt = 1. <br> s0 = dt <br> dj = 0.25<br> jtot = 1 + floattointeger(((log10(N*dt/s0))/dj)/log10(2.))<br> npad = N<br> nadof = new(2,float)<br> noise = 1<br> siglvl = .05<br> isigtest= 1<br> </div><div><br></div><div> w = wavelet(wts,mother,dt,param,s0,dj,jtot,npad,noise,isigtest,siglvl,nadof)<br> ;************************************<br> ; create coodinate arrays for plot<br> ;************************************<br> power = onedtond(w@power,(/jtot,N/))<br> power!0 = "period" ; Y axis<br> power&period = w@period<br> <br> power!1 = "time" ; X axis<br> power&time = time<br> <br> power@long_name = "Power Spectrum"<br> power@units = "unit^2"<br> <br> ; compute significance ( >= 1 is significant)<br> SIG = power ; transfer meta data<br> SIG = power/conform (power,w@signif,0)<br> SIG@long_name = "Significance"<br> SIG@units = " "<br> <br> ;************************************<br> ; initial resource settings<br> ;************************************<br> wks = gsn_open_wks("x11","wavelet") ; send graphics to PNG file<br> plot = new(2,graphic) ; create graphical array<br> <br> res = True ; plot mods desired <br> res@gsnFrame = False ; don't advance frame yet<br> res@gsnDraw = False ; don't draw yet<br> <br> res@cnFillOn = True ; turn on color<br> res@cnFillPalette = "BlAqGrYeOrReVi200" ; set color map<br> res@cnFillMode = "RasterFill" ; turn on raster mode<br> res@cnRasterSmoothingOn = True ; turn on raster smoothing<br> res@cnLinesOn = False ; turn off contour lines<br> res@lbOrientation = "Vertical" ; vertical label bar<br> <br> res@trYReverse = True ; reverse y-axis<br> res@tmLabelAutoStride = True<br> <br> res@vpHeightF = .4 ; height and width of plot<br> res@vpWidthF = .85<br> <br> <br> res@cnLevelSelectionMode = "ManualLevels" ; set manual contour levels<br> res@cnMinLevelValF = 0.0 ; set min contour level<br> res@cnMaxLevelValF = 20.0 ; set max contour level<br> res@cnLevelSpacingF = 2.0 ; set contour spacing<br> <br> ; power<br> res@gsnLeftString = "Wavelet Power"<br> plot(0) = gsn_csm_contour(wks,power({0:35},0:N-1),res) <br> <br> ; significance<br> res@cnMinLevelValF = 1.0 ; set min contour level<br> res@cnMaxLevelValF = 4.0 ; set max contour level<br> res@cnLevelSpacingF = 3.0 ; set contour spacing<br> res@gsnLeftString = "Wavelet Significance"<br> plot(1) = gsn_csm_contour(wks,SIG({0:35},0:N-1),res) </div><div><br></div><div>Any help is very much appreciated!<br></div><div><br></div><div>Best,<br></div><div>Yan<br></div></div>_______________________________________________<br>
ncl-talk mailing list<br>
<a href="mailto:ncl-talk@ucar.edu" target="_blank">ncl-talk@ucar.edu</a><br>
List instructions, subscriber options, unsubscribe:<br>
<a href="http://mailman.ucar.edu/mailman/listinfo/ncl-talk" rel="noreferrer" target="_blank">http://mailman.ucar.edu/mailman/listinfo/ncl-talk</a></blockquote></div>