[ncl-talk] Annual to Decadal
Dennis Shea
shea at ucar.edu
Tue Jul 25 08:30:55 MDT 2017
untested
----------------
undef("decadal_mean")
function decadal_mean(x_annual[*][*][*], long_name[1]:string)
local dim_annual, dim_decade, x_decade, nyr, nyr_annual
begin
dim_annual = dimsizes(x_annual)
dim_decade = dim_annual
dim_decade(0) = dim_annual(0)/10
x_decade = new(dim_decade, typeof(x_annual), getFillValue(x_annual))
nyr_annual = dim_annual(0) ; clarity
do nyr=0,nyr_annual-1,10
x_decade(nyr/10+1,:,:) = dim_avg_n(x_annual(nyr:nyr+9,:,:), 0)
end do
copy_VarMeta(x_annual(::10,:,:), x_decade)
x_decade at long_name = long_name
return(x_decade)
end
;----------------------------------------
; MAIN
;----------------------------------------
; .........
; .........
; .........
T_decade = decadal_mean(T_annual, "Decadal Me an Temperature")
printVarSummary(T_decade)
printMinMax(T_decade, 0)
On Tue, Jul 25, 2017 at 12:03 AM, 임수연 <soottong at gmail.com> wrote:
> Dear All
>
> I want to calculate decadal mean from annual data.
> The dimension of annual data(T_annual) is:
> [year|2000] x [lat|10] x [lon|19]
> And the dimension what I want to get(T_decade) is:
> [decade|200] x [lat|10] x [lon|19]
>
> I attempted to use avg function:
> ---------------------------------------------
> T_decade = new((/200,10,19/),float)
>
> T_decade!0 = "decade"
> T_decade!1 = "lat"
> T_decade!2 = "lon"
> T_decade&lat = T_annual&lat
> T_decade&lon = T_annual&lon
>
> Do i = 0,199
> n = 10*i
> T_decade(i,:,:)=avg(T_annual(n:n+9,:,:))
> End Do
> ---------------------------------------------
>
> and it seems not a good way.
> Could you advise me how to calculate decadal mean from annual data?
> Thank you.
>
> Soo
>
> _______________________________________________
> 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/20170725/b739aaa1/attachment.html
More information about the ncl-talk
mailing list