<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
		>
<channel>
	<title>Comments on: Trying Sage mathematical software part II &#8211; Running trials (#2) &#8211; EOF</title>
	<atom:link href="http://xenocoder.wordpress.com/2008/07/24/trying-sage-mathematical-software-part-ii-running-trials-2-eof/feed/" rel="self" type="application/rss+xml" />
	<link>http://xenocoder.wordpress.com/2008/07/24/trying-sage-mathematical-software-part-ii-running-trials-2-eof/</link>
	<description>A place to learn and share OS and programming tips, and generally dissect all things digital.</description>
	<lastBuildDate>Mon, 21 Sep 2009 16:46:38 +0000</lastBuildDate>
	<generator>http://wordpress.com/</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: xenocoder</title>
		<link>http://xenocoder.wordpress.com/2008/07/24/trying-sage-mathematical-software-part-ii-running-trials-2-eof/#comment-396</link>
		<dc:creator>xenocoder</dc:creator>
		<pubDate>Tue, 12 Aug 2008 23:00:58 +0000</pubDate>
		<guid isPermaLink="false">http://xenocoder.wordpress.com/?p=118#comment-396</guid>
		<description>Hi Mike,

Thanks! I appreciate the comment and the notes. I&#039;ll be sure to upgrade Sage when ready and try out your suggestions.</description>
		<content:encoded><![CDATA[<p>Hi Mike,</p>
<p>Thanks! I appreciate the comment and the notes. I&#8217;ll be sure to upgrade Sage when ready and try out your suggestions.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mike Hansen</title>
		<link>http://xenocoder.wordpress.com/2008/07/24/trying-sage-mathematical-software-part-ii-running-trials-2-eof/#comment-395</link>
		<dc:creator>Mike Hansen</dc:creator>
		<pubDate>Sun, 10 Aug 2008 22:27:55 +0000</pubDate>
		<guid isPermaLink="false">http://xenocoder.wordpress.com/?p=118#comment-395</guid>
		<description>Hello,

We&#039;re planning on upgrading scipy, numpy, and matplotlib to the latest releases in Sage 3.1 which should be out next week.

Regarding the speed of numpy.where(z&lt;0) in Sage, this is because numpy and Sage data types don&#039;t always play nicely together yet.

Sage has a light preparser that does things like replace things that would be Python integers with Sage&#039;s Integer class (which is based on GMP).  For example, 

sage: preparse(&quot;numpy.where(z&lt;0)&quot;)
&#039;numpy.where(z&lt;Integer(0))&#039;

I&#039;m not sure where all the time is being spent in the numpy routine.  But, there are a couple possible workarounds:

1) Turn off the Sage preprocessor with

sage: preparser(False)

2) Use the &#039;r&#039; to tell the preparser not to change the Python integer to a Sage one:

sage: preparse(&quot;&quot;numpy.where(z&lt;0r)&quot;)
&#039;numpy.where(z&lt;0)&#039;

3) Replace Integer with int

sage: Integer = int.

The same sort of thing applies with Sage&#039;s RealNumber class and Python&#039;s float.

--Mike</description>
		<content:encoded><![CDATA[<p>Hello,</p>
<p>We&#8217;re planning on upgrading scipy, numpy, and matplotlib to the latest releases in Sage 3.1 which should be out next week.</p>
<p>Regarding the speed of numpy.where(z&lt;0) in Sage, this is because numpy and Sage data types don&#8217;t always play nicely together yet.</p>
<p>Sage has a light preparser that does things like replace things that would be Python integers with Sage&#8217;s Integer class (which is based on GMP).  For example, </p>
<p>sage: preparse(&#8220;numpy.where(z&lt;0)&#8221;)<br />
&#8216;numpy.where(z&lt;Integer(0))&#8217;</p>
<p>I&#8217;m not sure where all the time is being spent in the numpy routine.  But, there are a couple possible workarounds:</p>
<p>1) Turn off the Sage preprocessor with</p>
<p>sage: preparser(False)</p>
<p>2) Use the &#8216;r&#8217; to tell the preparser not to change the Python integer to a Sage one:</p>
<p>sage: preparse(&#8220;&#8221;numpy.where(z&lt;0r)&#8221;)<br />
&#8216;numpy.where(z&lt;0)&#8217;</p>
<p>3) Replace Integer with int</p>
<p>sage: Integer = int.</p>
<p>The same sort of thing applies with Sage&#8217;s RealNumber class and Python&#8217;s float.</p>
<p>&#8211;Mike</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: xenocoder</title>
		<link>http://xenocoder.wordpress.com/2008/07/24/trying-sage-mathematical-software-part-ii-running-trials-2-eof/#comment-384</link>
		<dc:creator>xenocoder</dc:creator>
		<pubDate>Fri, 25 Jul 2008 18:57:34 +0000</pubDate>
		<guid isPermaLink="false">http://xenocoder.wordpress.com/?p=118#comment-384</guid>
		<description>Hey Ryan,

again, thanks for stopping by and your insights. I tried your random number example on sage and straight Numpy and got some interesting results. First off timeit would not work in the sage environment, but a simple 

z = standard_normal( (124,50,151) )
ind = numpy.where(z&lt;0)

takes 20 seconds in Sage 3.0.5 (running Numpy 1.0.4)

while in standard python (running Numpy 1.1.0) that command is instantaneous.

In [31]: timeit z&lt;0
100 loops, best of 3: 3.93 ms per loop

You are also dead on in regards to not using the major features of Sage which would differentiate it from just using Python+Packages. I feel the same way, but wanted to see if Sage would offer a &quot;one stop shopping&quot; where I could load data, run an EOF (matlab/python), run a Generalized Additive model (R), and plot a nice map (GMT) without having to push the data to three places. 

At this point though, the use of an older version of Numpy really seems to be a problem for the applications that I want to run as I cannot use Basemap in matplotlib and the speed issues on indexing arrays.

So I do have Numpy/SciPy/IPython/Basemap setup (no RPy yet) and I think that I will just be content to use these and report that Sage just isn&#039;t for me right now due to the Basemap and speed issues.

I am excited about the possibilities here, and I think that IPython is an amazing IDE to work in (especially ipython -pylab!). I actually *cheated* and used Matlab the other day, and it felt like a step backwards, especially when the Java-based IDE kept freezing on me (coupled with the fact that I *still* can&#039;t run 2008a or 2008b due to my eth0 being diasbled).

Again, thanks for the comments and I&#039;ll try to get some more playtime in with python today.</description>
		<content:encoded><![CDATA[<p>Hey Ryan,</p>
<p>again, thanks for stopping by and your insights. I tried your random number example on sage and straight Numpy and got some interesting results. First off timeit would not work in the sage environment, but a simple </p>
<p>z = standard_normal( (124,50,151) )<br />
ind = numpy.where(z&lt;0)</p>
<p>takes 20 seconds in Sage 3.0.5 (running Numpy 1.0.4)</p>
<p>while in standard python (running Numpy 1.1.0) that command is instantaneous.</p>
<p>In [31]: timeit z&lt;0<br />
100 loops, best of 3: 3.93 ms per loop</p>
<p>You are also dead on in regards to not using the major features of Sage which would differentiate it from just using Python+Packages. I feel the same way, but wanted to see if Sage would offer a &#8220;one stop shopping&#8221; where I could load data, run an EOF (matlab/python), run a Generalized Additive model (R), and plot a nice map (GMT) without having to push the data to three places. </p>
<p>At this point though, the use of an older version of Numpy really seems to be a problem for the applications that I want to run as I cannot use Basemap in matplotlib and the speed issues on indexing arrays.</p>
<p>So I do have Numpy/SciPy/IPython/Basemap setup (no RPy yet) and I think that I will just be content to use these and report that Sage just isn&#8217;t for me right now due to the Basemap and speed issues.</p>
<p>I am excited about the possibilities here, and I think that IPython is an amazing IDE to work in (especially ipython -pylab!). I actually *cheated* and used Matlab the other day, and it felt like a step backwards, especially when the Java-based IDE kept freezing on me (coupled with the fact that I *still* can&#8217;t run 2008a or 2008b due to my eth0 being diasbled).</p>
<p>Again, thanks for the comments and I&#8217;ll try to get some more playtime in with python today.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ryan</title>
		<link>http://xenocoder.wordpress.com/2008/07/24/trying-sage-mathematical-software-part-ii-running-trials-2-eof/#comment-383</link>
		<dc:creator>Ryan</dc:creator>
		<pubDate>Fri, 25 Jul 2008 15:33:55 +0000</pubDate>
		<guid isPermaLink="false">http://xenocoder.wordpress.com/?p=118#comment-383</guid>
		<description>Good to see you&#039;re warming up to Python et al!  

It&#039;s strange that it took so long to index into your matrix . . . that size shouldn&#039;t be too large at all.

In IPython on my 5-yr-old machine it&#039;s near-instantaneous:

    import numpy
    z = numpy.random.standard_normal( (124,50,151) )

    timeit z&lt;0
    # 100 loops, best of 3: 11.4 ms per loop


I wonder if the bottleneck is in loading the NetCDF data . . . maybe it&#039;s doing some funky &quot;lazy loading&quot; and not actually retrieving the data until you do the data&lt;0 test?

Sidenote: it was easier for me to make the transition easier from Matlab syntax when I found out vectorizing tricks like

    data[data&lt;0] = NaN

work with NumPy arrays.


So far it looks like everything you&#039;re doing can be done without needing Sage.  I haven&#039;t installed it to test it, but poking around it seems the advantages of Sage are 

1) its integration with computer algebra systems (http://www.sagemath.org/doc/html/tut/node46.html)

2) Notebooks

If you can get away with not using either of these, then it might be worth a shot to install the Python packages you&#039;d use individually (NumPy, SciPy, matplotlib, basemap).  Then you can always stay on top of the latest versions and bugfixes, and take advantage of high-quality documentation for the separate packages, for example matplotlib&#039;s new docs at http://matplotlib.sourceforge.net/doc/html/users/index.html

-ryan</description>
		<content:encoded><![CDATA[<p>Good to see you&#8217;re warming up to Python et al!  </p>
<p>It&#8217;s strange that it took so long to index into your matrix . . . that size shouldn&#8217;t be too large at all.</p>
<p>In IPython on my 5-yr-old machine it&#8217;s near-instantaneous:</p>
<p>    import numpy<br />
    z = numpy.random.standard_normal( (124,50,151) )</p>
<p>    timeit z&lt;0<br />
    # 100 loops, best of 3: 11.4 ms per loop</p>
<p>I wonder if the bottleneck is in loading the NetCDF data . . . maybe it&#8217;s doing some funky &#8220;lazy loading&#8221; and not actually retrieving the data until you do the data&lt;0 test?</p>
<p>Sidenote: it was easier for me to make the transition easier from Matlab syntax when I found out vectorizing tricks like</p>
<p>    data[data&lt;0] = NaN</p>
<p>work with NumPy arrays.</p>
<p>So far it looks like everything you&#8217;re doing can be done without needing Sage.  I haven&#8217;t installed it to test it, but poking around it seems the advantages of Sage are </p>
<p>1) its integration with computer algebra systems (<a href="http://www.sagemath.org/doc/html/tut/node46.html" rel="nofollow">http://www.sagemath.org/doc/html/tut/node46.html</a>)</p>
<p>2) Notebooks</p>
<p>If you can get away with not using either of these, then it might be worth a shot to install the Python packages you&#8217;d use individually (NumPy, SciPy, matplotlib, basemap).  Then you can always stay on top of the latest versions and bugfixes, and take advantage of high-quality documentation for the separate packages, for example matplotlib&#8217;s new docs at <a href="http://matplotlib.sourceforge.net/doc/html/users/index.html" rel="nofollow">http://matplotlib.sourceforge.net/doc/html/users/index.html</a></p>
<p>-ryan</p>
]]></content:encoded>
	</item>
</channel>
</rss>
