biomass/20.mask_to_1x1.ncl
changeset 0 0c6405ab2ff4
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/biomass/20.mask_to_1x1.ncl	Mon Jan 26 22:08:20 2009 -0500
     1.3 @@ -0,0 +1,112 @@
     1.4 +;************************************************
     1.5 +;    Read ascii, Write nc                         
     1.6 +;************************************************
     1.7 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"  
     1.8 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"  
     1.9 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"   
    1.10 +;************************************************
    1.11 +begin
    1.12 +;---------------------------------------------------
    1.13 +; final data
    1.14 +                                    
    1.15 +  c = addfile("amazon_mask_1x1.nc","c") 
    1.16 +       
    1.17 +  nlat  = 180
    1.18 +  nlon  = 360  
    1.19 +
    1.20 +;************************************************
    1.21 +; read 1x1 mask data
    1.22 +;************************************************
    1.23 +
    1.24 +  diri  = "/fis/cgd/cseg/people/jeff/clamp_data/observed/biomass/"
    1.25 +  fili  = "mask_1x1.txt"
    1.26 +  t     = asciiread(diri+fili,(/180,360/),"integer")
    1.27 +
    1.28 +  printVarSummary(t)
    1.29 +
    1.30 +  print (min(t)+"/"+max(t))                      
    1.31 +
    1.32 +  lon      = new((/nlon/),float)
    1.33 +  lat      = new((/nlat/),float)
    1.34 +
    1.35 +; data is (89.5N->89.5S) (-179.5->179.5)
    1.36 +
    1.37 +; sam result
    1.38 +; lon = fspan(-179.5,179.5,nlon)
    1.39 +; lat = fspan( -89.5, 89.5,nlat)
    1.40 + 
    1.41 +  do i = 0,nlon-1
    1.42 +     lon(i) = -179.5 + i*(360./nlon)
    1.43 +  end do
    1.44 + 
    1.45 +  do j = 0,nlat-1
    1.46 +;    lat(j) = -89.5 + j*(180./nlat)
    1.47 +     lat(j) =  89.5 - j*(180./nlat)
    1.48 +  end do
    1.49 +
    1.50 +; print (lon)
    1.51 +; print (lat)        
    1.52 +;=============================
    1.53 +    ;  create lat and long coordinate variables
    1.54 +    ;============================                                         
    1.55 +     lon!0          = "lon"
    1.56 +     lon@long_name  = "lon"
    1.57 +     lon@units      = "degrees-east"
    1.58 +     lon&lon        = lon
    1.59 +
    1.60 +     lat!0          = "lat"
    1.61 +     lat@long_name  = "lat"
    1.62 +     lat@units      = "degrees_north"
    1.63 +     lat&lat        = lat
    1.64 +    ;=============================
    1.65 +    ;  name dimensions of t and assign coordinate variables
    1.66 +    ;============================  
    1.67 +     t!0    = "lat"
    1.68 +     t!1    = "lon"
    1.69 +     t&lat  = lat
    1.70 +     t&lon  = lon
    1.71 +     t@long_name = "amazon mask"
    1.72 +;    t@units     = ""
    1.73 +     t@_FillValue= -999         
    1.74 +     t@missing_value= -999 
    1.75 +        
    1.76 +  c->mask_amazon  = t
    1.77 +  c->lat  = lat
    1.78 +  c->lon  = lon
    1.79 +
    1.80 +;************************************************
    1.81 +; create default plot
    1.82 +;************************************************
    1.83 +
    1.84 +  wks = gsn_open_wks("ps","xy")         ; open a ps file
    1.85 +  gsn_define_colormap(wks,"gui_default")     ; choose colormap
    1.86 +
    1.87 +  res                     = True             ; Use plot options
    1.88 +  res@cnFillOn            = True             ; Turn on color fill
    1.89 +  res@gsnSpreadColors      = True            ; use full colormap
    1.90 +; res@cnFillMode          = "RasterFill"     ; Turn on raster color
    1.91 +; res@lbLabelAutoStride   = True
    1.92 +  res@cnLinesOn           = False            ; Turn off contourn lines
    1.93 +  res@mpFillOn            = False            ; Turn off map fill
    1.94 +  res@gsnAddCyclic        = False
    1.95 +  res@tiMainString        = "LC15_amazon_biomass"
    1.96 +
    1.97 +  res@mpMinLatF            = -21.1      ; range to zoom in on
    1.98 +  res@mpMaxLatF            =  13.8
    1.99 +  res@mpMinLonF            =  277.28
   1.100 +  res@mpMaxLonF            =  326.43
   1.101 +
   1.102 +  res@gsnSpreadColors     = True             ; use full colormap
   1.103 +  res@cnLevelSelectionMode = "ManualLevels"  ; Manual contour invtervals
   1.104 +; res@cnMinLevelValF       = 1.              ; Min level
   1.105 +; res@cnMaxLevelValF       = 11.             ; Max level
   1.106 +; res@cnLevelSpacingF      = 1.              ; interval
   1.107 +  res@cnMinLevelValF       = 0.              ; Min level
   1.108 +  res@cnMaxLevelValF       = 1.             ; Max level
   1.109 +  res@cnLevelSpacingF      = 0.1              ; interval
   1.110 +; pres                            = True     ; panel plot mods desired
   1.111 +; pres@gsnMaximize                = True     ; fill the page
   1.112 +
   1.113 +  plot = gsn_csm_contour_map_ce(wks,t,res)   ; for observed
   1.114 +
   1.115 +end