forrest@2
|
1 |
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
|
forrest@2
|
2 |
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
|
forrest@2
|
3 |
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
|
forrest@2
|
4 |
|
forrest@2
|
5 |
begin
|
forrest@2
|
6 |
; Read in binary (2-byte, short int, little endian) MODIS NPP global
|
forrest@2
|
7 |
; annual data at 0.5 degree resolution and create a mean that will
|
forrest@2
|
8 |
; then be reprojected to various computational grids.
|
forrest@2
|
9 |
|
forrest@2
|
10 |
setfileoption("bin", "ReadByteOrder", "LittleEndian")
|
forrest@2
|
11 |
file_prefix = "Npp_0.05deg_"
|
forrest@2
|
12 |
file_suffix = ".int16"
|
forrest@2
|
13 |
yr_init = 2000
|
forrest@2
|
14 |
;yr_final = 2005
|
forrest@2
|
15 |
yr_final = 2004
|
forrest@2
|
16 |
|
forrest@2
|
17 |
bin_nlon = 7200
|
forrest@2
|
18 |
bin_nlat = 3600
|
forrest@2
|
19 |
bin_fill = 32700
|
forrest@2
|
20 |
bin_scale_factor = 0.1
|
forrest@2
|
21 |
|
forrest@2
|
22 |
npp = new((/bin_nlat,bin_nlon/), float)
|
forrest@2
|
23 |
npp(:,:) = 0.
|
forrest@2
|
24 |
|
forrest@2
|
25 |
cnt = 0
|
forrest@2
|
26 |
do y = yr_init,yr_final
|
forrest@2
|
27 |
ifile = file_prefix + y + file_suffix
|
forrest@2
|
28 |
print("Reading " + ifile)
|
forrest@2
|
29 |
npp_short = fbindirread(ifile, 0, (/bin_nlat,bin_nlon/), "short")
|
forrest@2
|
30 |
npp_short@_FillValue = inttoshort(bin_fill)
|
forrest@2
|
31 |
npp = npp + short2flt(npp_short) * bin_scale_factor
|
forrest@2
|
32 |
cnt = cnt + 1
|
forrest@2
|
33 |
end do
|
forrest@2
|
34 |
|
forrest@2
|
35 |
delete(npp_short)
|
forrest@2
|
36 |
|
forrest@2
|
37 |
npp = npp / int2flt(cnt)
|
forrest@2
|
38 |
|
forrest@2
|
39 |
npp@long_name = "net primary production"
|
forrest@2
|
40 |
npp@units = "gC/m^2/y"
|
forrest@2
|
41 |
npp@_FillValue = 1.e20
|
forrest@2
|
42 |
|
forrest@2
|
43 |
lat = latGlobeFo(bin_nlat, "lat", "latitude", "degrees_north")
|
forrest@2
|
44 |
lat = (/ lat(::-1) /) ; make N->S
|
forrest@2
|
45 |
lon = lonGlobeFo(bin_nlon, "lon", "longitude", "degrees_east")
|
forrest@2
|
46 |
lon = (/ lon - 180. /) ; subtract 180 from all values
|
forrest@2
|
47 |
lon&lon = lon ; update coordinates
|
forrest@2
|
48 |
|
forrest@2
|
49 |
npp!0 = "lat"
|
forrest@2
|
50 |
npp!1 = "lon"
|
forrest@2
|
51 |
npp&lat = lat
|
forrest@2
|
52 |
npp&lon = lon
|
forrest@2
|
53 |
|
forrest@2
|
54 |
ncfile = addfile("npp_0.5deg_mean_" + yr_init + "-" + yr_final + ".nc", "c")
|
forrest@2
|
55 |
ncfile->NPP = npp
|
forrest@2
|
56 |
|
forrest@2
|
57 |
;*************************************
|
forrest@2
|
58 |
; create plot
|
forrest@2
|
59 |
;*************************************
|
forrest@2
|
60 |
|
forrest@2
|
61 |
setvalues NhlGetWorkspaceObjectId()
|
forrest@2
|
62 |
"wsMaximumSize" : 199999999
|
forrest@2
|
63 |
end setvalues
|
forrest@2
|
64 |
|
forrest@2
|
65 |
wks = gsn_open_wks("ps", "npp_0.5deg_mean_" + yr_init + "-" + yr_final) ; open a PostScript file
|
forrest@2
|
66 |
gsn_define_colormap(wks, "gui_default") ; choose colormap
|
forrest@2
|
67 |
|
forrest@2
|
68 |
res = True ; Use plot options
|
forrest@2
|
69 |
res@cnFillOn = True ; Turn on color fill
|
forrest@2
|
70 |
res@cnFillMode = "RasterFill" ; Turn on raster color
|
forrest@2
|
71 |
res@lbLabelAutoStride = True
|
forrest@2
|
72 |
res@cnLinesOn = False ; Turn off contour lines
|
forrest@2
|
73 |
res@gsnSpreadColors = True ; Use full colormap
|
forrest@2
|
74 |
res@mpFillOn = False ; Turn off map fill
|
forrest@2
|
75 |
|
forrest@2
|
76 |
res@cnLevelSelectionMode = "ManualLevels" ; Manual contour invtervals
|
forrest@2
|
77 |
res@cnMinLevelValF = 0. ; Min level
|
forrest@2
|
78 |
res@cnMaxLevelValF = 2200. ; Max level
|
forrest@2
|
79 |
res@cnLevelSpacingF = 200. ; interval
|
forrest@2
|
80 |
res@tiMainString = "MODIS mean net primary production (" + yr_init + "-" + yr_final + ")"
|
forrest@2
|
81 |
|
forrest@2
|
82 |
npp@units = "gC m~S~-2~N~ y~S~-1~N~"
|
forrest@2
|
83 |
|
forrest@2
|
84 |
plot = gsn_csm_contour_map_ce(wks,npp,res)
|
forrest@2
|
85 |
|
forrest@2
|
86 |
delete(wks)
|
forrest@2
|
87 |
|
forrest@2
|
88 |
end
|