<div dir="ltr"><div><div><div><div><div><div><div><div>NCL uses the order returned by {u/li}nix &#39;ls&#39; command.<br><br></div>%&gt;  ls ./simulation*.nc<br><br>---<br></div>So, if the files are named as follows<br><br></div>    <a href="http://simulation_001.nc" target="_blank">simulation_001.nc</a><br></div>    <a href="http://simulation_002.nc" target="_blank">simulation_002.nc</a><br>    ...<br></div>    <a href="http://simulation_100.nc" target="_blank">simulation_100.nc</a><br><br></div><div>you will get this order and you can use the:<br>    <br></div><div>    diri = &quot;./&quot;   ; input directory<br></div><div>    fili   = systemfunc(&quot;cd &quot;+diri+&quot; ; ls simulation*nc&quot;)<br></div><div>    f      = addfiles( diri+fili)<br></div><div><br>==============<br></div><div><br></div>However, the files are named <br><br>    <a href="http://simulation_1.nc" target="_blank">simulation_1.nc</a><br>    <a href="http://simulation_2.nc" target="_blank">simulation_2.nc</a><br>    ...<br></div>    <a href="http://simulation_9.nc" target="_blank">simulation_9.nc</a><br></div>    <a href="http://simulation_10.nc" target="_blank">simulation_10.nc</a><br>    ...<br>    <a href="http://simulation_20.nc" target="_blank">simulation_20.nc</a><br>    ...<br>    <a href="http://simulation_30.nc" target="_blank">simulation_30.nc</a><br>    ...<br>    ...<br><div><div>    <a href="http://simulation_100.nc" target="_blank">simulation_100.nc</a><br><br>====<br></div><div>You will get<br><br></div><div><a href="http://simulation_1.nc" target="_blank">simulation_1.nc</a><br></div><div><a href="http://simulation_10.nc" target="_blank">simulation_10.nc</a><br></div><div><a href="http://simulation_100.nc" target="_blank">simulation_100.nc</a><br></div><div><a href="http://simulation_2.nc" target="_blank">simulation_2.nc</a><br></div><div><a href="http://simulation_20.nc" target="_blank">simulation_20.nc</a><br></div><div><a href="http://simulation_30.nc" target="_blank">simulation_30.nc</a><br></div><div><a href="http://simulatiom_9.nc" target="_blank">simulatiom_9.nc</a><br><br></div><div>Likely, this is not chronological order.<br></div><div><br>========================<br></div><div><br></div><div>I just wrote the attached function. If it is in a file named (say)  &#39;myLib.ncl&#39;, It can be tested with:<br><br></div><div>load &quot;./myLib.ncl&quot;<br></div><div><br>fileName = (/ &quot;<a href="http://simulation_1.nc" target="_blank">simulation_1.nc</a>&quot; ,&quot;<a href="http://simulation_10.nc" target="_blank">simulation_10.nc</a>&quot; ,&quot;<a href="http://simulation_100.nc" target="_blank">simulation_100.nc</a>&quot; \<br>             , &quot;<a href="http://simulation_2.nc" target="_blank">simulation_2.nc</a>&quot; ,&quot;<a href="http://simulation_20.nc" target="_blank">simulation_20.nc</a>&quot; ,&quot;<a href="http://simulation_30.nc" target="_blank">simulation_30.nc</a>&quot;  \<br>             , &quot;<a href="http://simulatiom_9.nc" target="_blank">simulatiom_9.nc</a>&quot; /)<br> print(fileName)<br>print(&quot;============&quot;)<br> <br> filUp     =  filename_reorder_test(fileName, 2, &quot;_.&quot;,  1)<br> filDown =  filename_reorder_test(fileName, 2, &quot;_.&quot;, -1)<br><br> print(fileName+&quot;  &quot;+ filUp+ &quot;  &quot;+filDown)<br><br>++++++++++++++++++++++++++++++++++++++++++++++<br><br></div><div>In your usage case, something like:<br><br></div><div>load &quot;./myLib.ncl&quot;<br><br></div><div>   diri = &quot;./&quot;   ; input directory<br></div><div>   fili  = systemfunc(&quot;cd &quot;+diri+&quot;  ;  ls simulation*nc&quot;)<br>   <br></div><div>   fili_new =  filename_reorder_test(fili, 2, &quot;_.&quot;,  1)<br></div><div>   print(fili_new)<br></div><div>   print(&quot;=====&quot;)<br><br></div><div>; read files in sorted order<br><br></div><div>   f = addfiles(diri+fili_new, &quot;r&quot;)    <br><br></div><div>   temp = f[:]-&gt;TEMP<br></div><div>   printVarSummary(temp)<br></div><div>   printMinMax(temp,0)<br></div><div><br><br></div><div>   Good luck<br></div><div><br></div><div><br><br></div><div><br></div><div><div><div><br></div></div></div></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Aug 12, 2016 at 3:43 AM, Michele Petrini <span dir="ltr">&lt;<a href="mailto:mpetrini139@yahoo.it" target="_blank">mpetrini139@yahoo.it</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
  

    
  
  <div bgcolor="#FFFFFF" text="#000000">
    Dear NCL helpdesk,<br>
    <div> <br>
      I have a question re the <b>addfiles</b> function. I am using
      this function in order to read data from an ensemble of 101 NetCDF
      files - let&#39;s say from <i>simulation000</i>.<i>nc</i> to <i>simulation100</i>.<i>nc</i>.
      <br>
      <br>
      My question is, what is the order the files are read with? Can I
      assume is from 000 to 100 if I have <br>
      <br>
      
      <pre style="margin:0px;padding:0px;font-size:13.3333px;line-height:16px;font-family:courier;border-style:solid;border-width:0px 0px 15px;border-color:transparent;text-indent:0px;color:rgb(0,0,0);font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:left;text-transform:none;word-spacing:0px;background-color:rgb(255,255,255)"> all_files = <a href="http://www.ncl.ucar.edu/Document/Functions/Built-in/systemfunc.shtml" style="margin:0px;padding:0px;text-decoration:none;color:rgb(133,45,133);font-family:verdana,sans-serif;font-weight:normal" target="_blank"><strong style="margin:0px;padding:0px">systemfunc</strong></a> (&quot;ls ./simulation*.nc&quot;)
     fall      = <strong style="margin:0px;padding:0px">addfiles</strong> (all_files, &quot;r&quot;) </pre>
      I ask this because I had a missing value error for the last file -
      but <a href="http://simulation100.nc" target="_blank">simulation100.nc</a> file seems to be ok. Do you have any clue why
      this could happen? <br>
      <br>
      Thank you for your help,<br>
      <br>
      Best regards<br>
      Michele Petrini<br>
      
      <pre cols="72">-- 

***
Michele Petrini

Ph.D. student in Earth Science and Fluid Mechanics

Università degli studi di Trieste, 
Dipartimento di Matematica e Geoscienze 
Palazzina C - via Weiss 1, 34128 Trieste, Italy

Email: <a href="mailto:mpetrini139@yahoo.it" target="_blank">mpetrini139@yahoo.it</a>
Skype: michele.petrins
Mobile: <a href="tel:%2B39%203398367372" value="+393398367372" target="_blank">+39 3398367372</a> 
</pre>
    </div>
  </div>

<br>______________________________<wbr>_________________<br>
ncl-talk mailing list<br>
<a href="mailto:ncl-talk@ucar.edu">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/<wbr>mailman/listinfo/ncl-talk</a><br>
<br></blockquote></div><br></div>