NCL Website header
NCL Home > Documentation > Functions > Empirical orthogonal functions

eof2data_n

Reconstructs a data set from EOFs and EOF time series, given an index that specifies which dimension contains the time dimemsion.

Available in version 6.4.0 and later.

Prototype

	function eof2data_n (
		ev           : numeric,  
		ev_ts [*][*] : numeric,  
		dim      [1] : integer   
	)

	return_val  :  numeric

Arguments

ev

A multi-dimensional array containing the EOFs calculated using eofunc_n.

ev_ts

A two-dimensional array containing the EOF time series calculated using eofunc_ts_n.

dim

The dimension index of data that represents the dimension containing the time dimension.

Return value

An array of the same size and type as the main data array input into eofunc_n.

Description

Uses the EOF spatial patterns and amplitude time series to create a data field. The original data array may be reconstructed if all possible eigen functions were used. If only a subset are used, the returned array will explain a percent of the variance of the original array. Note that the time series of amplitude coefficients returned by eofunc_ts_n has had the mean subtracted. To reconstruct the original series, the mean of each component must be included. The component means are returned as an attribute, ts_mean, of of ev_ts. You access this attribute via the @ operator:

print(ev_ts@ts_mean)

See Also

eof2data, eofunc_n, eofunc_ts_n, eofunc_n_Wrap, eofunc_ts_n_Wrap, eofunc, eofunc_ts eofunc_Wrap, eofunc_ts_Wrap

Examples

Example 1

Assume x is three-dimensional with dimensions time, lat, and lon.

   neval = 7                       ; number of EOFs
   ev    = eofunc_n(x,neval,False,0)       ; ev(neval,nlat,nlon)
   evts  = eofunc_ts_n(x,ev,False,0)       ; evts(neval,ntime)

   do n=0,neval-1
      evts(n,:) = evts(n,:) + evts@ts_mean(n)  ; add time series mean
   end do                 
                     
   xEof  = eof2data_n(ev,evts,0)       ; reconstruct original array
                                         ; 
   x2    = eof2data_n(ev(0:1,:),evts(0:1,:),0) ; construct array using
                                           ; first 2 EOFs
Example 2

Assume z is four-dimensional with dimensions time, level, lat, lon. Compute the EOFs at one level.

   kl     = 3                             ; specify level
   neval  = 8                             ; calculate 8 EOFs out of nlat*mlon 
   ev     = eofunc_n(z(kl,:,:,:),neval ,False,0)  ; ev(neval,nlat,mlon)
   evts   = eofunc_ts_n (z(kl,:,:,:),ev,False,0)  ; evts(neval,ntime)

   do n=0,neval-1
      evts(n,:) = evts(n,:) + evts@ts_mean(n)  ; add time series mean
   end do                 
   z8     = eof2data_n(ev,evts,0)             ; reconstruct array using the 8 EOFs
                                          ; z8(ntim,nlat,mlon)
Example 3

Note: when dealing with latitude/longitude grids, the user may have weighted the observations by the cosine of the latitude prior to using eofunc_n. To reconstruct the data, an extra step is needed to remove the weighting.

Assume p is three-dimensional with dimensions time, lat, and lon. Both time and lat are one-dimensional. Lat contains the latitudes.

   clat = sqrt(cos(lat*0.0174532))      ; array syntax  clat(nlat)

   do nl=0,nlat-1                       ; weight by cosine of the latitude
      p(:,nl,:)  = p(:,nl,:)*clat(nl)   ; array syntax
   end do

   neval  = 3                     ; calculate 3 EOFs out of nlat*mlon 
   ev     = eofunc_n(p,neval,False,0)       ; ev(neval,nlat,mlon)
   evts   = eofunc_ts_n(p,evecv,False,0)    ; evts(neval,ntim)

   do n=0,neval-1
      evts(n,:) = evts(n,:) + evts@ts_mean(n)  ; add time series mean
   end do                 

   p3     = eof2data_n(ev,evts,0)      ; reconstruct weighted array using 3 EOFs

   do nl=0,nlat-1                   ; remove weighting
      if (clat(nl).ne.0.) then
          p3(:,nl,:)  = p3(:,nl,:)/clat(nl)   ; array syntax
      end if
   end do