<div dir="ltr"><div class="gmail_default" style="font-family:verdana,sans-serif;font-size:small">Thanks so much Dennis. It works perfectly now. Your advice is also well taken.<br><br></div><div class="gmail_default" style="font-family:verdana,sans-serif;font-size:small">Regards,<br></div><div class="gmail_default" style="font-family:verdana,sans-serif;font-size:small">Kwesi<br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Jan 4, 2017 at 5:23 PM, Dennis Shea <span dir="ltr"><<a href="mailto:shea@ucar.edu" target="_blank">shea@ucar.edu</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">[a] You are constantly over writing the variable 'prClm'<br><br>[b] you constantly repeat code such as:<span class=""><br> months = (/"January", "February", "March", "April" \<br> ,"May", "June", "July", "Auguat" \<br> ,"September", "October", "November" \<br> ,"December" /) <br></span> Why are you doing this redundant code?<br><br>[c] <br><br>---<br>[1] <br>Rather than:<span class=""><br><br> fili = "CCCma91-05.nc3"<br> f = addfile (diri+fili , "r") <br><br> pr = f->pr*86400 ; (time,lat,lon)<br> time = f->time<br> lat = f->lat<br> lon = f->lon<br><br> ntim = dimsizes(time)<br> pr!0 = "time"<br> pr!1 = "lat"<br> pr!2 = "lon"<br> pr&time = time<br> pr&lat = lat<br> pr&lon = lon<br><br></span>Use<br>; NCL imports all the meta data. <br><span class=""> fili = "CCCma91-05.nc3"<br> f = addfile (diri+fili , "r") <br></span> pr = f->pr ; (time,lat,lon)<br> printVarSummary(pr)<br> printMinMax(pr,0)<br><br> pr = pr*86400 ; change units after importing the varible<br> pr@unit= "mm/day"<br> printVarSummary(pr)<br> printMinMax(pr,0)<br><br> prClm_0 = clmMonTLL( pr) <br> printVarSummary(prClm_0)<br> printMinMax(prClm_0,0)<br><br>Do the same for the other files except name them: pr_clm_1 and prClm_2<br><br><br>[2] Looking at your printVarSummary, it is clear that that the data are on a rectilinear grid. <br>The 'lat' and 'lon' are coordinate variables.<br><br>Coordinates:<br> month: [0..11]<br> lat: [-46.25..42.75] <==== rectilinear<br> lon: [-25.25..60.75] <==== "<br><br>Hence, you do *NOT* need. Delete these lines<span class=""><br><br> res@sfXArray = lon ; Only necessary if x doesn't<br> res@sfYArray = lat ; contain 1D coordinate arrays<br><br></span>[3]<br>nmo = 0 ; January<br>plot(0) = gsn_csm_contour_map_ce(wks,<wbr>prClm_0(nmo,:,:), res) ; create plot<br>plot(1) = gsn_csm_contour_map_ce(wks,<wbr>prClm_1(nmo,:,:), res) ; create plot<br>plot(2) = gsn_csm_contour_map_ce(wks,<wbr>prClm_2(nmo,:,:), res) ; create plot<br><br>[4]<br>Change:<br>gsn_panel(wks,plot,(/3,1/),<wbr>resP)<br>To:<br>gsn_panel(wks,(/prClm_0,prClm_<wbr>1,prClm_2/),(/3,1/),resP)<br>or<br>gsn_panel(wks,(/prClm_0,prClm_<wbr>1,prClm_2/),(/1,3/),resP)<br><br>[5]<br>In the future please do not send scripts which contain many code lines which are commented out. Please send 'clean' scripts only.<br><br>Good Luck<br><br></div><div class="gmail_extra"><br><div class="gmail_quote"><div><div class="h5">On Tue, Jan 3, 2017 at 9:11 AM, Kwesi Quagraine <span dir="ltr"><<a href="mailto:starskykwesi@gmail.com" target="_blank">starskykwesi@gmail.com</a>></span> wrote:<br></div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="h5"><div dir="ltr"><div class="gmail_default" style="font-family:trebuchet ms,sans-serif;font-size:large">Hello NCl Users, I am new to ncl and I have a problem. I am trying to make a plot similar to the one attached with a common color bar and the file contains precipitation data from 1991-2005. Here's what I have done so far. <br><br>load "$NCARG_ROOT/lib/ncarg/nclscri<wbr>pts/csm/gsn_code.ncl" <br>load "$NCARG_ROOT/lib/ncarg/nclscri<wbr>pts/csm/gsn_csm.ncl" <br>load "$NCARG_ROOT/lib/ncarg/nclscri<wbr>pts/csm/contributed.ncl" <br>load "$NCARG_ROOT/lib/ncarg/nclscri<wbr>pts/csm/shea_util.ncl" <br><br>wksType = "pdf"<br> wksName = "climo123" <wbr> ; ": "+yrStrt+"_"+yrLast<br> <br> diri = "/media/kwesi/Maxtor/paper/" <wbr> ; input directory <br><br><br>;*****************************<wbr>******************************<br>; Read first file; Create climatology for desired period<br>;*****************************<wbr>******************************<br><br> fili = "CCCma91-05.nc3"<br> f = addfile (diri+fili , "r") <br><br> pr = f->pr*86400 ; (time,lat,lon)<br> time = f->time<br> lat = f->lat<br> lon = f->lon <br><br> ntim = dimsizes(time)<br> pr!0 = "time"<br> pr!1 = "lat"<br> pr!2 = "lon"<br> pr&time = time<br> pr&lat = lat<br> pr&lon = lon<br> <br> months = (/"January", "February", "March", "April" \<br> ,"May", "June", "July", "Auguat" \<br> ,"September", "October", "November" \<br> ,"December" /) <br> prClm = clmMonTLL( pr) ; Climatology<br> <wbr> <br> delete(time)<br> delete(pr)<br><br> printVarSummary( prClm )<br> printMinMax( prClm, True )<br><br>;*****************************<wbr>******************************<br>; Read second file ; Create climatology for desired period<br>; <br>;*****************************<wbr>******************************<br><br> fili = "Cnrm91-05.nc3"<br> f = addfile (diri+fili , "r") <br> pr = f->pr*86400 ; (time,lat,lon)<br> time = f->time<br> lat = f->lat<br> lon = f->lon <br><br> ntim = dimsizes(time)<br> pr!0 = "time"<br> pr!1 = "lat"<br> pr!2 = "lon"<br> pr&time = time<br> pr&lat = lat<br> pr&lon = lon <br> months = (/"January", "February", "March", "April" \<br> ,"May", "June", "July", "Auguat" \<br> ,"September", "October", "November" \<br> ,"December" /) <br><br> prClm = clmMonTLL( pr) ; Climatology<br> <wbr> <br> delete(time)<br> delete(pr)<br><br> printVarSummary( prClm )<br> printMinMax( prClm, True )<br><br>;*****************************<wbr>******************************<br>; Read third file; Create climatology for desired period<br>;*****************************<wbr>******************************<br><br> fili = "Ichec91-05.nc3"<br> f = addfile (diri+fili , "r") <br><br> pr = f->pr*86400 ; (time,lat,lon)<br> time = f->time<br> lat = f->lat<br> lon = f->lon <br><br> ntim = dimsizes(time)<br> pr!0 = "time"<br> pr!1 = "lat"<br> pr!2 = "lon"<br> pr&time = time<br> pr&lat = lat<br> pr&lon = lon <br><br> months = (/"January", "February", "March", "April" \<br> ,"May", "June", "July", "Auguat" \<br> ,"September", "October", "November" \<br> ,"December" /)<br> prClm = clmMonTLL( pr) ; Climatology<br> <wbr> <br> ;delete(time)<br> delete(pr)<br><br> printVarSummary( prClm )<br> printMinMax( prClm, True )<br><br>;*****************************<wbr>********************<br>; create colors<br>;*****************************<wbr>********************<br> <br><br> colors = (/"white","black" \ ; back/fore ground<br> ,"azure1","beige","lavender" \<br> ,"PaleGreen","SeaGreen3","Ligh<wbr>tYellow" \<br> ,"Yellow","HotPink","Red"/) <wbr> ; choose colors for color map<br> wks = gsn_open_wks(wksType, wksName)<br> gsn_define_colormap(wks, colors) ; generate new color map<br><br>;*****************************<wbr>*******************<br>; create panel plots<br>;*****************************<wbr>********************<br> plot = new (3 , graphic) ; create graphical array<br><br> res = True ; plot options desired<br><br> res@cnFillOn = True ; turn on color fill<br> res@cnInfoLabelOn = False ; turn off contour info label<br> res@cnLinesOn = False ; turn off contour lines<br> res@cnLineLabelsOn = False ; turn off line labels<br> res@cnLevelSelectionMode = "ExplicitLevels" ; set explicit contour levels<br> res@cnLevels = (/ 2.0, 2.5 \ ; set unequal contour levels<br> , 3.0, 3.5, 4.0, 4.5, 5.0 \<br> ,5.5, 6.0, 6.5, 7.0, 7.5,10.0 /)<br><br> <br><br> res@mpFillOn = False ; turn off gray continents<br> ;res@mpCenterLonF = 180 ; Centers the plot at 180 <br> <br> res@lbLabelBarOn = False ; No single label bar<br><br> res@gsnDraw = False<br> res@gsnFrame = False<br><br> resP = True ; panel options<br> resP@txString = "GPCC Precipitation: Climatology" ; common title<br> resP@gsnMaximize = True ; maximize image<br> resP@gsnPanelLabelBar = True ; Add common label bar <br><br>;---Set to False if plotting regional data or setting sfXArray/sfYArray<br> res@gsnAddCyclic =False<br><br> res@sfXArray = lon ; Only necessary if x doesn't <br> res@sfYArray = lat ; contain 1D coordinate arrays<br>;<br>; Zoom in on map if desired. There are other ways to zoom in on<br>; map if you have a different projection, like lambert conformal.<br>;<br> res@mpMinLatF = -60<br> res@mpMaxLatF = 0<br> res@mpMinLonF = -20<br> res@mpMaxLonF = 60<br> ;res@mpCenterLonF = (res@mpMinLonF + res@mpMaxLonF) / 2.<br><br> ;i = -1 <wbr> ; Climatologies<br> ;do nmo=0,180 <wbr> ; loop over the months<br> ;i = i+1<br> ;res@gsnCenterString = months(nmo)+":"+time(0)/100 +"-"+ time(ntim-1)/100<br> ;plot(i) = gsn_csm_contour_map_ce(wks,prC<wbr>lm(nmo,:,:), res) ; create plot<br> ;end do<br>plot = gsn_csm_contour_map_ce(wks,prC<wbr>lm(0,:,:), res) ; create plot<br> gsn_panel(wks,plot,(/3,1/),res<wbr>P)<br><br></div><div class="gmail_default" style="font-family:trebuchet ms,sans-serif;font-size:large">-------After running the script I get<br clear="all"></div>Variable: prClm<br>Type: float<br>Total Size: 1486416 bytes<br> 371604 values<br>Number of Dimensions: 3<br>Dimensions and sizes: [month | 12] x [lat | 179] x [lon | 173]<br>Coordinates: <br> month: [0..11]<br> lat: [-46.25..42.75]<br> lon: [-25.25..60.75]<br>Number Of Attributes: 3<br> _FillValue : 1e+20<br> time_op_ncl : Climatology: 15 years<br> info : function clmMonLLT: contributed.ncl<br>(0) <br>(0) min=0 max=63.1759<br><br>Variable: prClm<br>Type: float<br>Total Size: 1486416 bytes<br> 371604 values<br>Number of Dimensions: 3<br>Dimensions and sizes: [month | 12] x [lat | 179] x [lon | 173]<br>Coordinates: <br> month: [0..11]<br> lat: [-46.25..42.75]<br> lon: [-25.25..60.75]<br>Number Of Attributes: 3<br> info : function clmMonLLT: contributed.ncl<br> time_op_ncl : Climatology: 15 years<br> _FillValue : 1e+20<br>(0) <br>(0) min=0 max=69.7658<br><br>Variable: prClm<br>Type: float<br>Total Size: 1486416 bytes<br> 371604 values<br>Number of Dimensions: 3<br>Dimensions and sizes: [month | 12] x [lat | 179] x [lon | 173]<br>Coordinates: <br> month: [0..11]<br> lat: [-46.25..42.75]<br> lon: [-25.25..60.75]<br>Number Of Attributes: 3<br> info : function clmMonLLT: contributed.ncl<br> time_op_ncl : Climatology: 15 years<br> _FillValue : 1e+20<br>(0) <br>(0) min=0 max=53.8587<br><div style="font-family:trebuchet ms,sans-serif;font-size:large" class="gmail_default"> and the file named climo123 as attached. Any help will be much appreciated.</div><span class="m_7717663735328254710HOEnZb"><font color="#888888"><br>-- <br><div class="m_7717663735328254710m_-2662625413926132514gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div dir="ltr"><div><div><font color="#0000ff" face="trebuchet ms, sans-serif">Try not to become a man of success but rather a man of value-Albert Einstein</font></div><div><font color="#0000ff" face="trebuchet ms, sans-serif"><br></font></div><div><font color="#0000ff"><font face="trebuchet ms, sans-serif">University of Cape Coast|</font><span style="font-family:"trebuchet ms",sans-serif;font-size:12.8px">College of Agriculture and Natural Sciences|</span><span style="font-family:"trebuchet ms",sans-serif;font-size:12.8px">Department of Physics|</span></font></div><div><font color="#0000ff" face="trebuchet ms, sans-serif">Team Leader|Recycle Up! Ghana|Technology Without Borders|</font></div><div><font color="#0000ff"><font face="trebuchet ms, sans-serif">Other emails: </font><span style="font-family:"trebuchet ms",sans-serif;font-size:12.8px"><a href="mailto:kwesi.quagraine@ucc.edu.gh" target="_blank">kwesi.quagraine@ucc.ed<wbr>u.gh</a>|</span><span style="font-family:"trebuchet ms",sans-serif;font-size:12.8px"><a href="mailto:kwesi.quagraine@teog.de" target="_blank">kwesi.quagraine@teog.de</a>|</span></font></div><div><span style="font-family:"trebuchet ms",sans-serif;font-size:12.8px"><font color="#0000ff">Mobile: <a href="tel:+233%2026%20617%203582" value="+233266173582" target="_blank">+233266173582</a></font></span></div></div><div><font color="#0000ff" face="trebuchet ms, sans-serif">Skype: quagraine_cwasi</font></div><div><font color="#0000ff" face="trebuchet ms, sans-serif">Twitter: @Pkdilly</font></div><div><br><img src="cid:ii_1596513231e8f873" alt="Inline image 1" width="387" height="334"></div></div></div></div></div></div></div></div>
</font></span></div>
<br></div></div>______________________________<wbr>_________________<br>
ncl-talk mailing list<br>
<a href="mailto:ncl-talk@ucar.edu" target="_blank">ncl-talk@ucar.edu</a><br>
List instructions, subscriber options, unsubscribe:<br>
<a href="http://mailman.ucar.edu/mailman/listinfo/ncl-talk" rel="noreferrer" target="_blank">http://mailman.ucar.edu/mailma<wbr>n/listinfo/ncl-talk</a><br>
<br></blockquote></div><br></div>
</blockquote></div><br><br clear="all"><br>-- <br><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div dir="ltr"><div><div><font face="trebuchet ms, sans-serif" color="#0000ff">Try not to become a man of success but rather a man of value-Albert Einstein</font></div><div><font face="trebuchet ms, sans-serif" color="#0000ff"><br></font></div><div><font color="#0000ff"><font face="trebuchet ms, sans-serif">University of Cape Coast|</font><span style="font-family:'trebuchet ms',sans-serif;font-size:12.8000001907349px">College of Agriculture and Natural Sciences|</span><span style="font-family:'trebuchet ms',sans-serif;font-size:12.8000001907349px">Department of Physics|</span></font></div><div><font face="trebuchet ms, sans-serif" color="#0000ff">Team Leader|Recycle Up! Ghana|Technology Without Borders|</font></div><div><font color="#0000ff"><font face="trebuchet ms, sans-serif">Other emails: </font><span style="font-family:'trebuchet ms',sans-serif;font-size:12.8px"><a href="mailto:kwesi.quagraine@ucc.edu.gh" target="_blank">kwesi.quagraine@ucc.edu.gh</a>|</span><span style="font-family:'trebuchet ms',sans-serif;font-size:12.8px"><a href="mailto:kwesi.quagraine@teog.de" target="_blank">kwesi.quagraine@teog.de</a>|</span></font></div><div><span style="font-family:'trebuchet ms',sans-serif;font-size:12.8px"><font color="#0000ff">Mobile: +233266173582</font></span></div></div><div><font face="trebuchet ms, sans-serif" color="#0000ff">Skype: quagraine_cwasi</font></div><div><font face="trebuchet ms, sans-serif" color="#0000ff">Twitter: @Pkdilly</font></div><div><br></div></div></div></div></div></div></div></div>
</div>