# Re: [ferret_users] EOf of 3d data

```Hi,

Thank you for the reply. I got this error message while saving my output:
**ERROR: request exceeds memory setting: A negative number of words were requested.
*** NOTE: The current grid is most likely too large
I tried breaking up the output and saving it in groups of timesteps but still got the same error. Is there any other way out of this problem?

----- Original Message -----
From: "Ansley Manke" <ansley.b.manke@xxxxxxxx>
To: "ferret users" <ferret_users@xxxxxxxx>
Sent: Thursday, July 3, 2014 10:59:34 PM
Subject: Re: [ferret_users] EOf of 3d data

Hi,
Yes, those functions expect the spatial variation to be in XY.   You
could do the calculation by defining a fake XY grid and using RESHAPE to
put your variable onto that grid.  Because Ferret grids are stored with
the data varying fastest in the X and then Y direction this will keep
the data order intact.

so, the new grid has an x axis the length of your grid's y axis, a y
axis the length of your z axis:

yes? def axis/x=1:`ny`:1 xfake
yes? def axis/y=1:`nz`:1 yfake

yes? let var_with_grid =  x[gx=xfake] + y[gy=yfake] +t[gt=T_20FLNNEW]
yes? let var_xyt = RESHAPE (T_20FLNNEW, var_with_grid)

Then call the EOF functions using var_xyt, and finally put the results
back on the original yz grid with another RESHAPE function.

Please have a look at the EOFSVD functions. They are faster than the EOF
family of functions.  As long as your data does not have gaps they are
the better choice.

Ansley

On 7/2/2014 10:14 PM, Shreya Dhame wrote:
> Hi,
>
> I want to use the method of Empirical Orthogonal Function (EOF) analysis to decompose the spatiotemporal data in orthogonal modes. My data is in 3d matrix in the form (time(t), lat(y), depth(z)). I tried the eof_space,eof_stat and eof_tfunc given in ef_eof_demo.jnl but did not get valid results.Are these functions only for x.y.t data?
>
> SET MODE VERIFY
> USE merge7y.cdf
>
> LET eofspace = eof_space(T_20FLNNEW, 0.5)
> SAVE/CLOBBER/FILE=merge7y_eof_space.cdf eofspace
>
> can variable/all
>
> use merge7y_eof_space.cdf
> set view ul; fill/l=1/title="eof 1" eofspace
> set view ur; fill/l=2/title="eof 2" eofspace
>
> USE merge7y.cdf
>
> LET eofstat = eof_stat(T_20NEW, 0.5)
> let nout =  eofstat[i=1,j=1]
>
> SAVE/CLOBBER/FILE=merge7y_eof_stat.cdf eofstat[i=1:`nout`]
>
> can var/all
>
> use merge7y_eof_stat.cdf
>
> let nout = eofstat[i=1,j=1,d=merge7y_eof_stat]
> let pcts = eofstat[i=1:`nout`,j=2,d=merge7y_eof_stat]
> let eigenv = eofstat[i=1:`nout`,j=3,d=merge7y_eof_stat]
>
> list nout
> list pcts
> list eigenv
>
> USE merge7y.cdf
> LET eoftime = eof_tfunc(T_20NEW, 0.5)
>
> SAVE/CLOBBER/FILE=M1215_eof_tfunc.cdf eoftime[i=1:`nout`]
>
> can var/all
> use merge7y_eof_tfunc.cdf
> can view
>
> set view ul; plot/k=1/title="time function 1" eoftime
> set view ur; plot/k=2/title="time function 2" eoftime
>
> set mode/last verify
>
>
> --Thank you

```