[ncl-talk] How to calculate the mean over time dimension with a stride?

Dennis Shea shea at ucar.edu
Sun Oct 13 13:40:18 MDT 2019


*calculate_daily_values*
<http://www.ncl.ucar.edu/Document/Functions/Contributed/calculate_daily_values.shtml>

This is 'calendar aware'
                time:calendar = "noleap" ;
 =================
  f = addfile("...","r")
  x = f->pr
  nDim = 0
  xDayAvg = *calculate_daily_values*(x, "avg", nDim, False)

              ;xDaySum = *calculate_daily_values*(x, "sum", nDim, False)
              ;xDayMin = *calculate_daily_values*(x, "min", nDim, False)
              ;xDayMax = *calculate_daily_values*(x, "max", nDim, False)

  *printVarSummary*(xDayAvg)


On Sun, Oct 13, 2019 at 10:54 AM Xueyan Zhang via ncl-talk <
ncl-talk at ucar.edu> wrote:

> Hi ncl_talk,
>
> I have a variable like this:
> dimensions:
>         time = 2920 ;
>         lat = 224 ;
>         lon = 464 ;
> variables:
>         float time(time) ;
>                 time:calendar = "noleap" ;
>                 time:long_name = "observation time" ;
>                 time:units = "days since 2098-01-01 00:00:00" ;
>         float lat(lat) ;
>                 lat:long_name = "latitude                 " ;
>                 lat:units = "degrees_north  " ;
>         float lon(lon) ;
>                 lon:long_name = "longitude                " ;
>                 lon:units = "degrees_east   " ;
>         float pr(time, lat, lon) ;
>                 pr:long_name = "Precipitation" ;
>                 pr:units = "mm" ;
>                 pr:_FillValue = 1.e+20f ;
>
> the time value is 0,0.125..364.875
> I want to calculate the mean value of pr among time dimension but using
> every 8 time index, like pr_mean (0) = (pr(0,:,:)+ pr(1,:,:)+ pr(2,:,:)+
> pr(3,:,:)+ pr(4,:,:)+ pr(5,:,:)+ pr(6,:,:)+ pr(7,:,:))/8
>
> I only thought about using loops but it is too slow. Any ideas?
>
> Thanks!
>
> Xueyan
> _______________________________________________
> ncl-talk mailing list
> ncl-talk at ucar.edu
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20191013/d82f5dc2/attachment.html>


More information about the ncl-talk mailing list