Re: Help with addfiles and stride syntax

From: Dennis Shea <shea_at_nyahnyahspammersnyahnyah>
Date: Tue Nov 17 2009 - 13:46:51 MST

You [GH] did not state what variables you had available.

For example, if you were using CAM generated files, there are several
'time' variables:

        int date(time) ;
                date:long_name = "current date (YYYYMMDD)" ;
        int datesec(time) ;
                datesec:long_name = "current seconds of current date" ;
        double time(time) ;
                time:long_name = "time" ;
                time:units = "days since 0000-09-01 00:00:00" ;
                time:calendar = "noleap" ;

Let's say you want

  dateStrt = 20010501
  dateLast = 20010531

  date = f[:]->date
  iStrt = ind(date.eq.dateStrt)
  iLast= ind(date.eq.dateLast)
   x = f[:]->x(iStrt:iLast,.,.,.)

Good Luck
D

Adam Phillips wrote:
> Hi Gina,
> Yes:
> Var = a[:]->Var(31:58,:,:,;)
>
> If you're running this for each year then something like this would work:
> allfiles = systemfunc("ls "+inputpath+"filename*.nc")
> a = addfiles(allfiles,"r")
> ListSetType (a, "cat")
> ndays = days_in_month(2001,ispan(1,12,1)) ; choose non-leap yr,
> assuming model
>
> ; does not have leap yrs
> cntr = 0
> do gg = 0,11
> Var = a[:]->Var(cntr:cntr+ndays(gg)-1,:,:,;)
> ...............
> cntr = cntr+ndays(gg)
> delete(Var)
> end do
>
>
> Gina Henderson wrote:
>
>> Hi there,
>>
>> I am trying to read in data that spans multiple files but cannot read a
>> variable entirely as the array would exceed ncl's limit. I need to read
>> in the data continuously as it is a multiple year model run with each
>> history tape containing 30 days of data but the write date of each tape
>> is not necessarily at the start of each month. Is there any way of using
>> the stride function to extract a block of data per stride rather than
>> just one value so I could do the analysis by month and avoid the array
>> memory limit?
>>
>> Something like:
>> allfiles = systemfunc("ls "+inputpath+"filename*.nc")
>> a = addfiles(allfiles,"r")
>> ListSetType (a, "cat")
>> Var = a[:]->Var(:,:,:,;)
>>
>> where instead of getting the whole var(:,:,:,:), can I get the first 30
>> of each 365 chuck of the first dimension? I am not sure if this is
>> possible or what the correct syntax would be?
>>
>> Any suggestions would be greatly appreciated.
>> Thanks, Gina.
>>
>>
>>
>>
>> ------------------------------------------------------------------------
>>
>> _______________________________________________
>> ncl-talk mailing list
>> List instructions, subscriber options, unsubscribe:
>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>
>
>

-- 
======================================================
Dennis J. Shea                  tel: 303-497-1361    |
P.O. Box 3000                   fax: 303-497-1333    |
Climate Analysis Section                             |
Climate & Global Dynamics Div.                       |
National Center for Atmospheric Research             |
Boulder, CO  80307                                   |
USA                        email: shea 'at' ucar.edu |
======================================================
_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Tue Nov 17 13:47:26 2009

This archive was generated by hypermail 2.1.8 : Tue Nov 17 2009 - 17:27:42 MST