forrest@2: load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl" forrest@2: load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl" forrest@2: load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl" forrest@2: forrest@2: begin forrest@2: ; Read in binary (2-byte, short int, little endian) MODIS NPP global forrest@2: ; annual data at 0.5 degree resolution and create a mean that will forrest@2: ; then be reprojected to various computational grids. forrest@2: forrest@2: setfileoption("bin", "ReadByteOrder", "LittleEndian") forrest@2: file_prefix = "Npp_0.05deg_" forrest@2: file_suffix = ".int16" forrest@2: yr_init = 2000 forrest@2: ;yr_final = 2005 forrest@2: yr_final = 2004 forrest@2: forrest@2: bin_nlon = 7200 forrest@2: bin_nlat = 3600 forrest@2: bin_fill = 32700 forrest@2: bin_scale_factor = 0.1 forrest@2: forrest@2: npp = new((/bin_nlat,bin_nlon/), float) forrest@2: npp(:,:) = 0. forrest@2: forrest@2: cnt = 0 forrest@2: do y = yr_init,yr_final forrest@2: ifile = file_prefix + y + file_suffix forrest@2: print("Reading " + ifile) forrest@2: npp_short = fbindirread(ifile, 0, (/bin_nlat,bin_nlon/), "short") forrest@2: npp_short@_FillValue = inttoshort(bin_fill) forrest@2: npp = npp + short2flt(npp_short) * bin_scale_factor forrest@2: cnt = cnt + 1 forrest@2: end do forrest@2: forrest@2: delete(npp_short) forrest@2: forrest@2: npp = npp / int2flt(cnt) forrest@2: forrest@2: npp@long_name = "net primary production" forrest@2: npp@units = "gC/m^2/y" forrest@2: npp@_FillValue = 1.e20 forrest@2: forrest@2: lat = latGlobeFo(bin_nlat, "lat", "latitude", "degrees_north") forrest@2: lat = (/ lat(::-1) /) ; make N->S forrest@2: lon = lonGlobeFo(bin_nlon, "lon", "longitude", "degrees_east") forrest@2: lon = (/ lon - 180. /) ; subtract 180 from all values forrest@2: lon&lon = lon ; update coordinates forrest@2: forrest@2: npp!0 = "lat" forrest@2: npp!1 = "lon" forrest@2: npp&lat = lat forrest@2: npp&lon = lon forrest@2: forrest@2: ncfile = addfile("npp_0.5deg_mean_" + yr_init + "-" + yr_final + ".nc", "c") forrest@2: ncfile->NPP = npp forrest@2: forrest@2: ;************************************* forrest@2: ; create plot forrest@2: ;************************************* forrest@2: forrest@2: setvalues NhlGetWorkspaceObjectId() forrest@2: "wsMaximumSize" : 199999999 forrest@2: end setvalues forrest@2: forrest@2: wks = gsn_open_wks("ps", "npp_0.5deg_mean_" + yr_init + "-" + yr_final) ; open a PostScript file forrest@2: gsn_define_colormap(wks, "gui_default") ; choose colormap forrest@2: forrest@2: res = True ; Use plot options forrest@2: res@cnFillOn = True ; Turn on color fill forrest@2: res@cnFillMode = "RasterFill" ; Turn on raster color forrest@2: res@lbLabelAutoStride = True forrest@2: res@cnLinesOn = False ; Turn off contour lines forrest@2: res@gsnSpreadColors = True ; Use full colormap forrest@2: res@mpFillOn = False ; Turn off map fill forrest@2: forrest@2: res@cnLevelSelectionMode = "ManualLevels" ; Manual contour invtervals forrest@2: res@cnMinLevelValF = 0. ; Min level forrest@2: res@cnMaxLevelValF = 2200. ; Max level forrest@2: res@cnLevelSpacingF = 200. ; interval forrest@2: res@tiMainString = "MODIS mean net primary production (" + yr_init + "-" + yr_final + ")" forrest@2: forrest@2: npp@units = "gC m~S~-2~N~ y~S~-1~N~" forrest@2: forrest@2: plot = gsn_csm_contour_map_ce(wks,npp,res) forrest@2: forrest@2: delete(wks) forrest@2: forrest@2: end