<div dir="ltr">Thanks again Dave for your help. I did note that you gave me two ways of getting ntimes. I kept both ( just for my learning) but commented out one.<div>My understanding is that   tc = wrf_user_getvar (files_all, "tc", it) is to get tc in all the files, in other words, the same as tc = wrf_user_getvar (files_all[:], "tc", it) is that correct?</div><div>Now my problem is on contour_tc = wrf_contour(files_all,wks,tc_plane,opts).</div><div>I think this has to take one file to plot at time it, out of files_all.contour_tc = wrf_contour(files_all,wks,tc_plane,opts)</div><div>Whether I put contour_tc = wrf_contour(files_all,wks,tc_plane,opts), contour_tc = wrf_contour(files_all(0),wks,tc_plane,opts) or contour_tc = wrf_contour(files_all[0],wks,tc_plane,opts) I get "fatal:Argument type mismatch on argument (0) of (wrf_contour) can not coerce".</div><div>So my problem is how do I specify the file from which to plot on that line?</div><div>I am trying to go through the documentation on subscripting, but ncl is such a vast library that I need time.</div></div><div id="DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2"><br>
<table style="border-top:1px solid #d3d4de">
        <tr>
        <td style="width:55px;padding-top:13px"><a href="https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail" target="_blank"><img src="https://ipmcdn.avast.com/images/icons/icon-envelope-tick-round-orange-animated-no-repeat-v1.gif" alt="" width="46" height="29" style="width: 46px; height: 29px;"></a></td>
                <td style="width:470px;padding-top:12px;color:#41424e;font-size:13px;font-family:Arial,Helvetica,sans-serif;line-height:18px">Virus-free. <a href="https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail" target="_blank" style="color:#4453ea">www.avast.com</a>
                </td>
        </tr>
</table><a href="#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2" width="1" height="1"></a></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Apr 4, 2022 at 8:11 PM Dave Allured - NOAA Affiliate <<a href="mailto:dave.allured@noaa.gov">dave.allured@noaa.gov</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>Zilore, I showed you two different ways to get ntimes.  Please choose only one or the other.  Do not put both in your program, it makes it hard to understand.  Also ntimes is a nice scalar, not an array.  So only use ntimes, not ntimes(0) or dims(0).<br><br>I think you want times_to_use, not times, to display time strings:<br><br>    print ("Working on time: " + times_to_use(it) )<br>    res@TimeLabel = times_to_use(it)<br><br>There are two different ways to do time indexing with wrf_user_getvar.  See the function documentation, and the examples at the end of that page.  The way you have it now looks like one of the correct ways.</div><div><br>    tc = wrf_user_getvar (files_all, "tc", it) <br><br><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sat, Apr 2, 2022 at 2:24 PM Zilore Mumba <<a href="mailto:zmumba@gmail.com" target="_blank">zmumba@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">Thanks Dave for the assistance. I have made some progress. While I know that I need time to learn ncl subscripting, perhaps I could be helped to make the script work. This script is an adaptation of one of the provided wrf-ncl scripts. The script plots several variables at different levels. I have reproduced below, parts of the script which plot temperature. I have marked in<div>1. yellow, some guidance I got from Dave</div><div>2. blue some changes I made to getting the times</div><div>3. purple, getting the variables, with files_all (I assume it is equivalent to files_all[:] and gets variables from all files)</div><div>4. red I have to specify from which file to plot. This is where I have a problem, how to index files_all.</div><div>I hope I can be assisted.<br><div><br></div><div>  files_all = addfiles(FILES+".nc","r")<br><br>; get time information<br>  times_in_file = files_all[:]->Times<br><span style="background-color:rgb(255,255,255)"> </span><b><font color="#000000"> <span style="background-color:rgb(255,255,0)">dims = dimsizes (times)<br>  ntimes = dimsizes (times(:,0))</span></font></b><br><br>; strip out the day and hour<br>  times_to_use = new(dims(0),string)<br><br>  do i=0,dims(0)-1<br>    times_to_use(i) = chartostring(times_in_file(i,8:12))<br>  end do<br>;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;<br>  do it = 0,<font color="#0000ff">ntimes(0)</font>-1,2             ; TIME LOOP<br><br>    print("Working on time: " +<font color="#0000ff"> times(it,0)</font> )<br>    res@TimeLabel =<font color="#0000ff"> times(it,0) </font>  ; Set Valid time to use on plots<br>;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;<br>; First get the variables we will need<br>    tc = wrf_user_getvar<font color="#9900ff">(<b style="background-color:rgb(255,242,204)">files_all</b></font><b style="background-color:rgb(255,242,204)">,</b>"tc",it)        ; T in C<br>    u  = wrf_user_getvar(files_all,"ua",it)        ; u averaged to mass points<br>    v  = wrf_user_getvar(files_all,"va",it)        ; v averaged to mass points<br>    p  = wrf_user_getvar(files_all, "pressure",it) ; pressure is our vertical coordinate<br>    z  = wrf_user_getvar(files_all, "z",it)        ; grid point height<br>    rh = wrf_user_getvar(files_all,"rh",it)        ; relative humidity<br>;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;<br>    do level = 0,nlevels-1                 ; LOOP OVER LEVELS<br><br>      pressure = pressure_levels(level)<br>      tc_plane = wrf_user_intrp3d(tc,p,"h",pressure,0.,False)<br>      z_plane  = wrf_user_intrp3d( z,p,"h",pressure,0.,False)<br>      rh_plane = wrf_user_intrp3d(rh,p,"h",pressure,0.,False)<br>      u_plane  = wrf_user_intrp3d( u,p,"h",pressure,0.,False)<br>      v_plane  = wrf_user_intrp3d( v,p,"h",pressure,0.,False)<br><br>      spd     = (u_plane*u_plane + v_plane*v_plane)^(0.5) ; m/sec<br>      spd@description = "Wind Speed"<br>      spd@units = "m/s"<br>      u_plane = u_plane*1.94386     ; kts<br>      v_plane = v_plane*1.94386     ; kts<br>      u_plane@units = "kts"<br>      v_plane@units = "kts"<br><br>      wks = gsn_open_wks(type,"Plots00-" + "P" + pressure_levels(level) + "_" + times_to_use(it) + "Z")<br><br>      ; Plotting options for T<br>        opts = res<br>        opts@cnLineColor = "Red"<br>        opts@ContourParameters = (/ 5.0 /)<br>        opts@cnInfoLabelOrthogonalPosF = 0.07  ; offset second label information<br>        opts@gsnContourLineThicknessesScale = 2.0<br>        contour_tc = wrf_contour(<b style="background-color:rgb(255,255,255)"><font color="#ff0000">files_all</font></b>,wks,tc_plane,opts)<br>        delete(opts)<br><br>    end do      ; END OF LEVEL LOOP<br>;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;<br>  end do        ; END OF TIME LOOP<br></div></div></div><div id="gmail-m_-2706776208549386084gmail-m_-355677814135215976DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2"><br>
<table style="border-top:1px solid rgb(211,212,222)">
        <tbody><tr>
        <td style="width:55px;padding-top:13px"><a href="https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail" target="_blank"><img src="https://ipmcdn.avast.com/images/icons/icon-envelope-tick-round-orange-animated-no-repeat-v1.gif" alt="" width="46" height="29" style="width: 46px; height: 29px;"></a></td>
                <td style="width:470px;padding-top:12px;color:rgb(65,66,78);font-size:13px;font-family:Arial,Helvetica,sans-serif;line-height:18px">Virus-free. <a href="https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail" style="color:rgb(68,83,234)" target="_blank">www.avast.com</a>
                </td>
        </tr>
</tbody></table><a href="#m_-2706776208549386084_m_-355677814135215976_DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2" width="1" height="1"></a></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sat, Apr 2, 2022 at 5:06 PM Dave Allured - NOAA Affiliate <<a href="mailto:dave.allured@noaa.gov" target="_blank">dave.allured@noaa.gov</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>Here are two different ways to get the size of the time dimension.  The second method uses dimension reduction to find the size of only one slice of the 2-D character array.</div><div><br></div><div>dims = dimsizes (times)</div><div>ntimes = dims(0)</div><div><br></div><div>ntimes = dimsizes (times(:,0))</div><div dir="ltr"><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Apr 1, 2022 at 11:04 PM Zilore Mumba <<a href="mailto:zmumba@gmail.com" target="_blank">zmumba@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 have 13 files, i.e. analysis plus 12 hourly files of forecasts. 

print (files_all[0]->Times) and printVarSummary(times) give the following output:<div>Variable: Times (file variable)<br>Type: character<br>Total Size: 19 bytes<br>            19 values<br>Number of Dimensions: 2<br>Dimensions and sizes:      [Time | 1] x [DateStrLen | 19]<br>Coordinates: <br>(0,0)    2<br>(0,1)        0<br>(0,2)        2<br>(0,3)        2<br>(0,4)        -<br>(0,5)        0<br>(0,6)        3<br>(0,7)        -<br>(0,8)        2<br>(0,9)        8<br>(0,10)       _<br>(0,11)       0<br>(0,12)       0<br>(0,13)       :<br>(0,14)       0<br>(0,15)       0<br>(0,16)       :<br>(0,17)       0<br>(0,18)       0<br><br>Variable: times<br>Type: character<br>Total Size: 247 bytes<br>            247 values<br>Number of Dimensions: 2<br>Dimensions and sizes:      [Time | 13] x [DateStrLen | 19]<br>Coordinates:</div><div> <br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Apr 1, 2022 at 11:53 PM Dave Allured - NOAA Affiliate <<a href="mailto:dave.allured@noaa.gov" target="_blank">dave.allured@noaa.gov</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>Please show print (files_all[0]->Times) and printVarSummary(times).</div><div dir="ltr"><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Apr 1, 2022 at 3:42 PM Zilore Mumba via ncl-talk <<a href="mailto:ncl-talk@mailman.ucar.edu" target="_blank">ncl-talk@mailman.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">I have a number of WRF output files, one file per hour, which I open with<div>files_all = addfiles(FILES+".nc","r")<br></div><div><br></div><div>I then get the times and the total number with.</div><div>  times = files_all[:]->Times      ; get all times in the file<br>  ntimes = dimsizes(times)         ; number of times in the file<br></div><div><br></div><div>I think I am missing something here because  with print(ntimes) I see two numbers.</div><div>I want to use ntimes in a loop: do it = 0,ntimes-1,2</div><div><br></div><div>This gives me the error: fatal:Loop end must be scalar, can't execute loop.</div><div>How do I get the times from files opened with addfiles. I will appreciate any assistance.</div></div></blockquote></div></div>
</blockquote></div>
</blockquote></div></div>
</blockquote></div>
</blockquote></div></div></div>
</blockquote></div>