defining new array - repost

Arindam Chakraborty arch at IO.MET.FSU.EDU
Wed Apr 27 17:03:28 EDT 2005


hi Mariusz,
        to my knowledge, redefinition of time dimension is not
possible currently in grads (may be dtype netcdf will provide this
opportunity in the future). Therefore, you may have to (if feasible)
write down the data to plain binary file, create 2 descriptor files
and do the subtraction (all these can be done from a single gs file
itself). However, if you decide to write to an intermediate file, you
can do the subtraction directly at the time of writing and the
procedure described in the previous mail is not required.

Alternatively, you can use netcdf operator (NCO). If the dimension
name for time is 'time' in your netcdf file, the commands may look
like this:

# extract the 1st hr data starting from 1st day to last-but-one day
% ncks -F -d time,1,697,24 inputfile.nc outputfile1.nc

# extract the 1st hr data starting from 2nd day to last day
% ncks -F -d time,25,721,24 inputfile.nc outputfile2.nc

# subtraction
% ncdiff outputfile2.nc outputfile1.nc daily.nc

Use the -v varname option if you have many variables in one file.

Hope this helps,
----------------------------
 ARINDAM CHAKRABORTY
 Department of Meteorology
 Florida State University
 Tallahassee, FL-32306, USA
 Tel: +001-850-6443524 (Off)
      +001-850-5758550 (Res)
 Fax: +001-850-6449642
____________________________

On Wed, 27 Apr 2005, Mariusz Pagowski wrote:

> Thanks Arindam for response.
>
> However, the trick with assigning additional dimension
> to the variable won't work - because I read a netcdf file
> and z dimension is not defined. I still cannot find a way
> how to declare/assign values to a daily array in a time loop
> going over hours  e.g.
>
> nreacs=721
> incrt=24
> tt=0
> while(tt <= nrecs-incrt)
> tt=tt+incrt
> 'd rainncacc(t='%tt%')-rainncacc(t='%tt-incrt%')'
> endwhile
>
> displays fine but I need to assign values
>
> rainncacc(t='%tt%')-rainncacc(t='%tt-incrt%') to an array
>
> for further manipulation. Any expression of sort
> rainncacc(t='%tt%')-rainncacc(t='%tt-incrt%') gets an error
> message that: Function not found: rainncacc
>
> Thanks a lot,
> Mariusz
>
>
> On Wed, 27 Apr 2005, Arindam Chakraborty wrote:
>
> > hi Mariusz,
> >         the trick is to introduce an additional dimension to the
> > hourly rainfall data. And the assumption is that the variable
> > has a free dimension (may be level in this case) and you have only
> > one variable in this file (this later assumption may not be required if
> > some other tricks are applied). Well, assuming these you may
> > try applying the followings:
> >
> > View your time series as two dimensional. The z-dimension is hrs
> > and t-dimension is days. Means, if you have 100 days (2400 time
> > points in total), you need to write the control file as
> > ....
> > zdef 24 linear 1 1
> > tdef 100 linear 1jan1998 1dy
> > vars 1
> > var 24 99 rainfall
> > endvars
> >
> > This is the control file which points to the actual time series of
> > your data. The next trick is to write another control file which will
> > point to the same data file but with a shifted time coordinate. This
> > is to make the subtraction sitting at the same time coordinate. This
> > 2nd control file will read
> > ....
> > zdef 24 linear 1 1
> > tdef 100 linear 31dec1997 1dy * starts 1 day early
> > vars 1
> > var 24 99 rainfall
> > endvars
> >
> > Notice the shift here. The actual rainfall of 1jan98 will be viewed by
> > the 2nd file as for 31dec97. And actual rainfall of 2jan98 will be
> > viewed as for 1jan98, and so on. Now we can make the subtraction.
> >
> > 'open 1st_file.ctl' * 'actual'
> > 'open 2nd_file.ctl' * dummy
> > 'set horizontal dimensions'
> > 'set t 1 99'
> > 'set z 1' * z = 1 is the 1st hour
> > 'd var.2 - var'
> >
> >
> > Hope this works out.
> > ----------------------------
> >  ARINDAM CHAKRABORTY
> >  Department of Meteorology
> >  Florida State University
> >  Tallahassee, FL-32306, USA
> >  Tel: +001-850-6443524 (Off)
> >       +001-850-5758550 (Res)
> >  Fax: +001-850-6449642
> > ____________________________
> >
> > On Wed, 27 Apr 2005, Mariusz Pagowski wrote:
> >
> > > Hello,
> > > Sorry for the respost - I forgot to name the subject in the
> > > header of my previous mail.
> > >
> > > In Grads I read a file with model hourly accumulated precipitation
> > > and store data in "hourly"   array.
> > > I want to convert hourly accumulated to daily totals. and later process
> > > it further. In fortran it would  look like that:
> > >
> > > real daily  :: (nx,ny,30)
> > > real hourly :: (nx,ny,721)
> > >
> > > daily(1)=hourly(25)-hourly(1)
> > > ....
> > > daily(30)=hourly(721)-hourly(697)
> > >
> > > After different tries with a define I ran out of ideas
> > > how to declare a daily array and assign daily precip as above
> > > in the fortran code.
> > >
> > > I would very much appreciate help.
> > > Thanks,
> > > Mariusz
> > >
> > > ___
> > >
> > > Mariusz Pagowski
> > > NOAA Research-Forecast Systems Laboratory*,
> > > 325 Broadway FSL/FS1, Boulder, CO 80305-3328
> > > Tel: (303)497-6443, Fax: (303)497-7262
> > > e-mail: Mariusz.Pagowski at noaa.gov
> > >
> > > *In collaboration with
> > > Cooperative Institute for Research in the Atmosphere (CIRA),
> > > Colorado State University
> > > __________________________________________________________________
> > >
> >
>
> ___
>
> Mariusz Pagowski
> NOAA Research-Forecast Systems Laboratory*,
> 325 Broadway FSL/FS1, Boulder, CO 80305-3328
> Tel: (303)497-6443, Fax: (303)497-7262
> e-mail: Mariusz.Pagowski at noaa.gov
>
> *In collaboration with
> Cooperative Institute for Research in the Atmosphere (CIRA),
> Colorado State University
> __________________________________________________________________
>



More information about the gradsusr mailing list