<div dir="ltr"><div>Nothin of which I am aware. You can nt automatically create variables on the left hand side.</div><div>Maybe Adam has an idea.. <br></div><div><br></div><div><span class="gmail-im">pm25_sim_a1    = a1[:]->PM2_5_DRY(:,0,145,79)</span></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Feb 21, 2019 at 3:53 PM Tabish Ansari <<a href="mailto:tabishumaransari@gmail.com">tabishumaransari@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 class="gmail_default" style="font-family:trebuchet ms,sans-serif"><br clear="all"></div><div><div dir="ltr" class="gmail-m_-291027335338115688gmail_signature"><div dir="ltr"><div><div><font size="1"><span style="font-family:tahoma,sans-serif">Tabish U Ansari<br></span></font></div><font size="1"><span style="font-family:tahoma,sans-serif">PhD student, Lancaster Environment Center<br></span></font></div><font size="1"><span style="font-family:tahoma,sans-serif">Lancaster Univeristy<br> <span>Bailrigg</span>, <span>Lancaster</span>, <br><span>LA1 4YW</span>, <span>United Kingdom</span></span></font><br></div></div></div><br><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">---------- Forwarded message ---------<br>From: <b class="gmail_sendername" dir="auto">Tabish Ansari</b> <span dir="ltr"><<a href="mailto:tabishumaransari@gmail.com" target="_blank">tabishumaransari@gmail.com</a>></span><br>Date: Thu, 21 Feb 2019 at 22:52<br>Subject: Re: [ncl-talk] efficient way of reading numbered directories?<br>To: Adam Phillips <<a href="mailto:asphilli@ucar.edu" target="_blank">asphilli@ucar.edu</a>><br>Cc: Dennis Shea <<a href="mailto:shea@ucar.edu" target="_blank">shea@ucar.edu</a>><br></div><br><br><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div style="font-family:trebuchet ms,sans-serif">Hi Adam, Dennis,<br></div><div style="font-family:trebuchet ms,sans-serif"><br></div><div style="font-family:trebuchet ms,sans-serif">Thanks very much.</div><div style="font-family:trebuchet ms,sans-serif">But this only solves part of the problem that is reading in the directories.</div><div style="font-family:trebuchet ms,sans-serif"><br></div><div style="font-family:trebuchet ms,sans-serif">I still have these other lines which have to be repeated 60 times with changing numbers as part of variable names.</div><div style="font-family:trebuchet ms,sans-serif"><br></div><div style="font-family:trebuchet ms,sans-serif">FILES1 = systemfunc (" ls -1 " + DATADir1 + "subset_d03_2014-* ")<br>FILES2 = systemfunc (" ls -1 " + DATADir2 + "subset_d03_2014-* ")<br>FILES3 = systemfunc (" ls -1 " + DATADir3 + "subset_d03_2014-* ")<br>FILES4 = systemfunc (" ls -1 " + DATADir4 + "subset_d03_2014-* ")<br>FILES5 = systemfunc (" ls -1 " + DATADir5 + "subset_d03_2014-* ")<br>FILES6 = systemfunc (" ls -1 " + DATADir6 + "subset_d03_2014-* ")<br>FILES7 = systemfunc (" ls -1 " + DATADir7 + "subset_d03_2014-* ")<br></div><div style="font-family:trebuchet ms,sans-serif">..... and so on up to FILES60</div><div style="font-family:trebuchet ms,sans-serif"><br></div><div style="font-family:trebuchet ms,sans-serif">a1 = addfiles(FILES1,"r")<br>a2 = addfiles(FILES2,"r")<br>a3 = addfiles(FILES3,"r")<br>a4 = addfiles(FILES4,"r")<br>a5 = addfiles(FILES5,"r")<br>a6 = addfiles(FILES6,"r")<br>a7 = addfiles(FILES7,"r")<br>a8 = addfiles(FILES8,"r")<br></div><div style="font-family:trebuchet ms,sans-serif">.... and so on up to a60</div><div style="font-family:trebuchet ms,sans-serif"><br></div><div style="font-family:trebuchet ms,sans-serif">pm25_sim_a1    = a1[:]->PM2_5_DRY(:,0,145,79)<br>pm25_sim_a2    = a2[:]->PM2_5_DRY(:,0,145,79)<br>pm25_sim_a3    = a3[:]->PM2_5_DRY(:,0,145,79)<br>pm25_sim_a4    = a4[:]->PM2_5_DRY(:,0,145,79)<br>pm25_sim_a5    = a5[:]->PM2_5_DRY(:,0,145,79)<br>pm25_sim_a6    = a6[:]->PM2_5_DRY(:,0,145,79)<br>pm25_sim_a7    = a7[:]->PM2_5_DRY(:,0,145,79)<br></div><div style="font-family:trebuchet ms,sans-serif">..... and so on up to <br></div><div style="font-family:trebuchet ms,sans-serif">pm25_sim_a60    = a60[:]->PM2_5_DRY(:,0,145,79)<br></div><div style="font-family:trebuchet ms,sans-serif"><br></div><div style="font-family:trebuchet ms,sans-serif">Further inside a loop...<br> pm25_sim_a1    = pm25_sim_a1 + a1[:]->PM2_5_DRY(:,0,J,I)<br> pm25_sim_a2    = pm25_sim_a2 + a2[:]->PM2_5_DRY(:,0,J,I)<br> pm25_sim_a3    = pm25_sim_a3 + a3[:]->PM2_5_DRY(:,0,J,I)<br> pm25_sim_a4    = pm25_sim_a4 + a4[:]->PM2_5_DRY(:,0,J,I)<br> pm25_sim_a5    = pm25_sim_a5 + a5[:]->PM2_5_DRY(:,0,J,I)<br> pm25_sim_a6    = pm25_sim_a6 + a6[:]->PM2_5_DRY(:,0,J,I)<br></div><div style="font-family:trebuchet ms,sans-serif">and so on... up to<br></div><div style="font-family:trebuchet ms,sans-serif">pm25_sim_a60    = pm25_sim_a60 + a60[:]->PM2_5_DRY(:,0,J,I)</div><div style="font-family:trebuchet ms,sans-serif"><br></div><div style="font-family:trebuchet ms,sans-serif">pm25_sim_a1 = pm25_sim_a1 / 12.0<br>pm25_sim_a2 = pm25_sim_a2 / 12.0<br>pm25_sim_a3 = pm25_sim_a3 / 12.0<br>pm25_sim_a4 = pm25_sim_a4 / 12.0<br>pm25_sim_a5 = pm25_sim_a5 / 12.0<br>pm25_sim_a6 = pm25_sim_a6 / 12.0<br>pm25_sim_a7 = pm25_sim_a7 / 12.0<br></div><div style="font-family:trebuchet ms,sans-serif">... and so on up to<br></div><span style="font-family:trebuchet ms,sans-serif">pm25_sim_a6<span class="gmail_default">0</span> = pm25_sim_a6<span class="gmail_default">0</span> / 12.0</span></div><div dir="ltr"><br></div><div dir="ltr"><br><div style="font-family:trebuchet ms,sans-serif">Is there a way to deal with that in a loop?</div><div style="font-family:trebuchet ms,sans-serif"><br></div><div style="font-family:trebuchet ms,sans-serif">Cheers,</div><div style="font-family:trebuchet ms,sans-serif"><br></div><div style="font-family:trebuchet ms,sans-serif">Tabish<br></div><div style="font-family:trebuchet ms,sans-serif"><br></div><div><div dir="ltr" class="gmail-m_-291027335338115688m_175957506788029673gmail_signature"><div dir="ltr"><div><div><font size="1"><span style="font-family:tahoma,sans-serif">Tabish U Ansari<br></span></font></div><font size="1"><span style="font-family:tahoma,sans-serif">PhD student, Lancaster Environment Center<br></span></font></div><font size="1"><span style="font-family:tahoma,sans-serif">Lancaster Univeristy<br> <span>Bailrigg</span>, <span>Lancaster</span>, <br><span>LA1 4YW</span>, <span>United Kingdom</span></span></font><br></div></div></div><br></div></div></div></div></div></div></div></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, 21 Feb 2019 at 22:39, Adam Phillips <<a href="mailto:asphilli@ucar.edu" target="_blank">asphilli@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">Dennis: Agreed, your way is more elegant. </div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Feb 21, 2019 at 3:37 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 dir="ltr"><div>offline!</div><div><br></div><div>I was just typing when I saw Adam's response.</div><div><br></div><div>Originally, I was going to use a 'do loop' but then <br></div><div><br></div><div> N = 60<br> dirRoot  = "/mnt/rasher/"+N+"sensruns/run" +<b>ispan</b>(1,N,1)+"/"<br> print(dirRoot)<br></div></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Feb 21, 2019 at 3:30 PM Adam Phillips <<a href="mailto:asphilli@ucar.edu" target="_blank">asphilli@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 dir="ltr"><div dir="ltr">Hi Tabish,<div>Yes, a do loop could be used:</div><div><br></div><div>DATADir =  "/mnt/rasher/60sensruns/run"</div><div>do gg = 1,60</div><div>     FILES1 = systemfunc (" ls -1 " + DATADir +gg+ "subset_d03_2014-* ")</div><div>     a1 = addfiles(FILES1,"r")    <br></div><div>.....</div><div><br></div><div>Also note, you could set up a string array that houses the directories using a do loop</div><div>DATADir = new(60,string)</div><div>do gg = 1,dimsizes(DATADir)-1</div><div>     DATADir(gg-1) = "/mnt/rasher/60sensruns/run"+gg</div><div>end do</div><div><br></div><div>Adam</div></div></div></div></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Feb 21, 2019 at 1:15 PM Tabish Ansari <<a href="mailto:tabishumaransari@gmail.com" target="_blank">tabishumaransari@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"><div dir="ltr"><div style="font-family:"trebuchet ms",sans-serif">Hi</div><div style="font-family:"trebuchet ms",sans-serif"><br></div><div style="font-family:"trebuchet ms",sans-serif">I am currently reading in files in a very inefficient way from 60 directories:</div><div style="font-family:"trebuchet ms",sans-serif"><br></div><div style="font-family:"trebuchet ms",sans-serif">DATADir1 = "/mnt/rasher/60sensruns/run1/"<br>DATADir2 = "/mnt/rasher/60sensruns/run2/"<br>DATADir3 = "/mnt/rasher/60sensruns/run3/"<br>DATADir4 = "/mnt/rasher/60sensruns/run4/"<br>DATADir5 = "/mnt/rasher/60sensruns/run5/"<br>DATADir6 = "/mnt/rasher/60sensruns/run6/"<br>DATADir7 = "/mnt/rasher/60sensruns/run7/"<br>DATADir8 = "/mnt/rasher/60sensruns/run8/"<br>DATADir9 = "/mnt/rasher/60sensruns/run9/"<br>DATADir10 = "/mnt/rasher/60sensruns/run10/"<br>DATADir11 = "/mnt/rasher/60sensruns/run11/"<br>DATADir12 = "/mnt/rasher/60sensruns/run12/"<br>DATADir13 = "/mnt/rasher/60sensruns/run13/"<br>DATADir14 = "/mnt/rasher/60sensruns/run14/"<br>DATADir15 = "/mnt/rasher/60sensruns/run15/"<br>DATADir16 = "/mnt/rasher/60sensruns/run16/"<br>DATADir17 = "/mnt/rasher/60sensruns/run17/"<br>DATADir18 = "/mnt/rasher/60sensruns/run18/"<br>DATADir19 = "/mnt/rasher/60sensruns/run19/"<br>DATADir20 = "/mnt/rasher/60sensruns/run20/"<br>DATADir21 = "/mnt/rasher/60sensruns/run21/"<br>DATADir22 = "/mnt/rasher/60sensruns/run22/"<br>DATADir23 = "/mnt/rasher/60sensruns/run23/"<br>DATADir24 = "/mnt/rasher/60sensruns/run24/"<br>DATADir25 = "/mnt/rasher/60sensruns/run25/"<br>DATADir26 = "/mnt/rasher/60sensruns/run26/"<br>DATADir27 = "/mnt/rasher/60sensruns/run27/"<br>DATADir28 = "/mnt/rasher/60sensruns/run28/"<br>DATADir29 = "/mnt/rasher/60sensruns/run29/"<br>DATADir30 = "/mnt/rasher/60sensruns/run30/"<br>DATADir31 = "/mnt/rasher/60sensruns/run31/"<br>DATADir32 = "/mnt/rasher/60sensruns/run32/"<br>DATADir33 = "/mnt/rasher/60sensruns/run33/"<br>DATADir34 = "/mnt/rasher/60sensruns/run34/"<br>DATADir35 = "/mnt/rasher/60sensruns/run35/"<br>DATADir36 = "/mnt/rasher/60sensruns/run36/"<br>DATADir37 = "/mnt/rasher/60sensruns/run37/"<br>DATADir38 = "/mnt/rasher/60sensruns/run38/"<br>DATADir39 = "/mnt/rasher/60sensruns/run39/"<br>DATADir40 = "/mnt/rasher/60sensruns/run40/"<br>DATADir41 = "/mnt/rasher/60sensruns/run41/"<br>DATADir42 = "/mnt/rasher/60sensruns/run42/"<br>DATADir43 = "/mnt/rasher/60sensruns/run43/"<br>DATADir44 = "/mnt/rasher/60sensruns/run44/"<br>DATADir45 = "/mnt/rasher/60sensruns/run45/"<br>DATADir46 = "/mnt/rasher/60sensruns/run46/"<br>DATADir47 = "/mnt/rasher/60sensruns/run47/"<br>DATADir48 = "/mnt/rasher/60sensruns/run48/"<br>DATADir49 = "/mnt/rasher/60sensruns/run49/"<br>DATADir50 = "/mnt/rasher/60sensruns/run50/"<br>DATADir51 = "/mnt/rasher/60sensruns/run51/"<br>DATADir52 = "/mnt/rasher/60sensruns/run52/"<br>DATADir53 = "/mnt/rasher/60sensruns/run53/"<br>DATADir54 = "/mnt/rasher/60sensruns/run54/"<br>DATADir55 = "/mnt/rasher/60sensruns/run55/"<br>DATADir56 = "/mnt/rasher/60sensruns/run56/"<br>DATADir57 = "/mnt/rasher/60sensruns/run57/"<br>DATADir58 = "/mnt/rasher/60sensruns/run58/"<br>DATADir59 = "/mnt/rasher/60sensruns/run59/"<br>DATADir60 = "/mnt/rasher/60sensruns/run60/"<br><br>For each directory I will further have to do this:</div><div style="font-family:"trebuchet ms",sans-serif">FILES1 = systemfunc (" ls -1 " + DATADir1 + "subset_d03_2014-* ")<br>a1 = addfiles(FILES1,"r")<br>pm25_sim_a1    = a1[:]->PM2_5_DRY(:,0,145,79)<br></div><div style="font-family:"trebuchet ms",sans-serif"><br></div><div style="font-family:"trebuchet ms",sans-serif">(I will have to type this another 59 times for the other directories)<br></div><div style="font-family:"trebuchet ms",sans-serif"><br></div><div style="font-family:"trebuchet ms",sans-serif">Is there a way to do this more efficiently perhaps in a loop?</div><div style="font-family:"trebuchet ms",sans-serif"><br></div><div style="font-family:"trebuchet ms",sans-serif">Thanks</div><div style="font-family:"trebuchet ms",sans-serif"><br></div><div style="font-family:"trebuchet ms",sans-serif">Tabish<br></div><div style="font-family:"trebuchet ms",sans-serif"><br clear="all"></div><div><div dir="ltr" class="gmail-m_-291027335338115688m_175957506788029673gmail-m_-3471649389014677179gmail-m_4532781125482650719gmail-m_-4468165492817127067gmail-m_-6874606385713140125gmail_signature"><div dir="ltr"><div><div><font size="1"><span style="font-family:tahoma,sans-serif">Tabish U Ansari<br></span></font></div><font size="1"><span style="font-family:tahoma,sans-serif">PhD student, Lancaster Environment Center<br></span></font></div><font size="1"><span style="font-family:tahoma,sans-serif">Lancaster Univeristy<br> <span>Bailrigg</span>, <span>Lancaster</span>, <br><span>LA1 4YW</span>, <span>United Kingdom</span></span></font><br></div></div></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><br>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail-m_-291027335338115688m_175957506788029673gmail-m_-3471649389014677179gmail-m_4532781125482650719gmail-m_-4468165492817127067gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div><div><span><font color="#888888">Adam Phillips <br></font></span></div><span><font color="#888888">Associate Scientist,  </font></span><span><font color="#888888">Climate and Global Dynamics Laboratory, NCAR<br></font></span></div></div><div><span><font color="#888888"><a href="http://www.cgd.ucar.edu/staff/asphilli/" target="_blank">www.cgd.ucar.edu/staff/asphilli/</a>   </font></span><span><font color="#888888">303-497-1726 </font></span></div><span><font color="#888888"></font></span><div><div><span><font color="#888888"><br></font></span><div><span><font color="#888888"><a href="http://www.cgd.ucar.edu/staff/asphilli" target="_blank"></a></font></span></div></div></div></div></div></div></div></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><br>
</blockquote></div>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail-m_-291027335338115688m_175957506788029673gmail-m_-3471649389014677179gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div><div><span><font color="#888888">Adam Phillips <br></font></span></div><span><font color="#888888">Associate Scientist,  </font></span><span><font color="#888888">Climate and Global Dynamics Laboratory, NCAR<br></font></span></div></div><div><span><font color="#888888"><a href="http://www.cgd.ucar.edu/staff/asphilli/" target="_blank">www.cgd.ucar.edu/staff/asphilli/</a>   </font></span><span><font color="#888888">303-497-1726 </font></span></div><span><font color="#888888"></font></span><div><div><span><font color="#888888"><br></font></span><div><span><font color="#888888"><a href="http://www.cgd.ucar.edu/staff/asphilli" target="_blank"></a></font></span></div></div></div></div></div></div></div></div></div></div></div>
</blockquote></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><br>
</blockquote></div>