forrest@0
|
1 |
; ***********************************************
|
forrest@0
|
2 |
; interpolate into model grids (T42)
|
forrest@0
|
3 |
; output: lat: S->N lon: 0->360
|
forrest@0
|
4 |
; input : lat: N->S lon: -180->180
|
forrest@0
|
5 |
; ***********************************************
|
forrest@0
|
6 |
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
|
forrest@0
|
7 |
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
|
forrest@0
|
8 |
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
|
forrest@0
|
9 |
;************************************************
|
forrest@0
|
10 |
begin
|
forrest@0
|
11 |
|
forrest@0
|
12 |
nclass = 20
|
forrest@0
|
13 |
|
forrest@0
|
14 |
;************************************************
|
forrest@0
|
15 |
; output data
|
forrest@0
|
16 |
;************************************************
|
forrest@0
|
17 |
diro = "/fis/cgd/cseg/people/jeff/clamp_data/lai/ob/"
|
forrest@0
|
18 |
filo = "land_class_T31.nc"
|
forrest@0
|
19 |
c = addfile(diro+filo,"c")
|
forrest@0
|
20 |
|
forrest@0
|
21 |
;************************************************
|
forrest@0
|
22 |
; read in observed data
|
forrest@0
|
23 |
;************************************************
|
forrest@0
|
24 |
diri = "/fis/cgd/cseg/people/jeff/clamp_data/lai/ob/"
|
forrest@0
|
25 |
fili = "land_class_0.25deg_new.nc"
|
forrest@0
|
26 |
g = addfile (diri+fili,"r")
|
forrest@0
|
27 |
bi = g->LAND_CLASS
|
forrest@0
|
28 |
xi = g->lon
|
forrest@0
|
29 |
yi = g->lat
|
forrest@0
|
30 |
|
forrest@0
|
31 |
;************************************************
|
forrest@0
|
32 |
; change into 0-360E, 90S-90N
|
forrest@0
|
33 |
;************************************************
|
forrest@0
|
34 |
|
forrest@0
|
35 |
yi = (/ yi(::-1) /)
|
forrest@0
|
36 |
bi = (/ bi(::-1,:) /)
|
forrest@0
|
37 |
printVarSummary(bi)
|
forrest@0
|
38 |
|
forrest@0
|
39 |
b2 = bi
|
forrest@0
|
40 |
x2 = xi
|
forrest@0
|
41 |
|
forrest@0
|
42 |
nx = dimsizes(xi)
|
forrest@0
|
43 |
nx2 = nx/2
|
forrest@0
|
44 |
|
forrest@0
|
45 |
do i= 0,nx-1
|
forrest@0
|
46 |
if (i .lt. nx2) then
|
forrest@0
|
47 |
p = i + nx2
|
forrest@0
|
48 |
xi(p) = x2(i) + 360.
|
forrest@0
|
49 |
else
|
forrest@0
|
50 |
p = i - nx2
|
forrest@0
|
51 |
xi(p) = x2(i)
|
forrest@0
|
52 |
end if
|
forrest@0
|
53 |
bi(:,p)= b2(:,i)
|
forrest@0
|
54 |
end do
|
forrest@0
|
55 |
|
forrest@0
|
56 |
bi&lat = yi
|
forrest@0
|
57 |
bi&lon = xi
|
forrest@0
|
58 |
|
forrest@0
|
59 |
print (xi)
|
forrest@0
|
60 |
print (yi)
|
forrest@0
|
61 |
;exit
|
forrest@0
|
62 |
|
forrest@0
|
63 |
;************************************************
|
forrest@0
|
64 |
; read in model data
|
forrest@0
|
65 |
;************************************************
|
forrest@0
|
66 |
diri2 = "/fis/cgd/cseg/people/jeff/clamp_data/model/"
|
forrest@0
|
67 |
fili2 = "b30.061n_1995-2004_ANN_climo_lnd.nc"
|
forrest@0
|
68 |
f = addfile (diri2+fili2,"r")
|
forrest@0
|
69 |
|
forrest@0
|
70 |
lon = f->lon
|
forrest@0
|
71 |
lat = f->lat
|
forrest@0
|
72 |
nlon = dimsizes(lon)
|
forrest@0
|
73 |
nlat = dimsizes(lat)
|
forrest@0
|
74 |
|
forrest@0
|
75 |
; print (xi)
|
forrest@0
|
76 |
; print (yi)
|
forrest@0
|
77 |
; print (xo)
|
forrest@0
|
78 |
; print (yo)
|
forrest@0
|
79 |
|
forrest@0
|
80 |
bo = new((/nlat,nlon/),integer)
|
forrest@0
|
81 |
count = new((/nclass/),integer)
|
forrest@0
|
82 |
|
forrest@0
|
83 |
do j=0,nlat-1
|
forrest@0
|
84 |
if (j.eq.0 .or. j.eq.nlat-1) then
|
forrest@0
|
85 |
if (j.eq.0) then
|
forrest@0
|
86 |
LATS = -90.
|
forrest@0
|
87 |
LATN = lat(j)+0.5*(lat(j+1)-lat(j))
|
forrest@0
|
88 |
end if
|
forrest@0
|
89 |
if (j.eq.nlat-1) then
|
forrest@0
|
90 |
LATS = lat(j)-0.5*(lat(j)-lat(j-1))
|
forrest@0
|
91 |
LATN = 90.
|
forrest@0
|
92 |
end if
|
forrest@0
|
93 |
else
|
forrest@0
|
94 |
LATS = lat(j)-0.5*(lat(j)-lat(j-1))
|
forrest@0
|
95 |
LATN = lat(j)+0.5*(lat(j+1)-lat(j))
|
forrest@0
|
96 |
end if
|
forrest@0
|
97 |
|
forrest@0
|
98 |
do i=0,nlon-1
|
forrest@0
|
99 |
if (i.eq.0 .or. i.eq.nlon-1) then
|
forrest@0
|
100 |
if (i.eq.0) then
|
forrest@0
|
101 |
LONL = 0.
|
forrest@0
|
102 |
LONR = lon(i)+0.5*(lon(i+1)-lon(i))
|
forrest@0
|
103 |
end if
|
forrest@0
|
104 |
if (i.eq.nlon-1) then
|
forrest@0
|
105 |
LONL = lon(i)-0.5*(lon(i)-lon(i-1))
|
forrest@0
|
106 |
LONR = 360.
|
forrest@0
|
107 |
end if
|
forrest@0
|
108 |
else
|
forrest@0
|
109 |
LONL = lon(i)-0.5*(lon(i)-lon(i-1))
|
forrest@0
|
110 |
LONR = lon(i)+0.5*(lon(i+1)-lon(i))
|
forrest@0
|
111 |
end if
|
forrest@0
|
112 |
|
forrest@0
|
113 |
;print (LATS)
|
forrest@0
|
114 |
;print (LATN)
|
forrest@0
|
115 |
;print (LONL)
|
forrest@0
|
116 |
;print (LONR)
|
forrest@0
|
117 |
|
forrest@0
|
118 |
count = 0
|
forrest@0
|
119 |
|
forrest@0
|
120 |
do n = 0,nclass-1
|
forrest@0
|
121 |
count(n) = num (bi({LATS:LATN},{LONL:LONR}).eq.n)
|
forrest@0
|
122 |
end do
|
forrest@0
|
123 |
|
forrest@0
|
124 |
bo(j,i) = maxind(count)
|
forrest@0
|
125 |
end do
|
forrest@0
|
126 |
end do
|
forrest@0
|
127 |
|
forrest@0
|
128 |
bo!0 = "lat"
|
forrest@0
|
129 |
bo!1 = "lon"
|
forrest@0
|
130 |
bo&lat = lat
|
forrest@0
|
131 |
bo&lon = lon
|
forrest@0
|
132 |
bo@units = bi@units
|
forrest@0
|
133 |
bo@long_name = bi@long_name
|
forrest@0
|
134 |
bo@_FillValue = bi@_FillValue
|
forrest@0
|
135 |
|
forrest@0
|
136 |
print (min(bo) + "/" + max(bo))
|
forrest@0
|
137 |
|
forrest@0
|
138 |
c->LAND_CLASS = bo
|
forrest@0
|
139 |
end |