<div dir="ltr">Dear Dennis,<div>Many thanks for your help. I used the attached script. I just want to check with you to make sure that the script is correct. Would you please check it?</div><div>Best wishes,</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Oct 28, 2019 at 12:31 AM Dennis Shea <<a href="mailto:shea@ucar.edu">shea@ucar.edu</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div>The following is untested. However, it gives you the idea.</div><div>It is your responsibility to look up documentation and look at the printed output.</div><div><br></div><div><br></div><div><div><br></div><div> fils = systemfunc ("ls precip.*.nc") ; file paths<br> a    = addfiles (fils, "r")<br> printVarSummary (a)<br><br>;************************************************<br>; Read the file<br>;************************************************<br><br>  ymdStrt = 19790101                            ; climatology start year/month/day<br>  ymdLast = 20151231                             ;      "      last  year/month/day <br>  time    = a[:]->time<br>  yyyymmdd= cd_calendar(time, -2)       ; note -2<br>print(yyyymmdd)<br>  ntStrt = ind(yyyymmdd.eq.ymdStrt)                ; start time index<br>  ntLast = ind(yyyymmdd.eq.ymdLast)              ; last  time index<br>print("ntStrt="+ntStrt+"  ntLast="+ntLast)<br>   prc   = a[:]->precip(ntStrt:ntLast,:,:)               ; read precip from all files<br><br>   printVarSummary (prc)<br>   printMinMax (prc,0)<br></div><div>  print("=====")</div><div>                   ; you decide what you need<br></div><div>   prcMonth = <a href="http://www.ncl.ucar.edu/Document/Functions/Contributed/calculate_monthly_values.shtml" target="_blank"><b>calculate_monthly_values(</b></a>prc, "avg", 0, False)   ; monthly mean<br></div><div> ;;prcMonth = <a href="http://www.ncl.ucar.edu/Document/Functions/Contributed/calculate_monthly_values.shtml" target="_blank"><b>calculate_monthly_values(</b></a>prc, "sum", 0, False)  ; monthly total<br></div><div><br></div><div>   printVarSummary (prcMonth)<br>   printMinMax (prcMonth,0)<br>   print("=====")</div><div>   opt = True                          ; examine data distribute [information only]<br>   opt@PrintStat = True<br>   stat_prc = stat_dispersion(prcMonth, opt )<br><br>   prcClm   = <a href="http://www.ncl.ucar.edu/Document/Functions/Contributed/clmMonTLL.shtml" target="_blank"><b>clmMonTLL</b></a>(prcMonth)         ; Compute monthly climatology<br>   printVarSummary (prcClm)<br>   printMinMax (prcClm,0)</div><div><br></div><div>====</div><div>Add the plot code.</div><div>Look carefully at: <a href="http://www.ncl.ucar.edu/Applications/HiResPrc.shtml" target="_blank">http://www.ncl.ucar.edu/Applications/HiResPrc.shtml</a></div><div><br></div><div>EG: The following may be inappropriate for your dataset but this is the idea.<br></div><div><pre> res@cnLevelSelectionMode = "ExplicitLevels"
 res@cnLevels             = (/ 0.01, 0.02, 0.04, 0.08, 0.16, \
                               0.32, 0.64, 0.96/)
 res@cnFillColors         = (/"white","cyan", "green","yellow",\
                              "darkorange","red","magenta","purple",\
                              "black"/)
</pre></div></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sun, Oct 27, 2019 at 2:48 PM Dennis Shea <<a href="mailto:shea@ucar.edu" target="_blank">shea@ucar.edu</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div><br></div><div>[0]<br></div><div>As noted on ncl-talk many time the first rule of data processing is *Look at your data!"</div><div>The temperature data were <b>monthly means</b> [K]. <br></div><div>The precipitation data are<b> daily</b> totals [mm/day]. How do I know? I looked at the README file at the URL. You should do that.<br></div><div><br></div><div>[1]</div><div>a =<a href="http://www.ncl.ucar.edu/Document/Functions/Built-in/addfiles.shtml" target="_blank"><b> addfiles</b></a> (fils, "r")</div><div><br></div><div>You have the following which is appropriate for an <a href="http://www.ncl.ucar.edu/Document/Functions/Built-in/addfile.shtml" target="_blank"><b>addfile</b></a> reference</div><div>       time   = a->time       </div><div><br></div><div>However, you are using <a href="http://www.ncl.ucar.edu/Document/Functions/Built-in/addfiles.shtml" target="_blank"><b>addfiles</b></a> It should be:<br></div><div>       time   = a<b>[:]</b>->time   ; <b>[:]</b> syntax is appropriate for an <b>addfiles</b> reference</div><div><br></div><div>[2] <br></div><div>Did you read the documentation for <a href="http://www.ncl.ucar.edu/Document/Functions/Built-in/cd_calendar.shtml" target="_blank"><b>cd_calendar </b></a>as I suggested? The whole point of using <b>cd_calendar</b> is to return 'human-readable' start and end times from which the actual start/stop time index values could be determined.. Your script uses the actual time values [  692496 , 1016808 ] mixed with human-readable yyyymm.  Further, you used <br></div><div><br></div><div>    yyyymm = cd_calendar(time, <b>-1</b>)         ; -1 returns YYYYMM<br></div><div><br></div><div>The precipitation files contain [as noted] daily values. You must use a human readable time like YYYYMMDD [eg: 19790101]. The us</div><div><br></div><div>     yyyymmdd = cd_calendar(time, <b>-2</b>)         ; -2 returns YYYYMMDD</div><div><br></div><div>This converts the actual time values [eg:      692496] to 'human-readable' yyyymmdd [year=>yyyy, month=>mm, day=dd><b> 692496=>197901</b>01] values. </div><div><br></div><div><br></div><div>===</div><div>Also, your script will need to be changed to accommodate the precipitation variable plot values <br></div><div>There are many examples of how to do this.</div><div><br></div><div>eg: <a href="http://www.ncl.ucar.edu/Applications/HiResPrc.shtml" target="_blank"><b>http://www.ncl.ucar.edu/Applications/HiResPrc.shtml</b></a></div><div>===<br></div><div>In a previous email, you mentioned that you converted degrees Kelvin to C.</div><div>It is best to self-document the  variable with its new units.<br></div><div><br></div><div>   tmp = tmp-273.15</div><div>   tmp@units = "degC"  ; this will be automatically plotted <br></div><div>===</div><div>Good Luck<br></div><div><br></div><div><b><br></b></div><div><b><br></b></div><div><b><br></b></div><div><b></b><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sat, Oct 26, 2019 at 8:19 AM zoe jacobs <<a href="mailto:zoejacobs1990@gmail.com" target="_blank">zoejacobs1990@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div dir="ltr">Dear all,<div>I would like to have climatology precipitation like temperature climatology discussed through previous emails. However, there are precipitation files for each year from 1979- 2015 (<a href="ftp://ftp.cdc.noaa.gov/Datasets/cpc_global_precip/" target="_blank">ftp://ftp.cdc.noaa.gov/Datasets/cpc_global_precip/</a>). In the first step, I tried to merge all those files as one, and then use Dennis script to plot a map. I faced some errors and need your advice please. the script I am running has been attached.<span style="color:rgb(80,0,80)">Many thanks in advance,</span></div></div><div class="gmail_quote"><div dir="ltr" class="gmail_attr"><span style="color:rgb(80,0,80)">Best regards</span>n Sat, Oct 26, 2019 at 3:20 PM zoe jacobs <<a href="mailto:zoejacobs1990@gmail.com" target="_blank">zoejacobs1990@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">I just noticed that I could use <span style="color:rgb(0,0,0);white-space:pre-wrap">res@gsnRightString      = " deg C" .</span><div><font color="#000000"><span style="white-space:pre-wrap">Once again, many thanks for your guide.</span></font></div><div><font color="#000000"><span style="white-space:pre-wrap">Best wishes,<br></span></font><div><span style="color:rgb(0,0,0);white-space:pre-wrap"><br></span></div></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Oct 25, 2019 at 11:07 PM Dennis Shea <<a href="mailto:shea@ucar.edu" target="_blank">shea@ucar.edu</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div>I forgot to mention that plots can be done in 'portrait' [default] or 'landscape' mode.</div><div><br></div><div>You should experiment to see which is appropriate for your needs.<br></div><div><br></div><div>resP@gsnPaperOrientation = "landscape"        ; "portrait" is default</div><div><br></div><div>  do nmo=0,11                                   ; loop over the months<br>     res@gsnLeftString     = months(nmo)<br>     plot(nmo) = gsn_csm_contour_map(wks,tmpClm(nmo,:,:), res)  ; create plot<br>  end do<br><br>  if (resP@gsnPaperOrientation .eq."landscape") then<br>      gsn_panel(wks,plot,(/3,4/),resP)                                  ; 3 rows x 4 columns<br>  else<br>      gsn_panel(wks,plot,(/4,3/),resP)            ; portrait         ; 4 rows x 3 columns<br>  end if<br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Oct 25, 2019 at 12:15 PM Dennis Shea <<a href="mailto:shea@ucar.edu" target="_blank">shea@ucar.edu</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div>Hello,</div><div><br></div><div>We do not usually do this but this is offline from ncl-talk.<br></div><div><br></div><div>[1] <br></div><div>Conventional subscripts start at 1 for Fortran and Matlab.  Hence, for 12 months [nmos=12]</div><div>     Fortran: do nmo=1,nmos  <br></div><div>     Matlab: for 1:nmos   or 1:1:nmos  [I am not a Matlab user so this is a guess.]<br></div><div>NCL 'conventional' subscripts start at 0 [like C/C++/IDL/Python]</div><div>     NCL: do nmo=0,ntim-1</div><div><br></div><div>[2] Dave illustrated 'coordinate subscripting' which uses the <span style="color:rgb(0,0,255)"><b>{</b></span>...<span style="color:rgb(0,0,255)"><b>}</b></span> syntax.</div><div><br></div><div>The script I am attaching uses conventional subscripting. Just like Matlab/Fortran except it uses a range fro 0 to 11 [12 elements].</div><div><br></div><div>[3] Please carefully read the documentation for <a href="http://www.ncl.ucar.edu/Document/Functions/Contributed/clmMonTLL.shtml" target="_blank"><b>clmMonTLL</b></a>, <a href="http://www.ncl.ucar.edu/Document/Functions/Built-in/cd_calendar.shtml" target="_blank"><b>cd_calendar</b></a>,<a href="http://www.ncl.ucar.edu/Document/Functions/Built-in/ind.shtml" target="_blank"><b> ind</b></a></div><div><br></div><div>[4] Look at the output from '<a href="http://www.ncl.ucar.edu/Document/Functions/Built-in/printVarSummary.shtml" target="_blank"><b>printVarSummary</b></a>'.  USE <b>printVarSummary </b>frequently.<br></div><div>     Note the dimensions and added attributes:  <br></div><div>     time_op_ncl :  Climatology: 29 years<br>     info :  function clmMonTLL: contributed.ncl</div><div><br></div><div>[5] NCL offer a large number of color tables [palettes]:</div><div>             <a href="http://www.ncl.ucar.edu/Document/Graphics/color_table_gallery.shtml" target="_blank"><b>http://www.ncl.ucar.edu/Document/Graphics/color_table_gallery.shtml</b></a></div><div>     Using a color map that emphasizes features can be very useful.</div><div><br></div><div>[6] You must invest the time to learn any new language. <br></div><div>Karin Meier-Fliesher and Michael Bottinger [DKRZ] wrote a wonderful tutorial. <br></div><div><br></div><div><a href="http://www.ncl.ucar.edu/Document/Manuals/NCL_User_Guide/" target="_blank"><b>http://www.ncl.ucar.edu/Document/Manuals/NCL_User_Guide/</b></a></div><div><br></div><div>I suggest you read it.</div><div><br></div><div>Good luck</div><div>==============<br></div><div><b>%></b> ncl  zoe_jacobs.hgcn_cams.ncl</div><div><br></div><div>will produce a png file.<br></div><div><br></div><div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Oct 25, 2019 at 11:16 AM Dave Allured - NOAA Affiliate via ncl-talk <<a href="mailto:ncl-talk@ucar.edu" target="_blank">ncl-talk@ucar.edu</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div>1.  In your example, please notice that the month loop has a stride of 3.  Therefore it is making plots for only four months:  January, April, July, and October.</div><div><br></div><div>If you want all 12 months, remove the stride.  Then make sure the array "plot" is dimensioned 12.  I think you can interchangeably use either a 1-D or 2-D plot array (i.e. 3*4), your choice.</div><div><br></div><div>The secondary index "i" is used to write the four plots into positions 0, 1, 2, 3 in the "plot" graphics array.  If you are making 12 plots, you do not really need to use a secondary index.</div><div><br></div><div>Panel plotting uses a graphics array containing multiple plots.  Please study basic examples and documentation for making panel plots.</div><div><br></div><div>2.  That data file has full coordinates.  Therefore you can use either conventional or coordinate subscripting, or mixed, your choice.</div><div><br></div>I suggest using one of the date functions with coordinate subscripting, to index the time subset that you want.  Something like this:<br><br>    time_units = f->air&time@units<br>    time1 = cd_inv_calendar (year1, 1, 1, 0, 0, 0, time_units, 0)<br>    time2 = cd_inv_calendar (year2, 12, 31, 23, 0, 0, time_units, 0)</div><div dir="ltr">    air_subset = f->air({time1:time2},:,:)<br><div><br></div><div>Use printVarSummary to ensure that the subset has the dimension sizes that you expect.  Then you can proceed to compute the climatology.</div><div><br></div><div><br></div><div>On Fri, Oct 25, 2019 at 10:14 AM zoe jacobs via ncl-talk <<a href="mailto:ncl-talk@ucar.edu" target="_blank">ncl-talk@ucar.edu</a>> wrote:<br></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><font face="arial, sans-serif">Hi all,</font><div><font face="arial, sans-serif">regarding climo_3.ncl (<a href="https://www.ncl.ucar.edu/Applications/Scripts/climo_3.ncl" target="_blank">https://www.ncl.ucar.edu/Applications/Scripts/climo_3.ncl</a>) ,</font></div><div><font face="arial, sans-serif">I have 2 questions:</font></div><div><font face="arial, sans-serif">1. I need to plot all months on one panel (say 3*4), and cannot understand the logic behind the below loop, which used in the climo_3.ncl script :</font></div><div><pre style="color:rgb(0,0,0);white-space:pre-wrap"><font style="background-color:rgb(241,194,50)" face="arial, sans-serif">i = -1                                        ; Climatologies
  do nmo=0,11,3                                 ; loop over the months
     i = i+1
     res@gsnCenterString   = months(nmo)+":"+time(0)/100 +"-"+ time(ntim-1)/100
     plot(i) = gsn_csm_contour_map(wks,prcClm(nmo,:,:), res)  ; create plot
  end do</font></pre><pre style="color:rgb(0,0,0);white-space:pre-wrap"><font style="background-color:rgb(241,194,50)" face="arial, sans-serif">How  does it  work??/</font></pre><pre style="color:rgb(0,0,0);white-space:pre-wrap"><font face="arial, sans-serif">2. I would like to show climotology temperature from 1987- 2015. Data which I am using is<span style="background-color:rgb(180,167,214)"> <a href="http://air.mon.mean.nc" target="_blank">air.mon.mean.nc</a> </span><span style="background-color:rgb(255,255,255)"> ( </span><a href="https://www.esrl.noaa.gov/psd/data/gridded/data.ghcncams.html" target="_blank">https://www.esrl.noaa.gov/psd/data/gridded/data.ghcncams.html</a>) <span style="background-color:rgb(255,255,255)"> and it is </span>using conventional subscripts. I am not familiar with conventional subscripts. So how can I convert coordinate subscripting to conventional subscripts?!!</font></pre><pre style="color:rgb(0,0,0);white-space:pre-wrap"><font face="arial, sans-serif">Please kindly advice me .</font></pre><pre style="color:rgb(0,0,0);white-space:pre-wrap"><font face="arial, sans-serif">Many thanks in advance,</font></pre><pre style="color:rgb(0,0,0);white-space:pre-wrap"><font face="arial, sans-serif">Best regards,</font></pre></div></div></blockquote></div></div></div></div>
_______________________________________________<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/mailman/listinfo/ncl-talk</a></blockquote></div>
</blockquote></div>
</blockquote></div>
</blockquote></div></div>
</blockquote></div>
</blockquote></div>
</blockquote></div>