co2/24.check.ncl
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
; add another model to plot
forrest@0
     3
; add panel plot to 22.lines.ncl
forrest@0
     4
; add zone plot to 21.lines.ncl
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
; read in data: observed
forrest@0
    13
;************************************************
forrest@0
    14
 diri  = "/fis/cgd/cseg/people/jeff/clamp_data/co2/"
forrest@0
    15
 fili  = "co2_globalView_98.nc"
forrest@0
    16
 g     = addfile (diri+fili,"r")
forrest@0
    17
 val   = g->CO2_SEAS  
forrest@0
    18
 lon   = g->LON 
forrest@0
    19
 lat   = g->LAT
forrest@0
    20
 sta   = chartostring(g->STATION) 
forrest@0
    21
 delete (g)
forrest@0
    22
 
forrest@0
    23
;print (sta(0))
forrest@0
    24
forrest@0
    25
 ncase = dimsizes(lat)
forrest@0
    26
;print (ncase)
forrest@0
    27
forrest@0
    28
;**************************************************************
forrest@0
    29
; get only the lowest level at each station 
forrest@0
    30
;**************************************************************
forrest@0
    31
 lat_tmp = lat
forrest@0
    32
 lat_tmp@_FillValue = 1.e+36
forrest@0
    33
 
forrest@0
    34
 do n = 0,ncase-1
forrest@0
    35
    if (.not. ismissing(lat_tmp(n))) then 
forrest@0
    36
       indexes = ind(lat(n) .eq. lat .and. lon(n) .eq. lon)
forrest@0
    37
       if (dimsizes(indexes) .gt. 1) then
forrest@0
    38
          lat_tmp(indexes(1:)) = lat_tmp@_FillValue
forrest@0
    39
       end if
forrest@0
    40
       delete (indexes)
forrest@0
    41
    end if
forrest@0
    42
 end do
forrest@0
    43
forrest@0
    44
 indexes = ind(.not. ismissing(lat_tmp))
forrest@0
    45
;print (dimsizes(indexes))
forrest@0
    46
;print (indexes)
forrest@0
    47
 
forrest@0
    48
 lat_ob = lat(indexes)
forrest@0
    49
 lon_ob = lon(indexes)
forrest@0
    50
 val_ob = val(indexes,:)
forrest@0
    51
;printVarSummary (val_ob)
forrest@0
    52
;print (lat_ob +"/"+lon_ob)
forrest@0
    53
forrest@0
    54
;************************************************
forrest@0
    55
; read in model data
forrest@0
    56
;************************************************
forrest@0
    57
  diri2 = "/fis/cgd/cseg/people/jeff/clamp_data/model/"
forrest@0
    58
  fili2 = "b30.061n_1995-2004_MONS_climo_atm.nc"
forrest@0
    59
  fili3 = "b30.061m_401_425_MONS_climo_atm.nc"
forrest@0
    60
;--------------------------------------------
forrest@0
    61
  g    = addfile(diri2+fili2,"r")
forrest@0
    62
  x1   = g->CO2
forrest@0
    63
  xi   = g->lon
forrest@0
    64
  yi   = g->lat
forrest@0
    65
  delete (g)
forrest@0
    66
forrest@0
    67
  xdim  = dimsizes(x1)
forrest@0
    68
  nlev  = xdim(1)
forrest@0
    69
; y1     = x1(:,0,:,:)
forrest@0
    70
  y1     = x1
forrest@0
    71
; printVarSummary (y1)
forrest@0
    72
  
forrest@0
    73
; get the co2 at the lowest level
forrest@0
    74
; y1     = x1(:,nlev-1,:,:)
forrest@0
    75
  delete (x1)
forrest@0
    76
;---------------------------------------------
forrest@0
    77
; g     = addfile(diri2+fili3,"r")
forrest@0
    78
; x2    = g->CO2
forrest@0
    79
; delete (g)
forrest@0
    80
; y2     = x2(:,0,:,:)
forrest@0
    81
; y2     = x2(:,nlev-1,:,:)
forrest@0
    82
; delete (x2)
forrest@0
    83
;---------------------------------------------
forrest@0
    84
; change to unit of observed (u mol/mol)
forrest@0
    85
; Model_units [=] kgCO2 / kgDryAir
forrest@0
    86
; 28.966 = molecular weight of dry air
forrest@0
    87
; 44.       = molecular weight of CO2
forrest@0
    88
; u mol = 1e-6 mol
forrest@0
    89
forrest@0
    90
  factor = (28.966/44.) * 1e6
forrest@0
    91
;---------------------------------------------
forrest@0
    92
  y1 = y1 * factor
forrest@0
    93
  y1@_FillValue = 1.e36
forrest@0
    94
  y1@units      = "u mol/mol"
forrest@0
    95
; y1 = where(y0 .lt. 287.,y1@_FillValue,y1)
forrest@0
    96
; printVarSummary (y1)
forrest@0
    97
; print (min(y1)+"/"+max(y1))
forrest@0
    98
;---------------------------------------------
forrest@0
    99
; y2 = y2 * factor
forrest@0
   100
; y2@_FillValue = 1.e36
forrest@0
   101
; y2@units      = "u mol/mol"
forrest@0
   102
;---------------------------------------------
forrest@0
   103
; interpolate into observed station
forrest@0
   104
; note: model is 0-360E,   90S-90N
forrest@0
   105
;       ob    is -180-180, 90S-90N
forrest@0
   106
forrest@0
   107
; to be able to handle observation at (-89.98,-24.80)
forrest@0
   108
; print (yi(0))
forrest@0
   109
  yi(0) = -90.
forrest@0
   110
forrest@0
   111
  i = ind(lon_ob .lt. 0.)
forrest@0
   112
  lon_ob(i) = lon_ob(i) + 360.  
forrest@0
   113
;----------------------------------------------------------------
forrest@0
   114
  yo = linint2_points_Wrap(xi,yi,y1,True,lon_ob,lat_ob,0)
forrest@0
   115
  printVarSummary (yo)
forrest@0
   116
; yo:[time | 12] x [lev | 26] x [pts | 98]
forrest@0
   117
forrest@0
   118
  val_model1 = yo(pts|:,lev|:,time|:)
forrest@0
   119
  delete (yo)
forrest@0
   120
  val_model1_0 = val_model1
forrest@0
   121
; printVarSummary (val_model1)
forrest@0
   122
; print (min(val_model1)+"/"+max(val_model1))
forrest@0
   123
forrest@0
   124
; remove annual mean
forrest@0
   125
  val_model1 = val_model1 - conform(val_model1,dim_avg(val_model1),(/0,1/))
forrest@0
   126
; print (min(val_model1)+"/"+max(val_model1))
forrest@0
   127
forrest@0
   128
;-----------------------------------------------------------------
forrest@0
   129
;    index of station Barrow, Alaska (71.32,-156.60)
forrest@0
   130
     ind_z = ind(lat_ob .eq. 71.32)
forrest@0
   131
     print (ind_z)
forrest@0
   132
     print (lat_ob(ind_z)+"/"+lon_ob(ind_z))
forrest@0
   133
     print ("observation at Barrow, Alaska (71.32,-156.60)")
forrest@0
   134
     print (val_ob(ind_z,:))
forrest@0
   135
     print ("model top atm  at Barrow, Alaska (71.32,-156.60)")
forrest@0
   136
     print (val_model1_0(ind_z,0,:))
forrest@0
   137
     print ("model surface at Barrow, Alaska (71.32,-156.60)")
forrest@0
   138
     print (val_model1_0(ind_z,nlev-1,:))
forrest@0
   139
     print ("model top atm  at Barrow, Alaska (71.32,-156.60)")
forrest@0
   140
     print (val_model1(ind_z,0,:))
forrest@0
   141
     print ("model surface at Barrow, Alaska (71.32,-156.60)")
forrest@0
   142
     print (val_model1(ind_z,nlev-1,:))
forrest@0
   143
end