# [ncl-talk] Problem with wk_spacetime function

Mike Victor mayuresh0987 at gmail.com
Sun Sep 13 22:19:51 MDT 2020

```*I referred to the code for the function wk_spacetime as given on this link
<http://www.mit.edu/course/13/13.715/ncarg-5.5.1/lib/ncarg/nclscripts/csm/diagnostics_cam.ncl>.
The result of the code is supposed to be in congruence with the methods
used in the paper "Convectively coupled equatorial waves: Analysis of
clouds and temperature in the wavenumber–frequency domain
<https://journals.ametsoc.org/jas/article/56/3/374/24501>", according to
which at first the 3 harmonics of the seasonal cycle are to be removed (as
mentioned in Methodology part of the paper) but according to the code for
wk_spacetime function, they have removed the annual cycle instead. Correct
me if I am understanding it wrong. I am pasting the part of the code where
the annual cycle is removed.*

;-------------------------------------------------------------------
; Remove dominant signals
; (a) Explicitly remove *long term* linear trend
;     For consistency with JET code keep the grid point means.
;     This necessitates that 'dtrend_msg' be used because 'dtrend'
;     always removes the mean(s).
; (b) All variations >= approx 'nDayWin' days if full year available
;-------------------------------------------------------------------

dNam = getvardims( x )
work = x(\$dNam(1)\$|:,\$dNam(2)\$|:,\$dNam(0)\$|:)    ; reorder  (lat,lon,time)
;;work = dtrend( work , False )   ; remove mean + overall long term
temporal trend
work = dtrend_msg(ispan(0,ntim-1,1)*1.0, work, False, False)  ;
remove just  trend
if (isatt(work,"_FillValue")) then
delete(work at _FillValue)                  ; dtrend_msg adds this att
end if
; replace
with detrended
x    = (/ work(\$dNam(0)\$|:,\$dNam(1)\$|:,\$dNam(2)\$|:) /) ; values (time,lat,lon)
delete(work)

if (nDayTot.ge.365) then                     ; rmv dominant signals
rmvMeans = False                         ; original code did not remove
x = rmvAnnualCycle(x, spd, nDayTot, rmvMeans, fCrit, 0)
end if

if (debug) then
print("===> Post removal of trend and signal <===")
printVarSummary( x )                     ; (time,lat,lon)
printMinMax( x, True )
end if

*Regards.*
*Mayuresh *
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.ucar.edu/pipermail/ncl-talk/attachments/20200914/b2a0cd9c/attachment.html>
```