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

Xueyan Zhang xueyanzhang520 at gmail.com
Sun Oct 13 10:53:57 MDT 2019


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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20191013/c2c2268b/attachment.html>


More information about the ncl-talk mailing list