[ncl-talk] Panel plots of hovmuellers
Melissa Lazenby
M.Lazenby at sussex.ac.uk
Wed Jul 4 07:37:33 MDT 2018
Dear NCL Users
I am not able to plot a panel plot of 36 CMIP5 models (lat vs time plots).
They plot individually however I think I am missing something when it comes to plotting it as a panel plot.
Any suggestions as to what could be wrong with the code would be very much appreciated.
Kindest Regards
Melissa
CODE BELOW
;*********************************************
; lat_time_bw.ncl
;*********************************************
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
model = (/"ACCESS1-0","ACCESS1-3","bcc-csm1-1","bcc-csm1-1-m","BNU-ESM","CanESM2","CCSM4","CESM1-BGC","CESM1-CAM5","CMCC-CMS","CNRM-CM5","CSIRO-Mk3-6-0","EC-EARTH","FGOALS-g2","FGOALS-s2","FIO-ESM","GFDL-CM3","GFDL-ESM2G","GFDL-ESM2M","GISS-E2-R_p1","GISS-E2-H-CC","GISS-E2-R-CC","HadGEM2-AO","HadGEM2-CC","HadGEM2-ES","inmcm4","IPSL-CM5A-LR","IPSL-CM5A-MR","MIROC5","MIROC-ESM","MIROC-ESM-CHEM","MPI-ESM-LR","MPI-ESM-MR","MRI-CGCM3","NorESM1-M","NorESM1-ME"/)
do gg = 0,dimsizes(model)-1
fili = "/mnt/geog/ml382/ml382_sals000408_home_dir/melsicz/dPhov/pr_Amon_"+model(gg)+"_dP_hov.nc"
fili2 = "/mnt/geog/ml382/ml382_sals000408_home_dir/melsicz/dPhov/pr_Amon_"+model(gg)+"_climhov_1971-2000.nc"
f = addfile (fili , "r") ; add file
lat = f->lat ; get lat
lon = f->lon ; get lon
time = f->time ; get time
;precip = f->pr ; get precip
;precip2 = precip(:,0,:,:)
f1 = addfile (fili2 , "r") ; add file
lat1 = f->lat ; get lat
lon1 = f->lon ; get lon
time1 = f->time ; get time
if ((gg.eq.13) .or. (gg.eq.17) .or. (gg.eq.18)) then
precip = f1->pr(:,:,:)
else
precip = f1->pr(:,0,:,:)
end if
if ((gg.eq.3) .or. (gg.eq.13) .or. (gg.eq.17) .or. (gg.eq.18) .or. (gg.eq.20) .or. (gg.eq.21)) then
precip2 = f->pr(:,:,:)
else
precip2 = f->pr(:,0,:,:)
end if
printVarSummary(precip2)
latS = -30.
latN = 30.
shov = precip2(:,{-30:30},{30:40})
shov1 = precip(:,{-30:30},{30:40})
dims = dimsizes(shov) ; shov=3D array=(12,40,37)
sdemo = dim_avg_Wrap(shov) ;sdemo(time,lat)
sdemo4 = dim_avg_Wrap(shov1) ;sdemo(time,lat)
sdemo1 = sdemo(lat|:,time|:)
sdemo1 = smth9 (sdemo1,0.5, 0.25, False) ; 2D smoother
sdemo2 = sdemo4(lat|:,time|:)
sdemo2 = smth9 (sdemo2,0.5, 0.25, False)
sdemo1 at units = "mm/day"
sdemo1 at long_name = "dP Hov "+model(gg)+" (lon 30E-40E)"
gtPat = 17 ; stiple
ltPat = 3
sdemo2 at units = ""
sdemo2 at long_name = ""
; hatch
;*************************
; plotting parameters
;*************************
wks = gsn_open_wks ("X11", "dPhov_ALL_models_lon30-40" ) ; open workstation
gsn_define_colormap(wks,"BlueDarkRed18") ; choose color map
gsn_reverse_colormap(wks)
plot = new (36,"graphic")
plot1= new (36,"graphic")
res = True ; plot mods desired
res at cnFillOn = True ; color on
res at gsnDraw = True ; don't draw yet
res at gsnAddCyclic = False
res at lbLabelStride = 2 ; every other label
res at lbOrientation = "Horizontal" ; vertical label bar
res at pmLabelBarOrthogonalPosF = -0.04 ; move label bar closer to axis
res at cnLinesOn = False ; turn off contour lines
res at gsnSpreadColors = True ; use full range of color map
res at gsnFrame = True ; don't advance frame yet
res at vpXF = 0.12 ; default is 0.2 change aspect
res at vpYF = 0.8 ; default is 0.8 ration
res at vpHeightF = 0.4 ; default is 0.6
res at vpWidthF = 0.8 ; default is 0.6
res at cnLevelSelectionMode = "ManualLevels" ; manual levels
res at cnMinLevelValF = -1.5 ; min level
res at cnMaxLevelValF = 1.5 ; max level
res at cnLevelSpacingF = 0.25 ; contour spacing
res at tmXBMode = "Explicit" ; Define own tick mark labels.
res at tmXBValues = (/ 0., 1., 2., 3., 4., 5., 6., 7., 8., 9., 10., 11. /)
res at tmXBLabels = (/"D","J","F","M" ,"A","M", "J", "J", "A", "S", "O", "N" /)
wpres = True ; plot mods desired
wpres at cnFillOn = False ; color on
wpres at gsnDraw = True ; don't draw yet
wpres at gsnFrame = True
wpres at gsnAddCyclic = False
wpres at lbLabelStride = 2 ; every other label
wpres at cnLinesOn = True
wpres at cnLineLabelsOn = True
wpres at cnLineThicknessF = 1.5
wpres at cnInfoLabelOn = False
wpres at cnLevelSelectionMode = "ManualLevels" ; manual levels
wpres at cnMinLevelValF = 0 ; min level
wpres at cnMaxLevelValF = 10 ; max level
wpres at cnLevelSpacingF = 1 ; contour spacing
plot(gg) = gsn_csm_lat_time(wks, sdemo1({-30:30},:),res )
plot1(gg) = gsn_csm_lat_time(wks, sdemo2({-30:30},:),wpres )
overlay(plot(gg),plot1(gg))
delete(sdemo1)
delete(sdemo2)
end do
panres = True ; mod panel plot
panres at gsnPanelLabelBar = True ; add common colorbar
panres at lbLabelFontHeightF =.012 ; make labels larger
panres at gsnMaximize = True ; Maximize plot in frame.
gsn_panel(wks,plot(:15),(/4,4/),panres) ; panel 16 models at a time.
gsn_panel(wks,plot(16:),(/4,4/),panres)
gsn_panel(wks,plot(32:),(/4,4/),panres)
end
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20180704/1c7844dd/attachment.html>
More information about the ncl-talk
mailing list