Coordinate variable specification

From: Correia, James <james.correia_at_nyahnyahspammersnyahnyah>
Date: Wed, 04 Feb 2009 14:38:25 -0800

Hi all-
I am getting the error:
Check_for_lon_coord and A valid coordinate array should have units ...

My question is:
How do I print out not only the variable summary but also the variables
coordinate information?

 printVarSummary lists the variables coordinates but not there attributes. I
have tried to set the coordinates properly, but I appear to be doing
something incorrectly.

I am working with ccsm3 data.

I have copied the script below

James Correia Jr., PhD
Climate Physics Group
Post. Doc.
Pacific Northwest National Lab

"Wisdom. Strength. Courage. Generosity. Each of us are born with one of
these. It is up to us to find the other three inside of us."
-Into the West

:
;*************************************************
; WRF: panel three different variables at the same time step
;************************************************
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/wrf/WRF_contributed.ncl"
begin
;************************************************
; open file and read in data
;************************************************
var = "pr" ;cape,shr,eml,qbar,llj,cash

if(var .eq. "pr")then
unit = "mm/day"
end if

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; CCSM GCM
  e1 =
addfile("/scratch2/narccap/b30.030e.cam2.h0.PRECL.1970-01_cat_1979-12.nc",
"r")
  e2 =
addfile("/scratch2/narccap/b30.030e.cam2.h0.PRECL.1980-01_cat_1989-12.nc",
"r")
  e3 =
addfile("/scratch2/narccap/b30.030e.cam2.h0.PRECL.1990-01_cat_1999-12.nc",
"r")

  e4 =
addfile("/scratch2/narccap/b30.030e.cam2.h0.PRECC.1970-01_cat_1979-12.nc",
"r")
  e5 =
addfile("/scratch2/narccap/b30.030e.cam2.h0.PRECC.1980-01_cat_1989-12.nc",
"r")
  e6 =
addfile("/scratch2/narccap/b30.030e.cam2.h0.PRECC.1990-01_cat_1999-12.nc",
"r")

  e7 =
addfile("/scratch2/narccap/b30.042e.cam2.h0.PRECL.2000-01_cat_2099-12.nc",
"r")
  e8 =
addfile("/scratch2/narccap/b30.042e.cam2.h0.PRECC.2000-01_cat_2099-12.nc",
"r")

lat = e1->lat
lon = e1->lon

var1 = e1->PRECL
printVarSummary(var1)
var2 = e2->PRECL
var3 = e3->PRECL

var4 = e4->PRECC
var5 = e5->PRECC
var6 = e6->PRECC

var7 = e7->PRECL
var8 = e8->PRECC

var1 = var1*3600.*24.*1000.
var2 = var2*3600.*24.*1000.
var3 = var3*3600.*24.*1000.
var4 = var4*3600.*24.*1000.
var5 = var5*3600.*24.*1000.
var6 = var6*3600.*24.*1000.
var7 = var7*3600.*24.*1000.
var8 = var8*3600.*24.*1000.

;units are m/s need mm/day : 3600.*24.*30.5/1000.
ct1 = dimsizes(var1)
ct2 = dimsizes(var2)
ct3 = dimsizes(var3)

cvar = new((/360,128,256/),float)
cctas = new((/7,30,128,256/),float)
fftas = new((/7,30,128,256/),float)

;get clim vars together to loop over to collect
cvar(0:ct1(0)-1,:,:) = var1(:,:,:)+var4(:,:,:)
cvar(ct1(0):ct1(0)+ct2(0)-1,:,:) = var2(:,:,:)+var5(:,:,:)
cvar(ct1(0)+ct2(0):ct1(0)+ct2(0)+ct3(0)-1,:,:) = var3(:,:,:)+var6(:,:,:)

fvar = var7+var8

ii = -1
do j=0,29
jj = -1
do i=0,11
ii = ii + 1
if(i.lt.5 .and. i .gt. 8)then
jj = jj + 1
cctas(jj,j,:,:) = cvar(ii,:,:)
end if
end do
end do
cctas!0 = "month"
cctas!1 = "year"
cctas!2 = "lat"
cctas!3 = "lon"
print(cctas&lat)

cctas&lat = lat
cctas&lon = lon
printVarSummary(cctas)

cctas&lat_at_units = "degrees_north"
cctas&lon_at_units = "degrees_east"
printVarSummary(cctas)

ctas = dim_avg_Wrap(cctas(lat|:,lon|:,month|:,year|:))
copy_VarCoords(var1(lat|:,lon|:,time|:6),ctas(:,:,:))
printVarSummary(ctas)

ii = -1
do j=0,99
jj = -1
do i=0,11
ii = ii +1
if(j .gt. 29 .and. j .lt. 61)then
if(i .lt. 5 .and. i .gt. 8)then
jj = jj +1
fftas(jj,j,:,:) = fvar(ii,:,:)
end if
end if
end do
end do
;copy_VarCoords(var1(:119,:,:),fftas)
fftas!0 = "month"
fftas!1 = "year"
fftas!2 = "lat"
fftas!3 = "lon"

fftas&lat = lat
fftas&lon = lon
fftas&lat_at_units = "degrees_north"
fftas&lon_at_units = "degrees_east"

;cdif = var1(0,:,:)
ftas = dim_avg_Wrap(fftas(lat|:,lon|:,month|:,year|:))
copy_VarCoords(var1(lat|:,lon|:,time|:6),ftas(:,:,:))

printVarSummary(ftas)

cdif = ftas - ctas

resa = True
  resa_at_gsnRightString = "mm/day"
  resa_at_gsnAddCyclic =False
  resa_at_mpMaxLonF = lona(y2,x2)-15.
  resa_at_mpMaxLatF = lata(y2,x2)+11.
  resa_at_mpMinLonF = lona(y1,x1)-15.
  resa_at_mpMinLatF = lata(y1,x1)+2.
  resa_at_mpFillOn = False
  resa_at_gsnMaximize = True ; uncomment to maximize size
  resa_at_gsnSpreadColors = True ; use full range of colormap
  resa_at_cnFillOn = True ; color plot desired
  resa_at_cnLinesOn = False ; turn off contour lines
  resa_at_cnLineLabelsOn = False ; turn off contour labels
  resa_at_lbLabelAutoStride = True ; let NCL figure lb stride
  resa_at_cnLevelSelectionMode = "ExplicitLevels" ; explicit [unequal] cn
levels
  resa_at_gsnDraw =False
  resa_at_gsnFrame = False

do u=0,6
  resa_at_gsnSpreadColorStart = 2
  resa_at_gsnSpreadColorEnd = 11
  resa_at_gsnLeftString ="CCSM Precip current"
  resa_at_gsnRightString = ""
  resa_at_cnLevels = (/0,.25,.5,1.,1.5,2.,3.,5.,10./)
plot(u) = gsn_csm_contour_map_ce(wks,ctas(:,:,u),resa)

delete(resa_at_cnLevels)
  resa_at_cnLevels = (/-1,-0.5,-.25,-.1,0,0.1,0.25,0.5,1/)
  resa_at_gsnSpreadColorStart = 12
  resa_at_gsnSpreadColorEnd = 21
  resa_at_gsnLeftString ="CCSM Precip change"
plot(u+1) = gsn_csm_contour_map_ce(wks,cdif(:,:,u),resa)
end do
;************************************************
; create panel: panel plots have their own set of resources
;************************************************
  resP = True ; modify the panel plot
  resP_at_txString = " "
  resP_at_gsnMaximize = True ; maximize panel area
  resP_at_vpHeightF = 0.345614
  resP_at_vpWidthF = 0.413117
  resP_at_gsnPanelRowSpec = True ; specify 1 top, 2 lower
level
  resP_at_gsnPanelFigureStrings = (/"A","B","C","D","E","F","G","H"/)
  gsn_panel(wks,plot,(/4,4/),resP) ; now draw as one plot

end

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Wed Feb 04 2009 - 15:38:25 MST

This archive was generated by hypermail 2.2.0 : Thu Feb 05 2009 - 17:21:37 MST