[ncl-talk] Significance plot in overlay not showing up
Ipshita Majhi
ipmajhi at alaska.edu
Tue Nov 22 18:38:13 MST 2016
Dear NCl,
I am trying to overlay two plots. But the significance plot does not show
up, and there are no errors as such. I would be grateful if you could guide
me on this.
;*******************************************
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"
;*******************************************
;*************************************************
;Reading in Storm track data by Peter Beinek 2016
;*************************************************
a=addfile("~/Documents/NCL_files/Storm_tracks/cyclcnt_monthly_80-14.nc
","r")
vNames = getfilevarnames(a) ; get variable names of all groups on file
;print (vNames) ; print all variable names on file
dens=a->dens
time=a->time
lat=a->lat
lon=a->lon
;**************************************************
;Doing composite analysis for the years
;with high and low monsoon
;High rainfall years: 1990,1994,1999,2000,2001,2008,2013
;Low rainfall years: 1987,1991,2009,2012
;***************************************************
;***************************************************
;Now extracting the years with high rainfall
;***************************************************
;********************
;Extracting for 1990
;********************
st1990=dens({119:130},:,:)
;*******************
;Extracting for 1994
;*******************
st1994=dens({167:178},:,:)
;********************
;1999
;*******************
st1999=dens({227:238},:,:)
;********************
;2000
;*********************
st2000=dens({239:250},:,:)
;*********************
;2001
;********************
st2001=dens({251:262},:,:)
;********************
;2008
;********************
st2008=dens({335:346},:,:)
;********************
;2013
;*********************
st2013=dens({395:406},:,:)
;*********************
;*****************************************
;This averaging all the high years
;*****************************************
st_highyrs= [/st1990,st1994,st1999,st2000,st2001,st2008,st2013/]
ListSetType(st_highyrs, "join")
jab = st_highyrs[:]
; print(dimsizes(jab))
zAvg = dim_avg_n_Wrap(jab,0) ; ==> zAvg(12,nlat,nlon)
; print(dimsizes(zAvg))
zAvg!1="lat" ; name dimensions
zAvg!2="lon"
zAvg&lat = dens&lat ; assign coordinate values and
zAvg&lon =dens&lon ; units attributes
copy_VarAtts(dens,zAvg)
copy_VarCoords_1(dens,zAvg)
zAvg&lat at units = "degrees_north"
zAvg&lon at units = "degrees_east"
;*********************************************
;Now reading in the years with low rainfall data
;For storm track 1987,1991,2009,2012
;**********************************************
;********************
;1987
;*********************
st1987=dens({83:94},:,:)
;*********************
;********************
;1991
;*********************
st1991=dens({131:142},:,:)
;*********************
;********************
;2009
;*********************
st2009=dens({335:346},:,:)
;*********************
;*********************
;2012
;*********************
st2012=dens({383:394},:,:)
;*********************
;*****************************************
;This averaging all the low years
;*****************************************
st_lowyrs= [/st1987,st1991,st2009,st2012/]
ListSetType(st_lowyrs, "join")
jab1 = st_lowyrs[:]
;print(dimsizes(jab1))
;******************************************
;This is to calculate the std
;******************************************
zStd1=dim_stddev_n_Wrap( jab1, 0 )
zAvg1 = dim_avg_n(jab1,0) ; ==> zAvg(12,nlat,nlon)
zAvg1!1="lat" ; name dimensions
zAvg1!2="lon"
zAvg1&lat = dens&lat ; assign coordinate values and
zAvg1&lon =dens&lon ; units attributes
copy_VarAtts(dens,zAvg1)
copy_VarCoords_1(dens,zAvg1)
zAvg1&lat at units = "degrees_north"
zAvg1&lon at units = "degrees_east"
;******************************************
;Difference between high and low years
;******************************************
zDiff=zAvg-zAvg1
zDiff!1="lat" ; name dimensions
zDiff!2="lon"
zDiff&lat = dens&lat ; assign coordinate values and
zDiff&lon =dens&lon ; units attributes
copy_VarAtts(dens,zDiff)
copy_VarCoords_1(dens,zDiff)
zDiff&lat at units = "degrees_north"
zDiff&lon at units = "degrees_east"
zDiff= smth9(zDiff, 0.5, 0.25, True)
;*****************************************
;Calculating significance test
siglvl = 0.05
aveX =dim_avg_n_Wrap(jab,0)
aveY = dim_avg_n_Wrap(jab1,0)
varX = dim_variance_n_Wrap( jab, 0 )
varY = dim_variance_n_Wrap( jab1, 0 )
sX = 7
sY = 4
alpha = 100.*(1. - ttest(aveX,varX,sX, aveY,varY,sY, True, False))
printMinMax(alpha,False)
; sig_ alpha = mask( alpha, alpha.eq.100,False)
;sig_ alpha = mask( alpha, alpha.le.90,False)
alpha!0="lat" ; name dimensions
alpha!1="lon"
alpha&lat = dens&lat ; assign coordinate values and
alpha&lon =dens&lon ; units attributes
copy_VarAtts(dens,alpha)
copy_VarCoords_1(dens,alpha)
alpha&lat at units = "degrees_north"
alpha&lon at units = "degrees_east"
;**************************************************
; Now plotting the storm track
;**************************************************
;*************************************************
plot = new(2,graphic)
;************************************************
; create plot
;************************************************
wks = gsn_open_wks("X11","Composite_high_low_storm_tracks_sig_dec_april")
;
gsn_define_colormap(wks, "BlueWhiteOrangeRed")
;************************************************
;Composite
;************************************************
res = True
res at gsnDraw = False ; don't draw
res at gsnFrame = False ; don't advance frame
res at cnFillOn = True ; turn on color
res at cnLinesOn = False ; turn off contour lines
res at cnLevelSpacingF = 0.1 ; contour interval
res at cnLevelSelectionMode = "ManualLevels";
res at cnMinLevelValF = -0.5 ; min level
res at cnMaxLevelValF =0.5
res at mpMinLatF = 30 ; choose a subregion
res at mpMaxLatF = 90.
res at mpMinLonF = 0 ; choose a subregion
res at mpMaxLonF = 180.
res at lbLabelBarOn = False ; turn off individual cb's
;*****************************************************
;Significance
;*****************************************************
res1 = True
res1 at gsnDraw = False ; Do not draw plot
res1 at gsnFrame = False ; Do not advance frome
res1 at cnFillOn = True
res1 at cnMonoFillColor = True
res1 at cnMonoFillPattern = False
res1 at lbLabelBarOn = False ; turn off
label bar
res1 at cnLevelSelectionMode = "ManualLevels" ; manually specify contour
levels
res1 at cnMinLevelValF = 95 ; min level
res1 at cnMaxLevelValF = 100 ; max level
res1 at cnLevelSpacingF = 1 ; contour interval
res1 at gsnSpreadColors = False
res1 at cnInfoLabelOn = False ; turn off info label
res at cnLineLabelsOn = False
res1 at cnFillPatterns = (/17,17,17,17,17,17,17,17,17,17/)
scale = 1.0
dotsize = 0.003
res1 at cnFillScaleF = scale
res1 at cnFillDotSizeF = dotsize
;****************************************************
plotA= gsn_csm_contour_map(wks,zDiff(3,:,:), res) ;
plotB = gsn_csm_contour(wks,alpha(3,:,:),res1) ; create plot
overlay(plotA,plotB) ; result will be plotA
plot(0) = plotA
plotC = gsn_csm_contour_map(wks,zDiff(11,:,:), res) ;
plotD = gsn_csm_contour(wks,alpha(11,:,:),res1) ; create plot
overlay (plotC, plotD)
plot(1) = plotC
resP = True ; modify the panel plot
resP at gsnFrame = False ; don't advance panel plot
resP at gsnPanelFigureStrings= (/ "April" ,"December"/) ;
resP at gsnPanelFigureStringsFontHeightF=0.01
resP at amJust = "TopLeft"
resP at gsnPanelFigureStringsBackgroundFillColor = (/-1/)
resP at txString = "Storm tracks difference between high and low MJ
years"
resP at gsnPanelLabelBar = True ; add common colorbar
resP at lbLabelFontHeightF = 0.01 ; make labels smaller
resP at lbOrientation = "vertical" ; vertical label bar
;
gsn_panel(wks,plot,(/2,1/),resP)
frame(wks)
;===========================================
--
Ipshita Majhi
PhD Candidate
University of Alaska , Fairbanks
Atmospheric Science Department
(907)978-4220 ipmajhi at alaska.edu
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20161122/9999823c/attachment.html
More information about the ncl-talk
mailing list