[ncl-talk] removing ensemble mean from original data

Sri nandini bax8609 at uni-hamburg.de
Fri Jun 12 04:50:01 MDT 2020


Hello dear ncl-users,

I want to know the best way to remove the ensemble mean from the 
corresponding time of each ensemble member. Can someone tell me if the 
following code is correct? i do not get any error but i wanted to be 
sure of the method.

Thanx in advance

Sri

;==================================================================
;  Remove the ensemble mean from each ensemble member
;==================================================================
    dimx = dimsizes(x)
    ntim = dimx(0)          ; 240
    nens = dimx(1)          ; 100
    nlat = dimx(2)          ; 45
    mlon = dimx(3)          ; 90

    nmos = 12
    nyrs = ntim/nmos         ; 21

    printVarSummary(x)       ;[time | 240] x [ens | 100] x [lat | 45] x [lon | 90]
    ens_mean=dim_avg_n_Wrap(x,1)
    printVarSummary(ens_mean);[time | 240]  x [lat | 45] x [lon | 90]

     detrended_x = x
     do nt=0,ntim-1
       nmo = nt%12
      do ne=0,nens-1
         detrended_x(nt,ne,:,:) = (/ x(nt,ne,:,:) - ens_mean(nmo,:,:) /) ; detrended array
      end do
    end do
    detrended_x at long_name = “Ensemble mean removed”

    printVarSummary(detrended_x)
   [time | 240] x [ens | 100] x [lat | 45] x [lon | 90]



More information about the ncl-talk mailing list