-
Notifications
You must be signed in to change notification settings - Fork 15
/
func_dailytopentad.ncl
83 lines (81 loc) · 2.02 KB
/
func_dailytopentad.ncl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
undef("dailytopentad")
function dailytopentad(var[*])
begin
nday = dimsizes(var)
if (nday.eq.1464 .or. nday.eq.1460)then
ravg = runave_Wrap(var,4,0)
dailyvar = ravg(1::4)
delete(ravg)
end if
if (nday.eq.365 .or. nday.eq.366)then
dailyvar = var
end if
if (.not.isvar("dailyvar"))then
printVarSummary(var)
exit
end if
nday = dimsizes(dailyvar)
ravg = runave_Wrap(dailyvar,5,0)
pentad = ravg(2::5)
delete(ravg)
if (nday .eq. 366)then
ravg = runave_Wrap(dailyvar(61:),5,0)
pentad(11) = avg(dailyvar(55:60))
pentad(12:) = ravg(2::5)
delete(ravg)
end if
pentad@_FillValue = -99.99
return pentad
end
undef("yrdailytopentadTL")
function yrdailytopentadTL(var[*][*])
begin
dims = dimsizes(var)
penvar = new((/73,dims(1)/),"float")
penvar!0 = "time"
penvar!1 = "lev"
;a = dailytopentad(var(:,0))
do i =0, dims(1)-1
penvar(:,i) = dailytopentad(var(:,i))
end do
penvar&time = fspan(1,73,73)
return penvar
end
undef("yrdailytopentadTLn")
function yrdailytopentadTLn(var)
begin
;; assume var t*z*y*x or t*y*x
dims = dimsizes(var)
dims(0) = 73
penvar = new(dims,"float")
;a = dailytopentad(var(:,0))
if(dimsizes(dims).eq.4)
do k =0, dims(3)-1
do j =0, dims(2)-1
do i =0, dims(1)-1
penvar(:,i,j,k) = dailytopentad(var(:,i,j,k))
end do
end do
end do
penvar!1 = "lev"
penvar&lev = var&$var!1$
penvar!2 = "lat"
penvar&lat = var&$var!2$
penvar!3 = "lon"
penvar&lon = var&$var!3$
end if
if(dimsizes(dims).eq.3)
do j =0, dims(2)-1
do i =0, dims(1)-1
penvar(:,i,j) = dailytopentad(var(:,i,j))
end do
end do
penvar!1 = "lat"
penvar&lat = var&$var!1$
penvar!2 = "lon"
penvar&lon = var&$var!2$
end if
penvar!0 = "time"
penvar&time = fspan(1,73,73)
return penvar
end