<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Old thread and probably solved, but for the archive a simple alternative to Dennis’s function would be<div class=""><br class=""></div><div class="">Rather that sort the return of the below yourself</div><div class=""><div dir="ltr" class=""><div class=""><div class=""><div class=""><div class=""><div class=""><div class=""><div class="">&gt;&nbsp; ls ./simulation*.nc</div></div></div></div></div></div></div></div><div class="">use :</div><div class=""><div dir="ltr" class=""><div class=""><div class=""><div class=""><div class=""><div class=""><div class=""><div class="">&gt;&nbsp; ls -v ./simulation*.nc</div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">probably depends on your &nbsp;ls version so the function may be more generic.&nbsp;</div><div class=""><br class=""></div><div class="">man ls&nbsp;</div><div class="">...</div><div class="">&nbsp; &nbsp; -v &nbsp; &nbsp; natural sort &nbsp;of &nbsp;(version) &nbsp;numbers &nbsp;within &nbsp;text&nbsp;</div><div class="">...</div></div></div></div></div></div></div></div></div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">e.g.&nbsp;</div><div class=""><div class="">&nbsp;~&gt;ls -1 fil*</div><div class="">file1</div><div class="">file10</div><div class="">file2</div><div class="">file3</div><div class="">~&gt;ls -1v fil*</div><div class="">file1</div><div class="">file2</div><div class="">file3</div><div class="">file10</div></div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div><br class=""><div class="">
<div style="color: rgb(0, 0, 0); letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div style="color: rgb(0, 0, 0); font-family: Helvetica; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; border-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-stroke-width: 0px;"><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">##############################<br class="">Alan Brammer,<div class="">Post-Doc Researcher</div><div class=""><br class=""></div><div class="">Department of Atmospheric and&nbsp;Environmental Sciences,<br class="">University at Albany,&nbsp;State University of New&nbsp;York,&nbsp;Albany, NY, 12222<div class=""><a href="mailto:abrammer@albany.edu" class="">abrammer@albany.edu</a><br class="">##############################</div></div></div></span></div></div>
</div>
<br class=""><div><blockquote type="cite" class=""><div class="">On 12 Aug 2016, at 08:52, Dennis Shea &lt;<a href="mailto:shea@ucar.edu" class="">shea@ucar.edu</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class=""><div class=""><div class=""><div class=""><div class=""><div class=""><div class=""><div class=""><div class="">NCL uses the order returned by {u/li}nix 'ls' command.<br class=""><br class=""></div>%&gt;&nbsp; ls ./simulation*.nc<br class=""><br class="">---<br class=""></div>So, if the files are named as follows<br class=""><br class=""></div>&nbsp;&nbsp;&nbsp; <a href="http://simulation_001.nc/" target="_blank" class="">simulation_001.nc</a><br class=""></div>&nbsp;&nbsp;&nbsp; <a href="http://simulation_002.nc/" target="_blank" class="">simulation_002.nc</a><br class="">&nbsp;&nbsp;&nbsp; ...<br class=""></div>&nbsp;&nbsp;&nbsp; <a href="http://simulation_100.nc/" target="_blank" class="">simulation_100.nc</a><br class=""><br class=""></div><div class="">you will get this order and you can use the:<br class="">&nbsp;&nbsp;&nbsp; <br class=""></div><div class="">&nbsp;&nbsp;&nbsp; diri = "./"&nbsp;&nbsp; ; input directory<br class=""></div><div class="">&nbsp;&nbsp;&nbsp; fili&nbsp;&nbsp; = systemfunc("cd "+diri+" ; ls simulation*nc")<br class=""></div><div class="">&nbsp;&nbsp;&nbsp; f&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = addfiles( diri+fili)<br class=""></div><div class=""><br class="">==============<br class=""></div><div class=""><br class=""></div>However, the files are named <br class=""><br class="">&nbsp;&nbsp;&nbsp; <a href="http://simulation_1.nc/" target="_blank" class="">simulation_1.nc</a><br class="">&nbsp;&nbsp;&nbsp; <a href="http://simulation_2.nc/" target="_blank" class="">simulation_2.nc</a><br class="">&nbsp;&nbsp;&nbsp; ...<br class=""></div>&nbsp;&nbsp;&nbsp; <a href="http://simulation_9.nc/" target="_blank" class="">simulation_9.nc</a><br class=""></div>&nbsp;&nbsp;&nbsp; <a href="http://simulation_10.nc/" target="_blank" class="">simulation_10.nc</a><br class="">&nbsp;&nbsp;&nbsp; ...<br class="">&nbsp;&nbsp;&nbsp; <a href="http://simulation_20.nc/" target="_blank" class="">simulation_20.nc</a><br class="">&nbsp;&nbsp;&nbsp; ...<br class="">&nbsp;&nbsp;&nbsp; <a href="http://simulation_30.nc/" target="_blank" class="">simulation_30.nc</a><br class="">&nbsp;&nbsp;&nbsp; ...<br class="">&nbsp;&nbsp;&nbsp; ...<br class=""><div class=""><div class="">&nbsp;&nbsp;&nbsp; <a href="http://simulation_100.nc/" target="_blank" class="">simulation_100.nc</a><br class=""><br class="">====<br class=""></div><div class="">You will get<br class=""><br class=""></div><div class=""><a href="http://simulation_1.nc/" target="_blank" class="">simulation_1.nc</a><br class=""></div><div class=""><a href="http://simulation_10.nc/" target="_blank" class="">simulation_10.nc</a><br class=""></div><div class=""><a href="http://simulation_100.nc/" target="_blank" class="">simulation_100.nc</a><br class=""></div><div class=""><a href="http://simulation_2.nc/" target="_blank" class="">simulation_2.nc</a><br class=""></div><div class=""><a href="http://simulation_20.nc/" target="_blank" class="">simulation_20.nc</a><br class=""></div><div class=""><a href="http://simulation_30.nc/" target="_blank" class="">simulation_30.nc</a><br class=""></div><div class=""><a href="http://simulatiom_9.nc/" target="_blank" class="">simulatiom_9.nc</a><br class=""><br class=""></div><div class="">Likely, this is not chronological order.<br class=""></div><div class=""><br class="">========================<br class=""></div><div class=""><br class=""></div><div class="">I just wrote the attached function. If it is in a file named (say)&nbsp; 'myLib.ncl', It can be tested with:<br class=""><br class=""></div><div class="">load "./myLib.ncl"<br class=""></div><div class=""><br class="">fileName = (/ "<a href="http://simulation_1.nc/" target="_blank" class="">simulation_1.nc</a>" ,"<a href="http://simulation_10.nc/" target="_blank" class="">simulation_10.nc</a>" ,"<a href="http://simulation_100.nc/" target="_blank" class="">simulation_100.nc</a>" \<br class="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; , "<a href="http://simulation_2.nc/" target="_blank" class="">simulation_2.nc</a>" ,"<a href="http://simulation_20.nc/" target="_blank" class="">simulation_20.nc</a>" ,"<a href="http://simulation_30.nc/" target="_blank" class="">simulation_30.nc</a>"&nbsp; \<br class="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; , "<a href="http://simulatiom_9.nc/" target="_blank" class="">simulatiom_9.nc</a>" /)<br class="">&nbsp;print(fileName)<br class="">print("============")<br class="">&nbsp;<br class="">&nbsp;filUp&nbsp;&nbsp;&nbsp;&nbsp; =&nbsp; filename_reorder_test(fileName, 2, "_.",&nbsp; 1)<br class="">&nbsp;filDown =&nbsp; filename_reorder_test(fileName, 2, "_.", -1)<br class=""><br class="">&nbsp;print(fileName+"&nbsp; "+ filUp+ "&nbsp; "+filDown)<br class=""><br class="">++++++++++++++++++++++++++++++++++++++++++++++<br class=""><br class=""></div><div class="">In your usage case, something like:<br class=""><br class=""></div><div class="">load "./myLib.ncl"<br class=""><br class=""></div><div class="">&nbsp;&nbsp; diri = "./"&nbsp;&nbsp; ; input directory<br class=""></div><div class="">&nbsp;&nbsp; fili&nbsp; = systemfunc("cd "+diri+"&nbsp; ;&nbsp; ls simulation*nc")<br class="">&nbsp;&nbsp; <br class=""></div><div class="">&nbsp;&nbsp; fili_new =&nbsp; filename_reorder_test(fili, 2, "_.",&nbsp; 1)<br class=""></div><div class="">&nbsp;&nbsp; print(fili_new)<br class=""></div><div class="">&nbsp;&nbsp; print("=====")<br class=""><br class=""></div><div class="">; read files in sorted order<br class=""><br class=""></div><div class="">&nbsp;&nbsp; f = addfiles(diri+fili_new, "r")&nbsp;&nbsp;&nbsp; <br class=""><br class=""></div><div class="">&nbsp;&nbsp; temp = f[:]-&gt;TEMP<br class=""></div><div class="">&nbsp;&nbsp; printVarSummary(temp)<br class=""></div><div class="">&nbsp;&nbsp; printMinMax(temp,0)<br class=""></div><div class=""><br class=""><br class=""></div><div class="">&nbsp;&nbsp; Good luck<br class=""></div><div class=""><br class=""></div><div class=""><br class=""><br class=""></div><div class=""><br class=""></div><div class=""><div class=""><div class=""><br class=""></div></div></div></div></div><div class="gmail_extra"><br class=""><div class="gmail_quote">On Fri, Aug 12, 2016 at 3:43 AM, Michele Petrini <span dir="ltr" class="">&lt;<a href="mailto:mpetrini139@yahoo.it" target="_blank" class="">mpetrini139@yahoo.it</a>&gt;</span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
  

    
  
  <div bgcolor="#FFFFFF" text="#000000" class="">
    Dear NCL helpdesk,<br class="">
    <div class=""> <br class="">
      I have a question re the <b class="">addfiles</b> function. I am using
      this function in order to read data from an ensemble of 101 NetCDF
      files - let's say from <i class="">simulation000</i>.<i class="">nc</i> to <i class="">simulation100</i>.<i class="">nc</i>.
      <br class="">
      <br class="">
      My question is, what is the order the files are read with? Can I
      assume is from 000 to 100 if I have <br class="">
      <br class="">
      
      <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; font-style: normal; font-variant-ligatures: normal; font-variant-position: normal; font-variant-caps: normal; font-variant-numeric: normal; font-variant-alternates: normal; font-variant-east-asian: normal; font-weight: normal; letter-spacing: normal; text-align: left; text-transform: none; word-spacing: 0px; background-color: rgb(255, 255, 255);" class=""> 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" class=""><strong style="margin:0px;padding:0px" class="">systemfunc</strong></a> ("ls ./simulation*.nc")
     fall      = <strong style="margin:0px;padding:0px" class="">addfiles</strong> (all_files, "r") </pre>
      I ask this because I had a missing value error for the last file -
      but <a href="http://simulation100.nc/" target="_blank" class="">simulation100.nc</a> file seems to be ok. Do you have any clue why
      this could happen? <br class="">
      <br class="">
      Thank you for your help,<br class="">
      <br class="">
      Best regards<br class="">
      Michele Petrini<br class="">
      
      <pre cols="72" class="">-- 

***
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" class="">mpetrini139@yahoo.it</a>
Skype: michele.petrins
Mobile: <a href="tel:%2B39%203398367372" value="+393398367372" target="_blank" class="">+39 3398367372</a> 
</pre>
    </div>
  </div>

<br class="">______________________________<wbr class="">_________________<br class="">
ncl-talk mailing list<br class="">
<a href="mailto:ncl-talk@ucar.edu" class="">ncl-talk@ucar.edu</a><br class="">
List instructions, subscriber options, unsubscribe:<br class="">
<a href="http://mailman.ucar.edu/mailman/listinfo/ncl-talk" rel="noreferrer" target="_blank" class="">http://mailman.ucar.edu/<wbr class="">mailman/listinfo/ncl-talk</a><br class="">
<br class=""></blockquote></div><br class=""></div>
<span id="cid:E34DD086-8A1E-417B-8722-7D09E38D021F@eas.albany.edu">&lt;myLib.ncl&gt;</span><span id="cid:E4ED98E8-8486-4E2E-BB93-53EF4BD77B9D@eas.albany.edu">&lt;tst_reorder.ncl&gt;</span>_______________________________________________<br class="">ncl-talk mailing list<br class=""><a href="mailto:ncl-talk@ucar.edu" class="">ncl-talk@ucar.edu</a><br class="">List instructions, subscriber options, unsubscribe:<br class="">http://mailman.ucar.edu/mailman/listinfo/ncl-talk<br class=""></div></blockquote></div><br class=""></div></body></html>