[Thread Prev][Thread Next][Index]

Re: [ferret_users]append multiple slabs on X axis



Hi all,
We concocted a new example for appending to a netCDF file in directions other than the X axis.  In Jean's example, he defines a variable with a transformation over X which results in the variables not having an x axis.  So an X axis needs to be defined and the data put onto it before saving it at each step.  The example will be added to the Ferret users guide, but I'll include it here as well to close out this thread:

Define a variable at each X location of an existing variable, and write, appending, to a netCDF file. The _expression_ uses a transformation in the X direction, so the variable has no x axis.  We'll define a new one-point x axis at each point and put the variable onto that x axis.

yes? USE levitus_climatology

  ! Define a variable containing the xaxis locations. These are

yes? LET lon =  x[gx=temp]
 
  ! Define a one-point X axis at the first X location.
  ! Define the variable, put it on this one-point X axis,
  ! and then regrid it onto the full x axis of the variable.

yes? DEFINE AXIS/X/UNITS="`temp,return=xunits`" xout = `lon[i=1]`
yes? SHOW AXIS xout
 
yes? LET mtmp1 = temp[X=`lon[i=1]`:300@MAX] + 0*x[GX=xout]

  ! see its grid has a single point in x
yes? SHOW GRID mtmp1 

  ! put the variable onto the full X grid

yes? LET mtmp = mtmp1[GX=temp]

  ! This is the result at the first location saved to the full x axis.
  ! Write out the first x value, and use /ILIMITS to set up the full 
  ! range in x that we'll be writing to the file

yes? SAVE/CLOBBER/FILE=mout.nc/ILIMITS=1:90/I=1 mtmp

  ! Now do the same for each other X location. The variable
  ! at each X step needs its own one-point x axis.
yes? PAUSE

yes? REPEAT/RANGE=2:30/NAME=inx (LET xstart = lon[I=`inx`];\
  DEFINE AXIS/X/UNITS="`temp,RETURN=xunits`" xout = `xstart`;\
  LET mtmp1 = temp[X=`xstart`:300@MAX] + 0*x[GX=xout];\
  LET mtmp = mtmp1[GX=temp@ave];\
   SAVE/APPEND/FILE=mout.nc/i=`inx` mtmp)




On 9/14/2011 1:32 PM, jean li wrote:
Hi All:
 
I am trying to compute the zonal integration of variable "data[i,j,t]" from longitude[i] to a fixed longitude, i.e. 290. The zonal integration, M, should have the same dimension as "data". But, I can only get one slab at each loop of i (total number of i is 600). The save/append or list/append command did not work on the X axis. Does anyone have any ideas to append the slabs on X axis? Below is the script.
 
-----------------------
let lon=x[g=data];
repeat/range=1:600/name=inx (let xstart=lon[i=`inx`];\
let M = data[x=`xstart`:290@din]/1.0e6;\
save/append/file=M_1998.nc M )
---------------------------------------------------
 
Thanks for your help!
 
Jean

[Thread Prev][Thread Next][Index]
Contact Us
Dept of Commerce / NOAA / OAR / PMEL / Ferret

Privacy Policy | Disclaimer | Accessibility Statement