help

From: kalim ullah <kalimrid_at_nyahnyahspammersnyahnyah>
Date: Thu Dec 17 2009 - 06:32:42 MST

Dear NCL Users,
I am trying to find the climatology and using the example (climo_6.ncl) but the script is not running properly, please anyone have a look on the script given below:
thanks and regards,
kalim
************************
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/csm/shea_util.ncl"
begin
plev = 850 ; 850hPa
ymStrt = 197901 ; start yyyymm
ymLast = 200812 ; last
yrStrt = ymStrt/100
yrLast = ymLast/100
wksType = "x11"
wksName = "climo" ; ": "+yrStrt+"_"+yrLast
diri = "/disk1/home/bwd/" ; input directory
;***********************************************************
fili = "sst.mnmean.nc"
f = addfile (diri+fili , "r")
time = f->time ; yyyymmdd (all times)
;yyyymm = time/100 ; yyyymm
yyyymm = ut_calendar(time, -1) ; convert to yyyymm
ntStrt = ind(yyyymm.eq.ymStrt) ; index start
ntLast = ind(yyyymm.eq.ymLast) ; index last
;sst = f->sst(ntStrt:ntLast,:,:) ; year-month
; Climatology
sst = short2flt( f->sst(ntStrt:ntLast,:,:))
sstClm = clmMonTLL( sst) ; (month,lat,lon)
delete(yyyymm)
delete(time)
delete(sst)
; land-sea mask distributed with NCL
fmsk = addfile("$NCARG_ROOT/lib/ncarg/data/cdf/landsea.nc","r")
lsmask = landsea_mask(fmsk->LSMASK,sstClm&lat,sstClm&lon)
sstClm = mask(sstClm,lsmask.eq.1,False) ; mask out land points
printVarSummary( sstClm )
;printMinMax( sstClm, True )
;***********************************************************
; Read year-month PRC; Create climatology for desired period
;***********************************************************
fili = "precip.mon.mean.nc"
f = addfile(diri+fili , "r")
time = f->time ; days since ...
yyyymm = ut_calendar(time, -1) ; convert to yyyymm
ntStrt = ind(yyyymm.eq.ymStrt) ; index start
ntLast = ind(yyyymm.eq.ymLast) ; index last
prc = f->precip(ntStrt:ntLast,:,:) ; year-month
prcClm = clmMonTLL( prc) ; Climatology
; (12,lat,lon)
delete(yyyymm)
delete(time)
delete(prc)
printVarSummary( prcClm )
printMinMax( prcClm, True )
;***********************************************************
; Read year-month U ; Create climatology for desired period
; Convert type short to float
;************************************************************
fili = "uwnd.mon.mean.nc"
f = addfile (diri+fili , "r")
time = f->time ; days since ...
yyyymm = ut_calendar(time, -1) ; convert to yyyymm
ntStrt = ind(yyyymm.eq.ymStrt) ; index start
ntLast = ind(yyyymm.eq.ymLast) ; index last
uwnd = short2flt( f->uwnd(ntStrt:ntLast,{plev},:,:) )
uwndClm = clmMonTLL( uwnd ) ; Climatology
; (12,lat,lon)
delete(time)
delete(yyyymm)
delete(uwnd)
;printVarSummary( uwndClm )
;printMinMax( uwndClm, True )
;***********************************************************
; Read year-month OLR; Create climatology for desired period
; Convert type short to float
;***********************************************************
fili = "olr.mon.mean.nc"
f = addfile (diri+fili , "r")
time = f->time ; days since ...
yyyymm = ut_calendar(time, -1) ; convert to yyyymm
ntStrt = ind(yyyymm.eq.ymStrt) ; index start
ntLast = ind(yyyymm.eq.ymLast) ; index last
olr = short2flt( f->olr(ntStrt:ntLast,:,:) ) ; year-month
olrClm = clmMonTLL( olr ) ; Climatology
; (12,lat,lon)
delete(yyyymm)
delete(time)
delete(olr)
;printVarSummary( olrClm )
;printMinMax( olrClm, True )
;************************************************
; plots ; Compute 6-month climatologies
;************************************************
; (2,6)
season =(/(/ 5, 6, 7, 8, 9,10/)\ ; May-Oct [summer]
, (/ 1, 2, 3, 4,11,12/) /) ; Nov-Apr [winter]
i_season = season - 1 ; NCL indices
season_label = (/ "May-Oct Climatology", "Nov-Apr Climatology"/)
plot = new ( 3, "graphic")
wks = gsn_open_wks(wksType, wksName)
gsn_define_colormap(wks,"amwg")
;************************************************
; resource list for first (color) data array
;************************************************
res1 = True
res1@gsnDraw = False ; don't draw
res1@gsnFrame = False ; don't advance frame
res1@gsnStringFontHeightF = 0.0125 ; make larger than default
res1@lbOrientation = "Vertical" ; vertical label bar
res1@lbLabelFontHeightF = 0.01 ; make labels larger
res1@pmLabelBarOrthogonalPosF = -0.025 ; move closer to plot
res1@lbLabelAutoStride = True ; optimal label stride
res1@gsnSpreadColors = True ; use full range of colors
res1@mpMinLonF = 30. ; select a subregion
res1@mpMaxLonF = 120.
res1@mpMinLatF = 0.
res1@mpMaxLatF = 50.
res1@mpLandFillColor = "background" ; color of land
;res1@cnFillDrawOrder = "Predraw"
;************************************************
; resource list for second (contour only) data array
;************************************************
res2 = True
res2@gsnDraw = False
res2@gsnFrame = False
res2@cnLevelSpacingF = 2. ; set contour spacing
res2@cnInfoLabelOn = False ; do not want
res2@cnLineLabelsOn = True
res2@cnLabelMasking = True
;************************************************
; resource list for panel
;************************************************
resP = True ; modify the panel plot
resP@gsnMaximize = True ; make large
;resP@gsnPaperOrientation = "portrait" ; force "portrait"
delete(sstClm@long_name) ; do not want
res1@gsnRightString = "SST (C): contour"
do ns =0,1 ; 2 seasons
res1@cnLevelSpacingF = 20.0 ; set contour spacing
res1@gsnLeftString = "OLR: ("+olrClm@units+")"
olrSeaClm = dim_avg_Wrap( olrClm(lat|:,lon|:,month|i_season(ns,:)) )
sstSeaClm = dim_avg_Wrap( sstClm(lat|:,lon|:,month|i_season(ns,:)) )
plot(0) = gsn_csm_contour_map_overlay(wks,olrSeaClm,sstSeaClm,res1,res2)
res1@gsnLeftString = "NCEP: U: ("+uwndClm@units+")"
res1@cnLevelSpacingF = 2.0 ; set contour spacing
uwndSeaClm= dim_avg_Wrap(uwndClm(lat|:,lon|:,month|i_season(ns,:)) )
plot(1) = gsn_csm_contour_map_overlay(wks,uwndSeaClm,sstSeaClm,res1,res2)
res1@gsnLeftString = "GPCP PRC: ("+prcClm@units+")"
res1@cnLevelSelectionMode = "ExplicitLevels" ; set explicit contour levels
;res1@cnLevels = (/1,2,4,6,8,10,12,14/)
res1@cnLevels = ispan(1,14,1)
prcSeaClm = dim_avg_Wrap( prcClm(lat|:,lon|:,month|i_season(ns,:)) )
plot(2) = gsn_csm_contour_map_overlay(wks, prcSeaClm,sstSeaClm,res1,res2)
delete(res1@cnLevelSelectionMode)
delete(res1@cnLevels)
resP@txString = season_label(ns) +": "+ yrStrt+"-"+yrLast
gsn_panel(wks,plot,(/3,1/),resP) ; now draw as one plot
end do
end

      

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Thu Dec 17 06:59:58 2009

This archive was generated by hypermail 2.1.8 : Thu Dec 17 2009 - 17:15:52 MST