lai/03.lai_ob_to_0.25deg.ncl.0
author Forrest Hoffman <forrest@climatemodeling.org>
Mon, 26 Jan 2009 22:08:20 -0500
changeset 0 0c6405ab2ff4
permissions -rw-r--r--
Initial commit of C-LAMP Diagnostics from Jeff Lee
forrest@0
     1
; ***********************************************
forrest@0
     2
; interpolate into 0.25degree
forrest@0
     3
; no change in lat and lon, to be in consistent with 
forrest@0
     4
; land class data
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
  year = 2003
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/"
forrest@0
    18
  filo  = "LAI_2000-2005_mean_0.25.nc"
forrest@0
    19
  c = addfile(diro+filo,"c")
forrest@0
    20
  filedimdef(c,"time",-1,True)
forrest@0
    21
forrest@0
    22
;************************************************
forrest@0
    23
; read in observed data
forrest@0
    24
;************************************************
forrest@0
    25
  diri  = "/fis/cgd/cseg/people/jeff/clamp_data/lai/"
forrest@0
    26
; fili  = "LAI_2000-2005_mean_0.05deg.nc"
forrest@0
    27
  fili  = "LAI_2000-2005_ensemble_0.05deg.nc"
forrest@0
    28
  g     = addfile (diri+fili,"r")
forrest@0
    29
  bi    = g->LAI   
forrest@0
    30
  xi    = g->lon 
forrest@0
    31
  yi    = g->lat
forrest@0
    32
forrest@0
    33
;************************************************
forrest@0
    34
; change into 0-360E, 90S-90N
forrest@0
    35
; Observed NPP*scale_factor
forrest@0
    36
;************************************************
forrest@0
    37
 
forrest@0
    38
 yi    = (/ yi(::-1) /)
forrest@0
    39
 bi    = (/ bi(:,::-1,:) /)
forrest@0
    40
 printVarSummary(bi)
forrest@0
    41
forrest@0
    42
 b2    = bi
forrest@0
    43
 x2    = xi   
forrest@0
    44
 
forrest@0
    45
 nx = dimsizes(xi)
forrest@0
    46
 do i= 0,nx-1
forrest@0
    47
    if (i .lt. 3600) then
forrest@0
    48
       p = i + 3600
forrest@0
    49
       xi(p) = x2(i) + 360.      
forrest@0
    50
    else
forrest@0
    51
       p = i - 3600
forrest@0
    52
       xi(p) = x2(i)
forrest@0
    53
    end if
forrest@0
    54
    bi(:,:,p)= b2(:,:,i) 
forrest@0
    55
 end do
forrest@0
    56
forrest@0
    57
 bi&lat =  yi
forrest@0
    58
 bi&lon =  xi
forrest@0
    59
forrest@0
    60
;print (xi)
forrest@0
    61
;print (yi)
forrest@0
    62
;exit
forrest@0
    63
forrest@0
    64
;************************************************
forrest@0
    65
; read in model data
forrest@0
    66
;************************************************
forrest@0
    67
;fili2  = "i01.03cn_1545-1569_ANN_climo.nc"
forrest@0
    68
 fili2  = ""
forrest@0
    69
 f     = addfile (diri+fili2,"r")
forrest@0
    70
forrest@0
    71
 lon    = f->lon     
forrest@0
    72
 lat    = f->lat
forrest@0
    73
 nlon   = dimsizes(lon)
forrest@0
    74
 nlat   = dimsizes(lat)      
forrest@0
    75
forrest@0
    76
; print (xi)
forrest@0
    77
; print (yi)
forrest@0
    78
; print (xo)
forrest@0
    79
; print (yo)
forrest@0
    80
forrest@0
    81
;(A)
forrest@0
    82
;bo = linint2_Wrap(xi,yi,bi,True,xo,yo,0)
forrest@0
    83
forrest@0
    84
;(B)
forrest@0
    85
forrest@0
    86
; rad   = 4.*atan(1.)/180.
forrest@0
    87
; clat  = lat
forrest@0
    88
; clat  = cos(lat*rad)
forrest@0
    89
; clat@long_name = "cos(latitude)"
forrest@0
    90
; delete(clat@units)
forrest@0
    91
; printVarSummary(clat)
forrest@0
    92
forrest@0
    93
 bo = new((/12,nlat,nlon/),float)
forrest@0
    94
;bo = new((/1,nlat,nlon/),float)
forrest@0
    95
 do m = 0,11
forrest@0
    96
    do j=0,nlat-1
forrest@0
    97
       if (j.eq.0 .or. j.eq.nlat-1) then
forrest@0
    98
          if (j.eq.0) then
forrest@0
    99
             LATS = -90.          
forrest@0
   100
             LATN = lat(j)+0.5*(lat(j+1)-lat(j))
forrest@0
   101
          end if
forrest@0
   102
          if (j.eq.nlat-1) then
forrest@0
   103
             LATS = lat(j)-0.5*(lat(j)-lat(j-1))
forrest@0
   104
             LATN = 90.                  
forrest@0
   105
          end if
forrest@0
   106
       else
forrest@0
   107
          LATS = lat(j)-0.5*(lat(j)-lat(j-1))
forrest@0
   108
          LATN = lat(j)+0.5*(lat(j+1)-lat(j))
forrest@0
   109
       end if
forrest@0
   110
 
forrest@0
   111
;      CLAT = clat({LATS:LATN})      ; do once for *slight* efficiency
forrest@0
   112
;      TEMP = bi(:,{LATS:LATN},:)      ; 2D [lat,lon]
forrest@0
   113
 
forrest@0
   114
      do i=0,nlon-1
forrest@0
   115
       if (i.eq.0 .or. i.eq.nlon-1) then
forrest@0
   116
          if (i.eq.0) then
forrest@0
   117
             LONL = 0.          
forrest@0
   118
             LONR = lon(i)+0.5*(lon(i+1)-lon(i))
forrest@0
   119
          end if
forrest@0
   120
          if (i.eq.nlon-1) then
forrest@0
   121
             LONL = lon(i)-0.5*(lon(i)-lon(i-1))
forrest@0
   122
             LONR = 360.                 
forrest@0
   123
          end if
forrest@0
   124
       else
forrest@0
   125
          LONL = lon(i)-0.5*(lon(i)-lon(i-1))
forrest@0
   126
          LONR = lon(i)+0.5*(lon(i+1)-lon(i))
forrest@0
   127
       end if
forrest@0
   128
forrest@0
   129
;print (LATS)
forrest@0
   130
;print (LATN)
forrest@0
   131
;print (LONL)
forrest@0
   132
;print (LONR)
forrest@0
   133
;        bo(:,j,i) = avg(bi(:,{LATS:LATN},{LONL:LONR}))
forrest@0
   134
         bo(m,j,i) = avg(bi(m,{LATS:LATN},{LONL:LONR}))  
forrest@0
   135
;        bo(:,j,i) = wgt_areaave(TEMP(:,{LONL:LONR}), CLAT, 1.0, 0)
forrest@0
   136
      end do
forrest@0
   137
 
forrest@0
   138
;     delete(CLAT)
forrest@0
   139
;     delete(TEMP) 
forrest@0
   140
    end do
forrest@0
   141
  end do
forrest@0
   142
forrest@0
   143
  bo!0   = "time"
forrest@0
   144
  bo!1   = "lat"
forrest@0
   145
  bo!2   = "lon"
forrest@0
   146
  bo&time= bi&time
forrest@0
   147
; bo&time= 1
forrest@0
   148
  bo&lat = lat
forrest@0
   149
  bo&lon = lon
forrest@0
   150
; bo@units      = bi@units
forrest@0
   151
; bo@long_name  = bi@long_name
forrest@0
   152
  bo@units      = "none"
forrest@0
   153
  bo@long_name  = "Leaf Area Index"
forrest@0
   154
  bo@_FillValue = bi@_FillValue
forrest@0
   155
forrest@0
   156
  c->LAI  = bo
forrest@0
   157
end