[ncl-talk] Fwd: how to fill in between two curves? Please help to sort this out

Ruksana Abedin ruksana.abedin at gmail.com
Fri Feb 12 09:32:48 MST 2016


Dear NCL,

in connection to my earlier query, I need to add information that the first
two curves have monthly mean precipitation values, which are meant to be
the max and min range simulated by the model. So, filling in with color in
between curve 1 and 2 will show the model range.

Making this filled xy curve as the plot0, I need to overlay all the other
lines over it.

Please help me to do this. I have gone through the examples given at NCL
website but can't figure out the required commands for my case.

Thanks a lot for your kind support,
Ruksana

---------- Forwarded message ----------
From: Ruksana Abedin <ruksana.abedin at gmail.com>
Date: Thu, Feb 11, 2016 at 5:36 PM
Subject: how to fill in between two curves? Please help to sort this out
To: NCL-talk <ncl-talk at ucar.edu>


Hi,

I need to fill in with color in between my first two curves (both grey
lines in figure) but not sure how to do this. I have tried  adding these
lines but error message says one mudt be 2D other 1D. Please help me to get
this done.

y = fldmeanx
y1 = fldmeany

;The area between b/w curves y and y1 will be filled in with grey

res at gsnXYFillColors = "grey"

plotxy = gsn_csm_y(wks,y,res)

below is the script and the figure




;*****************************************************
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"
load "$NCARG_ROOT/lib/ncarg/nclscripts/contrib/time_axis_labels.ncl"
;*****************************************************
begin
;*****************************************************
;read in data
;*****************************************************
fx = addfile("/...../wah2_sas_LRBdesh.1992.nc","r")
fy= addfile("/....../wah2_sas_LRBdesh.2003.nc","r")
f0=addfile ("/../wah2_sas_1985_2007.part.LRBdesh.ymonmean_1_11.nc",
"r");
f =
addfile("/.../APHRO_Asian_Monsoon_1963-2007/APHRO_LRBdesh_ppt_1985_2007_ymonmean_1_11.nc",
"r")
f1 = addfile(".../GPCC.precip.ymonmean_1_11.1985-2007.v6.360d.LRBdesh.nc
","r")
f2 = addfile("/.../UoD.precip.360d.ymonmean.1985_2007_LRBDesh.v301.nc","r")

;*****************************************************
; parameters
;*****************************************************
PPT_modx = fx->field90(:,0,:,:)
PPT_modx = PPT_modx*86400

PPT_mody = fy->field90(:,0,:,:)
PPT_mody = PPT_mody*86400

PPT_mod = f0->field90(:,0,:,:)
PPT_mod = PPT_mod*86400

PPT_obs = f->precip
PPT_obs1 = f1->precip/30
PPT_obs2 = f2->precip/3


fldmeanx = wgt_areaave_Wrap(PPT_modx,1.0,1.0,1)
fldmeany = wgt_areaave_Wrap(PPT_mody,1.0,1.0,1)
fldmean0 = wgt_areaave_Wrap(PPT_mod,1.0,1.0,1)
fldmean = wgt_areaave_Wrap(PPT_obs,1.0,1.0,1)
fldmean1 = wgt_areaave_Wrap(PPT_obs1,1.0,1.0,1)
fldmean2 = wgt_areaave_Wrap(PPT_obs2,1.0,1.0,1)

time = f0->time0
x = PPT_mod&time0
timax = dimsizes(time)-1

;--convert the time proleptic_gregorian calendar to UTC date
utc_date   = cd_calendar(time,0)

;-- set date variable names

year     = tointeger(utc_date(:,0))
month     = tointeger(utc_date(:,1))
day     = tointeger(utc_date(:,2))
hour      = tointeger(utc_date(:,3))
minute      = tointeger(utc_date(:,4))
second      = utc_date(:,5)

;-- write date as string (MM)
date_str_i = sprinti("%0.2i",month)

;-- create the time strings, plot every axis annotation
incr     = 1
labels      = (/date_str_i(0::incr)/)
labels   = (/"J","F","M","A","M","J","J","A","S","O","N"/)

;-- set resources
res = True
res at trXMinF           = time(0)             ; time minimum on axis
res at trXMaxF           = time(timax)         ; time maximum on axis
res at tmXBMode         = "Explicit"           ; explicit time setting
res at tmXBValues         = PPT_mod&time0(::incr)  ; axis tick position
res at tmXBLabels         = labels


colors = (/"grey","grey","blue","green","violet","orange"/)
lg_labels = (/"RCM","Range of","RCM","APHRODITE","GPCC","UoD"/)

printVarSummary(time)
printVarSummary(PPT_mod)
printVarSummary(PPT_obs)
printVarSummary(PPT_obs1)
printVarSummary(PPT_obs2)

wks = gsn_open_wks("eps","annpptcycle")

res =True
res at gsnDraw    = False
res at gsnFrame   = False
res at gsnPaperOrientation = "portrait"

res= True   ; plot mods desired
res =True
res at gsnMaximize= True
res at gsnDraw    = False
res at gsnFrame   = False
res at gsnPaperOrientation = "portrait"


res= True   ; plot mods desired
res at tiMainString = "Bangladesh with Larger Region"
res at tiYAxisString   = "Precipitation (mm/day)"
res at tiXAxisString   = "months"
res at xyLineThicknessF = (/6,6,8,6,6,6/)
res at trYMinF     = 0.0
res at trYMaxF     = 15.0

res at xyLineColor          = colors(0)
plot0 = gsn_csm_xy(wks,x,fldmeanx,res)

res at xyLineColor          = colors(1)
plot1 = gsn_csm_xy(wks,x,fldmeany,res)

res at xyLineColor          = colors(2)
plot2 = gsn_csm_xy(wks,x,fldmean0,res)

res at xyLineColor          = colors(3)
plot3 = gsn_csm_xy(wks,x,fldmean,res)

res at xyLineColor          = colors(4)
plot4 = gsn_csm_xy(wks,x,fldmean1,res)

res at xyLineColor          = colors(5)
plot5 = gsn_csm_xy(wks,x,fldmean2,res)


overlay(plot0,plot1)
overlay(plot0,plot2)
overlay(plot0,plot3)
overlay(plot0,plot4)
overlay(plot0,plot5)


; Attach a legend

lgres = True
lgres at lgLineColors              = colors
lgres at lgMonoItemType        = True
lgres at lgItemType        = "Lines"
lgres at lgMonoDashIndex        = True
lgres at lgDashIndex        = "SolidLine"
lgres at gsLineDashPattern         = 0.
lgres at lgLineThicknessF          = 5.
lgres at lgLabelFontHeightF     = 0.25
lgres at lgBoxMinorExtentF      = 0.25
lgres at vpWidthF            = 0.25
lgres at vpHeightF         = 0.25
lgres at pmLegendDisplayMode     = "Always"
lgres at pmLegendWidthF          = 0.9
lgres at pmLegendHeightF          = 0.1
lgres at xyExplicitLabels         = lg_labels
lgres at lgBoxMinorExtentF     = 0.8
lgres at lgPerimOn                 = False
legend = gsn_create_legend(wks, 6, lg_labels, lgres)

amres                 = True
amres at amJust             = "BottomRight"     ; Use bottom right corner of
box for determining its location.
amres at amOrthogonalPosF        = -0.12
amres at amParallelPosF         = -0.1

annoid  =  gsn_add_annotation(plot0, legend, amres)  ; add legend to plot

draw(plot0)

frame(wks)

end



[image: Inline image 1]
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20160212/44a9e08e/attachment-0001.html 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image.jpeg
Type: image/jpeg
Size: 515631 bytes
Desc: not available
Url : http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20160212/44a9e08e/attachment-0001.jpeg 


More information about the ncl-talk mailing list