<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-width:1px;border-left-style:solid;border-left-color: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-width:1px;border-left-style:solid;border-left-color: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-width:1px;border-left-style:solid;border-left-color: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>