forrest@2
|
1 |
; ***********************************************
|
forrest@2
|
2 |
; interpolate into model grids (T31)
|
forrest@2
|
3 |
; ***********************************************
|
forrest@2
|
4 |
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
|
forrest@2
|
5 |
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
|
forrest@2
|
6 |
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
|
forrest@2
|
7 |
;************************************************
|
forrest@2
|
8 |
begin
|
forrest@2
|
9 |
;************************************************
|
forrest@2
|
10 |
; output data
|
forrest@2
|
11 |
;************************************************
|
forrest@2
|
12 |
diro = ""
|
forrest@2
|
13 |
filo = "npp_T42_mean_2000-2004.nc"
|
forrest@2
|
14 |
c = addfile(diro+filo,"c")
|
forrest@2
|
15 |
|
forrest@2
|
16 |
;************************************************
|
forrest@2
|
17 |
; read in observed data
|
forrest@2
|
18 |
;************************************************
|
forrest@2
|
19 |
diri = ""
|
forrest@2
|
20 |
fili = "npp_0.05deg_mean_2000-2004.nc"
|
forrest@2
|
21 |
g = addfile (diri+fili,"r")
|
forrest@2
|
22 |
bi = g->NPP
|
forrest@2
|
23 |
xi = g->lon
|
forrest@2
|
24 |
yi = g->lat
|
forrest@2
|
25 |
|
forrest@2
|
26 |
;************************************************
|
forrest@2
|
27 |
; change into 0-360E, 90S-90N
|
forrest@2
|
28 |
; Observed NPP*scale_factor
|
forrest@2
|
29 |
;************************************************
|
forrest@2
|
30 |
|
forrest@2
|
31 |
;scale_factor = 0.1
|
forrest@2
|
32 |
; FMH : Now the scaling occurs in the previous routine the writes out the mean
|
forrest@2
|
33 |
; netCDF file, so don't scale again here.
|
forrest@2
|
34 |
scale_factor = 1.
|
forrest@2
|
35 |
|
forrest@2
|
36 |
yi = (/ yi(::-1) /)
|
forrest@2
|
37 |
bi = (/ bi(::-1,:) /)
|
forrest@2
|
38 |
b2 = bi
|
forrest@2
|
39 |
x2 = xi
|
forrest@2
|
40 |
|
forrest@2
|
41 |
nx = dimsizes(xi)
|
forrest@2
|
42 |
do i= 0,nx-1
|
forrest@2
|
43 |
if (i .lt. 3600) then
|
forrest@2
|
44 |
p = i + 3600
|
forrest@2
|
45 |
xi(p) = x2(i) + 360.
|
forrest@2
|
46 |
else
|
forrest@2
|
47 |
p = i - 3600
|
forrest@2
|
48 |
xi(p) = x2(i)
|
forrest@2
|
49 |
end if
|
forrest@2
|
50 |
bi(:,p)= b2(:,i) * scale_factor
|
forrest@2
|
51 |
end do
|
forrest@2
|
52 |
|
forrest@2
|
53 |
bi&lat = yi
|
forrest@2
|
54 |
bi&lon = xi
|
forrest@2
|
55 |
|
forrest@2
|
56 |
;print (xi)
|
forrest@2
|
57 |
;print (yi)
|
forrest@2
|
58 |
;exit
|
forrest@2
|
59 |
|
forrest@2
|
60 |
;************************************************
|
forrest@2
|
61 |
; read in model data
|
forrest@2
|
62 |
;************************************************
|
forrest@2
|
63 |
;fili2 = "i01.04casa_1605-1629_ANN_climo.nc"
|
forrest@2
|
64 |
diri = "../../model/"
|
forrest@2
|
65 |
fili2 = "i01.10cn_2000-2004_ANN_climo.nc"
|
forrest@2
|
66 |
f = addfile (diri+fili2,"r")
|
forrest@2
|
67 |
|
forrest@2
|
68 |
lon = f->lon
|
forrest@2
|
69 |
lat = f->lat
|
forrest@2
|
70 |
nlon = dimsizes(lon)
|
forrest@2
|
71 |
nlat = dimsizes(lat)
|
forrest@2
|
72 |
|
forrest@2
|
73 |
; print (xi)
|
forrest@2
|
74 |
; print (yi)
|
forrest@2
|
75 |
; print (xo)
|
forrest@2
|
76 |
; print (yo)
|
forrest@2
|
77 |
|
forrest@2
|
78 |
;(A)
|
forrest@2
|
79 |
;bo = linint2_Wrap(xi,yi,bi,True,xo,yo,0)
|
forrest@2
|
80 |
|
forrest@2
|
81 |
;(B)
|
forrest@2
|
82 |
|
forrest@2
|
83 |
rad = 4.*atan(1.)/180.
|
forrest@2
|
84 |
clat = lat
|
forrest@2
|
85 |
clat = cos(lat*rad)
|
forrest@2
|
86 |
clat@long_name = "cos(latitude)"
|
forrest@2
|
87 |
delete(clat@units)
|
forrest@2
|
88 |
printVarSummary(clat)
|
forrest@2
|
89 |
|
forrest@2
|
90 |
bo = new((/nlat,nlon/),float)
|
forrest@2
|
91 |
do j=0,nlat-1
|
forrest@2
|
92 |
if (j.eq.0 .or. j.eq.nlat-1) then
|
forrest@2
|
93 |
if (j.eq.0) then
|
forrest@2
|
94 |
LATS = -90.
|
forrest@2
|
95 |
LATN = lat(j)+0.5*(lat(j+1)-lat(j))
|
forrest@2
|
96 |
end if
|
forrest@2
|
97 |
if (j.eq.nlat-1) then
|
forrest@2
|
98 |
LATS = lat(j)-0.5*(lat(j)-lat(j-1))
|
forrest@2
|
99 |
LATN = 90.
|
forrest@2
|
100 |
end if
|
forrest@2
|
101 |
else
|
forrest@2
|
102 |
LATS = lat(j)-0.5*(lat(j)-lat(j-1))
|
forrest@2
|
103 |
LATN = lat(j)+0.5*(lat(j+1)-lat(j))
|
forrest@2
|
104 |
end if
|
forrest@2
|
105 |
|
forrest@2
|
106 |
; CLAT = clat({LATS:LATN}) ; do once for *slight* efficiency
|
forrest@2
|
107 |
; TEMP = bi({LATS:LATN},:) ; 2D [lat,lon]
|
forrest@2
|
108 |
|
forrest@2
|
109 |
do i=0,nlon-1
|
forrest@2
|
110 |
if (i.eq.0 .or. i.eq.nlon-1) then
|
forrest@2
|
111 |
if (i.eq.0) then
|
forrest@2
|
112 |
LONL = 0.
|
forrest@2
|
113 |
LONR = lon(i)+0.5*(lon(i+1)-lon(i))
|
forrest@2
|
114 |
end if
|
forrest@2
|
115 |
if (i.eq.nlon-1) then
|
forrest@2
|
116 |
LONL = lon(i)-0.5*(lon(i)-lon(i-1))
|
forrest@2
|
117 |
LONR = 360.
|
forrest@2
|
118 |
end if
|
forrest@2
|
119 |
else
|
forrest@2
|
120 |
LONL = lon(i)-0.5*(lon(i)-lon(i-1))
|
forrest@2
|
121 |
LONR = lon(i)+0.5*(lon(i+1)-lon(i))
|
forrest@2
|
122 |
end if
|
forrest@2
|
123 |
|
forrest@2
|
124 |
;print (LATS)
|
forrest@2
|
125 |
;print (LATN)
|
forrest@2
|
126 |
;print (LONL)
|
forrest@2
|
127 |
;print (LONR)
|
forrest@2
|
128 |
bo(j,i) = avg(bi({LATS:LATN},{LONL:LONR}))
|
forrest@2
|
129 |
; bo(j,i) = wgt_areaave(TEMP(:,{LONL:LONR}), CLAT, 1.0, 0)
|
forrest@2
|
130 |
end do
|
forrest@2
|
131 |
|
forrest@2
|
132 |
; delete(CLAT)
|
forrest@2
|
133 |
; delete(TEMP)
|
forrest@2
|
134 |
end do
|
forrest@2
|
135 |
|
forrest@2
|
136 |
bo!0 = "lat"
|
forrest@2
|
137 |
bo!1 = "lon"
|
forrest@2
|
138 |
bo&lat = lat
|
forrest@2
|
139 |
bo&lon = lon
|
forrest@2
|
140 |
bo@units = bi@units
|
forrest@2
|
141 |
bo@long_name = bi@long_name
|
forrest@2
|
142 |
; bo@_FillValue = bi@_FillValue
|
forrest@2
|
143 |
bo@_FillValue = 1.e+36
|
forrest@2
|
144 |
|
forrest@2
|
145 |
c->NPP = bo
|
forrest@2
|
146 |
end
|