<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);" class="elementToProof">
Hi All NCL Users</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);" class="elementToProof">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);" class="elementToProof">
I am struggling with a conditional statement that I would like to perform. </div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);" class="elementToProof">
Essentially, I am trying to make some bars pink instead of red to show a difference in uncertainty. </div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);" class="elementToProof">
I have the following code below to perform this but I think there is an error with how I am looping the array. </div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);" class="elementToProof">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);" class="elementToProof ContentPasted0">
do hh = 0,33
<div class="ContentPasted0"> stdarr(hh,0) = (/ (yIndex(hh::34)) /)</div>
<div class="ContentPasted0"> </div>
<div class="ContentPasted0"> if ((hh.eq.1) .or. (hh.eq.2) .or. (hh.eq.3)) then</div>
<div class="ContentPasted0">sres@gsnXYBarChartColors = (/"pink"/) </div>
<div class="ContentPasted0">else </div>
<div class="ContentPasted0">sres@gsnXYBarChartColors = (/"red"/) </div>
<div class="ContentPasted0">end if</div>
<div class="ContentPasted0"> plot1 = gsn_csm_xy(wks,fspan(1855.6,1888.7,34),stdarr(hh,0),sres) ; draw each time series</div>
<div><br class="ContentPasted0">
</div>
<div class="ContentPasted0"> end do</div>
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);" class="elementToProof">
This error occurs: </div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);" class="elementToProof ContentPasted2">
(0) gsn_csm_xy: Fatal: X and Y must have the same dimensions sizes, or one must be one-dimensional and both have the same rightmost dimension.<br class="ContentPasted2">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);" class="elementToProof">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);" class="elementToProof">
Any help on this would be much appreciated!</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);" class="elementToProof">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);" class="elementToProof">
Many thanks!</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);" class="elementToProof">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);" class="elementToProof">
Kindest Regards</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);" class="elementToProof">
Melissa</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);" class="elementToProof">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);" class="elementToProof">
Full Code:</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);" class="elementToProof">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);" class="elementToProof ContentPasted1">
;*******************************************************
<div class="ContentPasted1">; Mpwapwa.ncl</div>
<div class="ContentPasted1">;</div>
<div class="ContentPasted1">; Concepts illustrated:</div>
<div class="ContentPasted1">; - Drawing multiple bar charts on a page</div>
<div class="ContentPasted1">; - Drawing three custom legends outside a bar chart</div>
<div class="ContentPasted1">; - Using bar charts to draw standard deviations for four time series</div>
<div class="ContentPasted1">; - Drawing a time series plot</div>
<div class="ContentPasted1">;*******************************************************</div>
<div class="ContentPasted1">;</div>
<div class="ContentPasted1">; These files are loaded by default in NCL V6.2.0 and newer</div>
<div class="ContentPasted1"> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"</div>
<div class="ContentPasted1"> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"</div>
<div><br class="ContentPasted1">
</div>
<div class="ContentPasted1">begin</div>
<div class="ContentPasted1"> </div>
<div><br class="ContentPasted1">
</div>
<div class="ContentPasted1">x = (/1856, 1857, 1858, 1859, 1860, 1861, 1862, 1863, 1864, 1865, 1866, 1867, 1868, 1869, 1870, 1871, 1872, 1873, 1874, 1875, 1876, 1877, 1878, 1879, 1880, 1881, 1882, 1883, 1884, 1885, 1886, 1887, 1888, 1889/)</div>
<div><br class="ContentPasted1">
</div>
<div class="ContentPasted1">yIndex = (/0,2,-1,-3,2,0,0,0,0,0,0,0,0,0,0,0.05,2,0,-1,-1,-2,1,1,-2,-2,1,-1,-3,0.05,0.05,0.05,-3,0.05,0/)</div>
<div><br class="ContentPasted1">
</div>
<div><br class="ContentPasted1">
</div>
<div class="ContentPasted1">y20CR3 = (/-1.7049024, -1.9956352, 0.1017878, 1.5787968, 0.2902762, 0.1615032, 0.7573914, 0.127654184, 0.3391526, 0.18975348, 1.4533978, 0.28738338, 0.8228474, -1.2142216, 0.67589808, 1.3983746, 1.1087944, 0.58095216, -1.3422622, 0.226781852, 2.173188, 0.6511904, 0.9723054, -0.4989326, -1.5402072, -0.1535788, -0.226605, -1.6808838, -0.19809544, -0.1772666, 0.0769234, -0.6346154, -1.2222682, -0.0073483/)</div>
<div><br class="ContentPasted1">
</div>
<div class="ContentPasted1">;scaled by 5 and deleted first value to go for year 2.
</div>
<div class="ContentPasted1">yCMIP5 = (/-0.9094243, 0.5458735, -0.8682191, -1.826278, -0.6501346, 0.1305088, 0.51643, 0.6247665, -0.4082086, 0.3641764, 1.476322, 0.842743, -0.5013026, -0.1281874, 0.4829363, -0.7015711, 0.269588, -0.2834916, -0.8827865, -0.4242322,
-1.171241, -0.8289737, -0.4638377, 0.8812776, 0.5154026, -1.191759 ,0.8223722, -1.198702, -0.8878552, -1.724694, -1.62958, 1.02131, -1.440305, -2.299565/)</div>
<div><br class="ContentPasted1">
</div>
<div><br class="ContentPasted1">
</div>
<div class="ContentPasted1"> stdarr = new((/34,3/),"float")</div>
<div class="ContentPasted1"> do hh = 0,33</div>
<div class="ContentPasted1"> stdarr(hh,0) = (/ (yIndex(hh::34)) /)</div>
<div class="ContentPasted1"> stdarr(hh,1) = (/ (y20CR3(hh::34)) /)</div>
<div class="ContentPasted1"> stdarr(hh,2) = (/ (yCMIP5(hh::34)) /)</div>
<div class="ContentPasted1"> end do</div>
<div class="ContentPasted1"> print("Index Data = "+dimsizes(yIndex)+", 20CR3 = "+dimsizes(y20CR3)+", CMIP5 = "+dimsizes(yCMIP5))</div>
<div><br class="ContentPasted1">
</div>
<div class="ContentPasted1">printVarSummary(stdarr)</div>
<div><br class="ContentPasted1">
</div>
<div class="ContentPasted1">;====================================================================================== </div>
<div class="ContentPasted1"> wks = gsn_open_wks("X11","Mpwapwa_3_Plot") ; send graphics to PNG file</div>
<div><br class="ContentPasted1">
</div>
<div><br class="ContentPasted1">
</div>
<div class="ContentPasted1">sres = True</div>
<div><br class="ContentPasted1">
</div>
<div class="ContentPasted1"> sres@trXMinF = 1855</div>
<div class="ContentPasted1"> sres@trXMaxF = 1890</div>
<div class="ContentPasted1">sres@tmXBValues = ispan(1855,1890,5) ; create major tickmarks with labels every 5 years</div>
<div class="ContentPasted1">sres@tmXBLabels = sres@tmXBValues</div>
<div class="ContentPasted1">sres@tmXBMinorValues = ispan(1855,1890,1) ; as tmXBMode = "Explicit", this resource needs to be set to get minor tickmarks. Create minor tickmarks every year.</div>
<div><br class="ContentPasted1">
</div>
<div class="ContentPasted1"> sres@vpWidthF = 0.8</div>
<div class="ContentPasted1"> sres@vpHeightF = 0.5</div>
<div class="ContentPasted1"> sres@vpXF = .15</div>
<div class="ContentPasted1"> sres@trYMinF = -3.5</div>
<div class="ContentPasted1"> sres@trYMaxF = 3.5</div>
<div class="ContentPasted1"> sres@gsnDraw = True</div>
<div class="ContentPasted1"> ;sres@gsnFrame = False</div>
<div class="ContentPasted1"> sres@gsnXYBarChart = True</div>
<div class="ContentPasted1"> sres@gsnXYBarChartBarWidth = 0.20 ; change bar widths</div>
<div class="ContentPasted1"> sres@tmXBMode = "Explicit" ; explicit labels</div>
<div class="ContentPasted1"> sres@tmXBLabelFontHeightF = 0.0205</div>
<div class="ContentPasted1"> sres@tmXTLabelFontHeightF = 0.0205</div>
<div class="ContentPasted1"> sres@tmYLLabelFontHeightF = 0.0225</div>
<div class="ContentPasted1"> sres@tiMainFontHeightF = 0.025</div>
<div class="ContentPasted1"> sres@tiMainFont = "helvetica"</div>
<div class="ContentPasted1"> sres@tiMainString = "Precipitation Anomalies for Mpwapwa"</div>
<div class="ContentPasted1"> sres@gsnRightString = ""</div>
<div class="ContentPasted1"> sres@tiYAxisString = "Pr Anomalies (mm/day) DJFMA"</div>
<div class="ContentPasted1"> sres@gsnYRefLine = 0. ; reference line </div>
<div class="ContentPasted1"> </div>
<div class="ContentPasted1"> do hh = 0,33</div>
<div class="ContentPasted1"> stdarr(hh,0) = (/ (yIndex(hh::34)) /)</div>
<div class="ContentPasted1"> </div>
<div class="ContentPasted1"> if ((hh.eq.1) .or. (hh.eq.2) .or. (hh.eq.3)) then</div>
<div class="ContentPasted1">sres@gsnXYBarChartColors = (/"pink"/) </div>
<div class="ContentPasted1">else </div>
<div class="ContentPasted1">sres@gsnXYBarChartColors = (/"red"/) </div>
<div class="ContentPasted1">end if</div>
<div class="ContentPasted1"> plot1 = gsn_csm_xy(wks,fspan(1855.6,1888.7,34),stdarr(hh,0),sres) ; draw each time series</div>
<div><br class="ContentPasted1">
</div>
<div class="ContentPasted1"> end do</div>
<div><br class="ContentPasted1">
</div>
<div><br class="ContentPasted1">
</div>
<div class="ContentPasted1"> sres@gsnXYBarChartColors = (/"black"/) ; seperately, not</div>
<div class="ContentPasted1"> plot2 = gsn_csm_xy(wks,fspan(1855.8,1888.9,34),stdarr(:,1),sres) ; advancing the frame</div>
<div class="ContentPasted1"> sres@gsnXYBarChartColors = (/"blue"/) ; drawn on the X-axis</div>
<div class="ContentPasted1"> plot3 = gsn_csm_xy(wks,fspan(1856.4,1889.2,34),stdarr(:,2),sres)
</div>
<div><br class="ContentPasted1">
</div>
<div class="ContentPasted1"> lbres = True ; labelbar only resources</div>
<div class="ContentPasted1"> lbres@vpWidthF = 0.2 ; labelbar width</div>
<div class="ContentPasted1"> lbres@vpHeightF = 0.1 ; labelbar height</div>
<div class="ContentPasted1"> lbres@lbBoxMajorExtentF = 0.56 ; puts space between color boxes</div>
<div class="ContentPasted1"> lbres@lbMonoFillPattern = True ; Solid fill pattern</div>
<div class="ContentPasted1"> lbres@lbLabelFontHeightF = 0.025 ; font height. default is small</div>
<div class="ContentPasted1"> lbres@lbLabelJust = "CenterLeft" ; left justify labels</div>
<div class="ContentPasted1"> lbres@lbPerimOn = False</div>
<div class="ContentPasted1"> lbres@lgPerimColor = "white"</div>
<div class="ContentPasted1"> colors = (/"red", "black", "blue"/)</div>
<div class="ContentPasted1"> labels = (/"Index", "Reanalysis", "CMIP5"/)</div>
<div class="ContentPasted1"> xpos = (/0.15, 0.40, 0.7/)</div>
<div><br class="ContentPasted1">
</div>
<div class="ContentPasted1"> do i=0,2</div>
<div class="ContentPasted1"> lbres@lbFillColors = colors(i)</div>
<div class="ContentPasted1"> gsn_labelbar_ndc(wks,1,labels(i),xpos(i),0.20,lbres)</div>
<div class="ContentPasted1"> end do</div>
<div class="ContentPasted1"> </div>
<div class="ContentPasted1"> frame(wks) </div>
<div class="ContentPasted1">end</div>
<br>
</div>
<div class="elementToProof">
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div id="Signature">
<div>
<div style="font-family:Tahoma; font-size:13px"></div>
<div style="font-family:Tahoma; font-size:13px">
<div style="font-family:Tahoma; font-size:13px">Dr. Melissa Lazenby
<div>Lecturer in Climate Change</div>
<div>Department of Geography</div>
<div>Chichester 1 C150</div>
<div>University of Sussex</div>
<div><br>
</div>
<div><i style="color: inherit; font-family: inherit; font-size: inherit; font-variant-ligatures: inherit; font-variant-caps: inherit; font-weight: inherit;">"Education is the most powerful weapon which you can use to change the world" Nelson Mandela</i><br>
</div>
<div><i style="color: inherit; font-family: inherit; font-size: inherit; font-variant-ligatures: inherit; font-variant-caps: inherit; font-weight: inherit;"><br>
</i></div>
<div><i style="color: inherit; font-family: inherit; font-size: inherit; font-variant-ligatures: inherit; font-variant-caps: inherit; font-weight: inherit;"><img style="max-width:100%" data-outlook-trace="F:1|T:1" src="cid:a164c079-9320-46e5-877d-0852711e5ddb"><br>
</i></div>
</div>
</div>
</div>
</div>
</div>
</body>
</html>