biomass/20.mask_to_1x1.ncl
author Forrest Hoffman <forrest@climatemodeling.org>
Thu, 26 Mar 2009 14:02:21 -0400
changeset 1 4be95183fbcd
permissions -rw-r--r--
Modifications to scoring and graphics production for the final version of code for the C-LAMP paper in GCB.
forrest@0
     1
;************************************************
forrest@0
     2
;    Read ascii, Write nc                         
forrest@0
     3
;************************************************
forrest@0
     4
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"  
forrest@0
     5
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"  
forrest@0
     6
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"   
forrest@0
     7
;************************************************
forrest@0
     8
begin
forrest@0
     9
;---------------------------------------------------
forrest@0
    10
; final data
forrest@0
    11
                                    
forrest@0
    12
  c = addfile("amazon_mask_1x1.nc","c") 
forrest@0
    13
       
forrest@0
    14
  nlat  = 180
forrest@0
    15
  nlon  = 360  
forrest@0
    16
forrest@0
    17
;************************************************
forrest@0
    18
; read 1x1 mask data
forrest@0
    19
;************************************************
forrest@0
    20
forrest@0
    21
  diri  = "/fis/cgd/cseg/people/jeff/clamp_data/observed/biomass/"
forrest@0
    22
  fili  = "mask_1x1.txt"
forrest@0
    23
  t     = asciiread(diri+fili,(/180,360/),"integer")
forrest@0
    24
forrest@0
    25
  printVarSummary(t)
forrest@0
    26
forrest@0
    27
  print (min(t)+"/"+max(t))                      
forrest@0
    28
forrest@0
    29
  lon      = new((/nlon/),float)
forrest@0
    30
  lat      = new((/nlat/),float)
forrest@0
    31
forrest@0
    32
; data is (89.5N->89.5S) (-179.5->179.5)
forrest@0
    33
forrest@0
    34
; sam result
forrest@0
    35
; lon = fspan(-179.5,179.5,nlon)
forrest@0
    36
; lat = fspan( -89.5, 89.5,nlat)
forrest@0
    37
 
forrest@0
    38
  do i = 0,nlon-1
forrest@0
    39
     lon(i) = -179.5 + i*(360./nlon)
forrest@0
    40
  end do
forrest@0
    41
 
forrest@0
    42
  do j = 0,nlat-1
forrest@0
    43
;    lat(j) = -89.5 + j*(180./nlat)
forrest@0
    44
     lat(j) =  89.5 - j*(180./nlat)
forrest@0
    45
  end do
forrest@0
    46
forrest@0
    47
; print (lon)
forrest@0
    48
; print (lat)        
forrest@0
    49
;=============================
forrest@0
    50
    ;  create lat and long coordinate variables
forrest@0
    51
    ;============================                                         
forrest@0
    52
     lon!0          = "lon"
forrest@0
    53
     lon@long_name  = "lon"
forrest@0
    54
     lon@units      = "degrees-east"
forrest@0
    55
     lon&lon        = lon
forrest@0
    56
forrest@0
    57
     lat!0          = "lat"
forrest@0
    58
     lat@long_name  = "lat"
forrest@0
    59
     lat@units      = "degrees_north"
forrest@0
    60
     lat&lat        = lat
forrest@0
    61
    ;=============================
forrest@0
    62
    ;  name dimensions of t and assign coordinate variables
forrest@0
    63
    ;============================  
forrest@0
    64
     t!0    = "lat"
forrest@0
    65
     t!1    = "lon"
forrest@0
    66
     t&lat  = lat
forrest@0
    67
     t&lon  = lon
forrest@0
    68
     t@long_name = "amazon mask"
forrest@0
    69
;    t@units     = ""
forrest@0
    70
     t@_FillValue= -999         
forrest@0
    71
     t@missing_value= -999 
forrest@0
    72
        
forrest@0
    73
  c->mask_amazon  = t
forrest@0
    74
  c->lat  = lat
forrest@0
    75
  c->lon  = lon
forrest@0
    76
forrest@0
    77
;************************************************
forrest@0
    78
; create default plot
forrest@0
    79
;************************************************
forrest@0
    80
forrest@0
    81
  wks = gsn_open_wks("ps","xy")         ; open a ps file
forrest@0
    82
  gsn_define_colormap(wks,"gui_default")     ; choose colormap
forrest@0
    83
forrest@0
    84
  res                     = True             ; Use plot options
forrest@0
    85
  res@cnFillOn            = True             ; Turn on color fill
forrest@0
    86
  res@gsnSpreadColors      = True            ; use full colormap
forrest@0
    87
; res@cnFillMode          = "RasterFill"     ; Turn on raster color
forrest@0
    88
; res@lbLabelAutoStride   = True
forrest@0
    89
  res@cnLinesOn           = False            ; Turn off contourn lines
forrest@0
    90
  res@mpFillOn            = False            ; Turn off map fill
forrest@0
    91
  res@gsnAddCyclic        = False
forrest@0
    92
  res@tiMainString        = "LC15_amazon_biomass"
forrest@0
    93
forrest@0
    94
  res@mpMinLatF            = -21.1      ; range to zoom in on
forrest@0
    95
  res@mpMaxLatF            =  13.8
forrest@0
    96
  res@mpMinLonF            =  277.28
forrest@0
    97
  res@mpMaxLonF            =  326.43
forrest@0
    98
forrest@0
    99
  res@gsnSpreadColors     = True             ; use full colormap
forrest@0
   100
  res@cnLevelSelectionMode = "ManualLevels"  ; Manual contour invtervals
forrest@0
   101
; res@cnMinLevelValF       = 1.              ; Min level
forrest@0
   102
; res@cnMaxLevelValF       = 11.             ; Max level
forrest@0
   103
; res@cnLevelSpacingF      = 1.              ; interval
forrest@0
   104
  res@cnMinLevelValF       = 0.              ; Min level
forrest@0
   105
  res@cnMaxLevelValF       = 1.             ; Max level
forrest@0
   106
  res@cnLevelSpacingF      = 0.1              ; interval
forrest@0
   107
; pres                            = True     ; panel plot mods desired
forrest@0
   108
; pres@gsnMaximize                = True     ; fill the page
forrest@0
   109
forrest@0
   110
  plot = gsn_csm_contour_map_ce(wks,t,res)   ; for observed
forrest@0
   111
forrest@0
   112
end