<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Script won't stop running in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/script-won-t-stop-running/m-p/590051#M46263</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Ditto the other answers, plus you don't really need the with statement at all, since loadtxt accepts either a file object or filename as the first arg.&amp;nbsp; I'd feed it the filename and see if that doesn't help.&amp;nbsp; And there's some code somewhere that calls this function that we haven't seen.&amp;nbsp; Maybe your issue is that code, instead of this code.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Mike&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 24 Jul 2012 21:55:49 GMT</pubDate>
    <dc:creator>MikeHunter</dc:creator>
    <dc:date>2012-07-24T21:55:49Z</dc:date>
    <item>
      <title>Script won't stop running</title>
      <link>https://community.esri.com/t5/python-questions/script-won-t-stop-running/m-p/590048#M46260</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I have created a function which plots data.&amp;nbsp; The problem is when I run the script it doesn't stop.&amp;nbsp; I know it is probably a really easy fix.&amp;nbsp; I would really appreciate some help!&amp;nbsp; Thanks!!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;
import numpy as np
import matplotlib.pyplot as plt
import datetime as DT

def plotGridmetOneDay(GcmVar,GcmYear,LastYear,output):
&amp;nbsp;&amp;nbsp;&amp;nbsp; with open(output+"/Climate.txt") as f:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; data = np.loadtxt(f, delimiter=',', skiprows=1,
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; dtype={'names': ('date', 'count'),'formats': ('S10', 'i4')} )

&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; x = [DT.datetime.strptime(key,"%j/%Y") for (key, value) in data ]
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; y = [value for (key, value) in data]

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; fig = plt.figure()
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ax = fig.add_subplot(111)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ax.grid()

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; fig.autofmt_xdate()

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; plt.plot(x,y)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; plt.xlabel('Date')
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; plt.ylabel(str(GcmVar))
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; plt.title(str(GcmVar)+" "+str(GcmYear)+"-"+str(LastYear))
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; plt.savefig(output+"/ClimateMap.png",bbox_inches=0)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; plt.show()
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; f.close()
&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 24 Jul 2012 18:51:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/script-won-t-stop-running/m-p/590048#M46260</guid>
      <dc:creator>StephenFricke</dc:creator>
      <dc:date>2012-07-24T18:51:48Z</dc:date>
    </item>
    <item>
      <title>Re: Script won't stop running</title>
      <link>https://community.esri.com/t5/python-questions/script-won-t-stop-running/m-p/590049#M46261</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;You shouldn't need to manually close your file if you open it with the "with" statement. Try removing the &lt;/SPAN&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_macro_code jive_text_macro"&gt;f.close()&lt;/PRE&gt;&lt;SPAN&gt; and see what happens. Are you sure whatever reference you are using to this function isn't the problem?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 24 Jul 2012 19:50:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/script-won-t-stop-running/m-p/590049#M46261</guid>
      <dc:creator>MathewCoyle</dc:creator>
      <dc:date>2012-07-24T19:50:00Z</dc:date>
    </item>
    <item>
      <title>Re: Script won't stop running</title>
      <link>https://community.esri.com/t5/python-questions/script-won-t-stop-running/m-p/590050#M46262</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Also get rid of the &lt;/SPAN&gt;&lt;SPAN style="font-family:Courier New;"&gt;plt.show()&lt;/SPAN&gt;&lt;SPAN&gt; and see if that helps.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 24 Jul 2012 20:37:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/script-won-t-stop-running/m-p/590050#M46262</guid>
      <dc:creator>JasonScheirer</dc:creator>
      <dc:date>2012-07-24T20:37:26Z</dc:date>
    </item>
    <item>
      <title>Re: Script won't stop running</title>
      <link>https://community.esri.com/t5/python-questions/script-won-t-stop-running/m-p/590051#M46263</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Ditto the other answers, plus you don't really need the with statement at all, since loadtxt accepts either a file object or filename as the first arg.&amp;nbsp; I'd feed it the filename and see if that doesn't help.&amp;nbsp; And there's some code somewhere that calls this function that we haven't seen.&amp;nbsp; Maybe your issue is that code, instead of this code.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Mike&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 24 Jul 2012 21:55:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/script-won-t-stop-running/m-p/590051#M46263</guid>
      <dc:creator>MikeHunter</dc:creator>
      <dc:date>2012-07-24T21:55:49Z</dc:date>
    </item>
    <item>
      <title>Re: Script won't stop running</title>
      <link>https://community.esri.com/t5/python-questions/script-won-t-stop-running/m-p/590052#M46264</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thanks for the suggestions everyone.&amp;nbsp; It turns out the the plt.show() was causing the issue.&amp;nbsp; That is somewhat of a bummer because the alternative is to make the graph I am creating show up in the arcmap window, and it looks really bad with horrible resolution.&amp;nbsp; Does anyone know how to make .png or .jpg look sharper in the arcmap window?&amp;nbsp; Thanks!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 25 Jul 2012 18:23:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/script-won-t-stop-running/m-p/590052#M46264</guid>
      <dc:creator>StephenFricke</dc:creator>
      <dc:date>2012-07-25T18:23:46Z</dc:date>
    </item>
    <item>
      <title>Re: Script won't stop running</title>
      <link>https://community.esri.com/t5/python-questions/script-won-t-stop-running/m-p/590053#M46265</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Try using &lt;/SPAN&gt;&lt;SPAN style="font-family:Courier New;"&gt;os.startfile(output+"/ClimateMap.png")&lt;/SPAN&gt;&lt;SPAN&gt; instead.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 25 Jul 2012 20:02:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/script-won-t-stop-running/m-p/590053#M46265</guid>
      <dc:creator>JasonScheirer</dc:creator>
      <dc:date>2012-07-25T20:02:21Z</dc:date>
    </item>
  </channel>
</rss>

