[Thread Prev][Thread Next][Index]

Re: How do I deal with variables without dimension



Hi Erwan,
           
	 According to your script, if we are listing 'R' your final 
variable; you will get something like this, 

	VARIABLE : R_XMEAN[Y=1:10@AVE]
             X        : n to nn    <== n < nn
             Y        : m to mm    <== m < mm
             Z        : 1 
             T        : p to pp   <== p < pp

     To a netcdf you can write/appened only along an axis. While
writing to netcdf file inside a repeat loop,  everytime R will come
with the same dimesions ie, a range for X,Y & T and "Z=1" for Z-axis...
ie. "Z" (or rather abstract index k) will be "1". It is not at all
increasing. So you will get only one value in the netcdf file after the 
complesion of repeat loop.

	To appened along Z axis we need to "impose" the required dimension
to the variable "R". Have a look at the section in ferret manual;

	Ch10 Sec2. SIMPLE CONVERSIONS USING FERRET 
	Example 4--mulltiple slabs 

Here is a sample method in the same formulation as yours.

As a comment :  "repeat" bussiness will be easier with the dummy repeat 
index in  the new version of ferret (fer5.6).

autocorrel.jnl : journal file which finds corr. for a dummy variable
repeat_autocorr.jnl : journal file to call autocorrel.jnl within a repeat
                        loop and write the reusult to netcd file

------------- autocorrel.jnl-------------
\ cancel mode verify
define axis/x=1:10:1 xax    ! to get a variable with x,y,z,t dimensions
define axis/y=1:10:1 yax
define axis/t=1:10:1 tax
define axis/z=1:1:1 zax

define grid/x=xax/y=yax/z=zax/t=tax grd

let var = sin(X[g=grd]) + cos(Y[g=grd]) + (Z[g=grd]) + sin(T[g=grd])

! fill/l=1 var

let/quiet p = var[x=1:10,y=1:10,z=1,t=1:10@shf:0]  
let/quiet q = var[x=1:10,y=1:10,z=1,t=1:10@shf:$1]
go variance
let R_xmean = CORREL[y=1:10,x=1:10@AVE]
let R = R_xmean[y=1:10@AVE]
!----------------------------------------

---------------repeat_autocorr.jnl----------------
\ cancel mode verify

let num = 9 ! end value(index) of repeat loop

define axis/z=1:`num`:1 kdummy  ! Z-axis with as many points we want
                                ! "znew" axis in the repeat loop imposes
	                        ! successive Z values in "kdummy" axis to
	                        ! corresponding "R" usin @asn regridding
                                ! "klimits" : for details refer user manual
repeat/i=1:`num` ( ;\
	go erwan_go `i` ;\ 
        define axis/z=`i`:`i`:1 znew  ;\
        let R_1 = R[gz=znew@asn]  ;\
        let R_new = R_1[gz=kdummy] ;\
        save/klimits=1:`num`/k=`i`/file=output.nc/append R_new  ;\
        )
!-----------------------------------------------




On Fri, 16 Apr 2004, Erwan Monier wrote:

> Hi ferret users,
> 
> I have daily mean wind velocity maps for several
> months and I am working on calculating the
> autocorrelation averaged on the whole grid, for
> different lags in order to plot the mean
> autocorrelation as a function of the lag. To do so, I
> have written a script which computes the mean
> autocorrelation for a specific lag. That script named
> autocorrel.jnl works fine :
> 
> USE "../obs_era_uv.ctrl.nc"
> let
> p=UMEAN[d=1,x=20.00E:107.50E,y=22.50S:22.50N,z=200,T="01-AUG-1990":"31-jul-1992"@shf:0]
> let
> q=UMEAN[d=1,x=20.00E:107.50E,y=22.50S:22.50N,z=200,T="01-AUG-1990":"31-jul-1992"@shf:$1]
> go variance
> let
> R_xmean=CORREL[y=22.50S:22.50N,x=20.00E:107.50E@AVE]
> let R=R_xmean[y=22.50S:22.50N@AVE]
> 
> Then I have another script which makes a loop over all
> the lags I need and calls the previous script. Then
> it's supposed to write the autocorrelation in a netcdf
> file. Here is the script :
> 
> repeat/i=1:$1 (go autocorrel
> `i`;save/file=output_autocorrel.nc/append `i`,R)
> 
> My problem is that I only get the autocorrelation of
> the last lag written down : it seems my script writes
> over the previous output data. I guess it is because
> the variable R has no time dimension (and even no
> dimension at all).
> 
> So my question is : How can you add a dimension to a
> variable. Especially as I only have 1 value of
> autocorrelation each step, it's not a list.
> 
> If you have any other way to get an output file with
> the autocorrelation and its corresponding lag, I would
> be really glad to hear your advice.
> 
> Thanks
> 
> Erwan
> 

-- 
___________________________________________________

    Jaison Kurian                           
    Centre for Atmospheric and Oceanic Sciences
    Indian Institute of Science
    B A N G A L O R E   560 012
    Ph: +91-80-3942505
        +91-80-3600450
    Fax:+91-80-3600865
___________________________________________________



[Thread Prev][Thread Next][Index]

Dept of Commerce / NOAA / OAR / PMEL / TMAP

Contact Us | Privacy Policy | Disclaimer | Accessibility Statement