<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>AstroBetter &#187; python</title>
	<atom:link href="http://www.astrobetter.com/category/python/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.astrobetter.com</link>
	<description>Tips and Tricks for Professional Astronomers</description>
	<lastBuildDate>Mon, 26 Jul 2010 13:28:50 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Manipulating and Viewing FITS Files in Python with pyds9</title>
		<link>http://www.astrobetter.com/manipulating-and-viewing-fits-files-in-python-with-pyds9/</link>
		<comments>http://www.astrobetter.com/manipulating-and-viewing-fits-files-in-python-with-pyds9/#comments</comments>
		<pubDate>Wed, 14 Jul 2010 12:00:07 +0000</pubDate>
		<dc:creator>Jessica</dc:creator>
				<category><![CDATA[analysis]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[ds9]]></category>
		<category><![CDATA[figures]]></category>
		<category><![CDATA[pyds9]]></category>

		<guid isPermaLink="false">http://www.astrobetter.com/?p=2262</guid>
		<description><![CDATA[For anyone who uses python and ds9 to visualize their FITS files, I think pyds9 is now a must-have. It is officially written and developed through SAOImage ds9 so it will be supported for the long haul. Here are the primary links to get going:

TARball for installation: Source
Documentation for installation and use: Docs

The documentation is [...]]]></description>
			<content:encoded><![CDATA[<p></p><p><a href="http://www.astrobetter.com/wp-content/uploads/2010/07/Picture-3.png"><img class="alignright size-medium wp-image-2631" title="Picture 3" src="http://www.astrobetter.com/wp-content/uploads/2010/07/Picture-3-300x217.png" alt="" width="300" height="217" /></a>For anyone who uses python and ds9 to visualize their FITS files, I think <a title="pyds9" href="http://hea-www.harvard.edu/saord/ds9/pyds9/">pyds9</a> is now a must-have. It is officially written and developed through SAOImage ds9 so it will be supported for the long haul. Here are the primary links to get going:</p>
<ul>
<li>TARball for installation: <a href="http://hea-www.harvard.edu/saord/download/ds9/python/pyds9-1.0.tar.gz">Source</a></li>
<li>Documentation for installation and use: <a title="Docs" href="http://hea-www.harvard.edu/saord/ds9/pyds9/">Docs</a></li>
</ul>
<p>The documentation is pretty basic so I put together a very small tutorial of a way I might typically use it. Most of the controls work through the XPA interface, which seems very flexible, if a little tricky to figure out exactly how to make it work for specific use-cases. If you have samples of how you use pyds9 or ds9 xpa, post them in the comments or on this <a href="http://www.astrobetter.com/wiki/tiki-index.php?page=pyds9+Tutorials">wiki page</a>.</p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;"><span style="color: #ff7700;font-weight:bold;">from</span> scipy <span style="color: #ff7700;font-weight:bold;">import</span> stats
<span style="color: #ff7700;font-weight:bold;">import</span> numpy <span style="color: #ff7700;font-weight:bold;">as</span> np
<span style="color: #ff7700;font-weight:bold;">import</span> ds9
&nbsp;
<span style="color: #808080; font-style: italic;"># Make a 2D gaussian image that is stored in a 2D numpy array</span>
x = np.<span style="color: black;">arange</span><span style="color: black;">&#40;</span>-<span style="color: #ff4500;">3</span>, <span style="color: #ff4500;">3</span>, <span style="color: #ff4500;">0.1</span><span style="color: black;">&#41;</span>
xx, yy = np.<span style="color: black;">meshgrid</span><span style="color: black;">&#40;</span>x, x<span style="color: black;">&#41;</span>
gauss2d = stats.<span style="color: black;">norm</span>.<span style="color: black;">pdf</span><span style="color: black;">&#40;</span>xx<span style="color: black;">&#41;</span> <span style="color: #66cc66;">*</span> stats.<span style="color: black;">norm</span>.<span style="color: black;">pdf</span><span style="color: black;">&#40;</span>yy<span style="color: black;">&#41;</span>
&nbsp;
<span style="color: #808080; font-style: italic;"># Now open ds9 (this assumes no ds9 instance is yet running)</span>
d = ds9.<span style="color: black;">ds9</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
&nbsp;
<span style="color: #808080; font-style: italic;"># Load up our 2D gaussian</span>
d.<span style="color: black;">set_np2arr</span><span style="color: black;">&#40;</span>gauss2d<span style="color: black;">&#41;</span>
&nbsp;
<span style="color: #808080; font-style: italic;"># Zoom to fit</span>
d.<span style="color: #008000;">set</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'zoom to fit'</span><span style="color: black;">&#41;</span>
&nbsp;
<span style="color: #808080; font-style: italic;"># Change the colormap and scaling</span>
d.<span style="color: #008000;">set</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'cmap bb'</span><span style="color: black;">&#41;</span>
d.<span style="color: #008000;">set</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'scale log'</span><span style="color: black;">&#41;</span>
&nbsp;
<span style="color: #808080; font-style: italic;"># Add a label</span>
d.<span style="color: #008000;">set</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'regions command {text 30 20 #text=&quot;Fun with pyds9&quot; font=&quot;times 18 bold&quot;}'</span><span style="color: black;">&#41;</span>
&nbsp;
<span style="color: #808080; font-style: italic;"># Now you can play in ds9 to your heart's content.</span>
<span style="color: #808080; font-style: italic;"># Check back to see what the current color scale is.</span>
<span style="color: #ff7700;font-weight:bold;">print</span> d.<span style="color: black;">get</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'scale'</span><span style="color: black;">&#41;</span>
&nbsp;
<span style="color: #808080; font-style: italic;"># Finally, save your completed image (including regions or labels)</span>
d.<span style="color: #008000;">set</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'saveimage png my_pyds9_img.png'</span><span style="color: black;">&#41;</span></pre></div></div>




Share This:


	<a rel="nofollow"  href="http://www.printfriendly.com/print?url=http%3A%2F%2Fwww.astrobetter.com%2Fmanipulating-and-viewing-fits-files-in-python-with-pyds9%2F&amp;partner=sociable" title="Print"><img src="http://www.astrobetter.com/wp-content/plugins/sociable/images/printfriendly.png" title="Print" alt="Print" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.astrobetter.com%2Fmanipulating-and-viewing-fits-files-in-python-with-pyds9%2F&amp;title=Manipulating%20and%20Viewing%20FITS%20Files%20in%20Python%20with%20pyds9&amp;bodytext=For%20anyone%20who%20uses%20python%20and%20ds9%20to%20visualize%20their%20FITS%20files%2C%20I%20think%20pyds9%20is%20now%20a%20must-have.%20It%20is%20officially%20written%20and%20developed%20through%20SAOImage%20ds9%20so%20it%20will%20be%20supported%20for%20the%20long%20haul.%20Here%20are%20the%20primary%20links%20to%20get%20going%3A%0D%0A%0D%0A%09TA" title="Digg"><img src="http://www.astrobetter.com/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://delicious.com/post?url=http%3A%2F%2Fwww.astrobetter.com%2Fmanipulating-and-viewing-fits-files-in-python-with-pyds9%2F&amp;title=Manipulating%20and%20Viewing%20FITS%20Files%20in%20Python%20with%20pyds9&amp;notes=For%20anyone%20who%20uses%20python%20and%20ds9%20to%20visualize%20their%20FITS%20files%2C%20I%20think%20pyds9%20is%20now%20a%20must-have.%20It%20is%20officially%20written%20and%20developed%20through%20SAOImage%20ds9%20so%20it%20will%20be%20supported%20for%20the%20long%20haul.%20Here%20are%20the%20primary%20links%20to%20get%20going%3A%0D%0A%0D%0A%09TA" title="del.icio.us"><img src="http://www.astrobetter.com/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.astrobetter.com%2Fmanipulating-and-viewing-fits-files-in-python-with-pyds9%2F&amp;t=Manipulating%20and%20Viewing%20FITS%20Files%20in%20Python%20with%20pyds9" title="Facebook"><img src="http://www.astrobetter.com/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fwww.astrobetter.com%2Fmanipulating-and-viewing-fits-files-in-python-with-pyds9%2F&amp;title=Manipulating%20and%20Viewing%20FITS%20Files%20in%20Python%20with%20pyds9&amp;annotation=For%20anyone%20who%20uses%20python%20and%20ds9%20to%20visualize%20their%20FITS%20files%2C%20I%20think%20pyds9%20is%20now%20a%20must-have.%20It%20is%20officially%20written%20and%20developed%20through%20SAOImage%20ds9%20so%20it%20will%20be%20supported%20for%20the%20long%20haul.%20Here%20are%20the%20primary%20links%20to%20get%20going%3A%0D%0A%0D%0A%09TA" title="Google Bookmarks"><img src="http://www.astrobetter.com/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="mailto:?subject=Manipulating%20and%20Viewing%20FITS%20Files%20in%20Python%20with%20pyds9&amp;body=http%3A%2F%2Fwww.astrobetter.com%2Fmanipulating-and-viewing-fits-files-in-python-with-pyds9%2F" title="email"><img src="http://www.astrobetter.com/wp-content/plugins/sociable/images/email_link.png" title="email" alt="email" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://twitter.com/home?status=Manipulating%20and%20Viewing%20FITS%20Files%20in%20Python%20with%20pyds9%20-%20http%3A%2F%2Fwww.astrobetter.com%2Fmanipulating-and-viewing-fits-files-in-python-with-pyds9%2F" title="Twitter"><img src="http://www.astrobetter.com/wp-content/plugins/sociable/images/twitter.png" title="Twitter" alt="Twitter" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.printfriendly.com/print?url=http%3A%2F%2Fwww.astrobetter.com%2Fmanipulating-and-viewing-fits-files-in-python-with-pyds9%2F&amp;partner=sociable" title="PDF"><img src="http://www.astrobetter.com/wp-content/plugins/sociable/images/pdf.png" title="PDF" alt="PDF" class="sociable-hovers" /></a>


<br/><br/><img src="http://www.astrobetter.com/?ak_action=api_record_view&id=2262&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://www.astrobetter.com/manipulating-and-viewing-fits-files-in-python-with-pyds9/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Interpolation and Integration in Python</title>
		<link>http://www.astrobetter.com/interpolation-and-integration-in-python/</link>
		<comments>http://www.astrobetter.com/interpolation-and-integration-in-python/#comments</comments>
		<pubDate>Mon, 14 Jun 2010 12:02:51 +0000</pubDate>
		<dc:creator>Jessica</dc:creator>
				<category><![CDATA[analysis]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[interpolation]]></category>

		<guid isPermaLink="false">http://www.astrobetter.com/?p=2146</guid>
		<description><![CDATA[Interpolation
Interpolation is a used for many astronomical applications. Interpolation is required to combine sub-pixel dithered images or spectroscopy, sample grids of stellar evolution or stellar atmosphere models, calculate extinction from observed extinction curves, and many many more applications. The scipy.interpolate package in python has some nice built-in interpolation functions and I have gathered a few [...]]]></description>
			<content:encoded><![CDATA[<p></p><h2>Interpolation</h2>
<div id="attachment_2383" class="wp-caption alignright" style="width: 280px">
	<a href="http://www.astrobetter.com/wp-content/uploads/2010/06/interpolation.png"><img class="size-thumbnail wp-image-2383" style="padding:0px;" title="interpolation_figure" src="http://www.astrobetter.com/wp-content/uploads/2010/06/interpolation.png" alt="" width="280" /></a>
	<p class="wp-caption-text">Interpolation: Filter profiles may be reported as transmission vs. wavelength data points. To resample the filter profiles to a different (regularly spaced) wavelength grid, I used scipy&#39;s interpolation package.</p>
</div>
<p>Interpolation is a used for many astronomical applications. Interpolation is required to combine sub-pixel dithered images or spectroscopy, sample grids of stellar evolution or stellar atmosphere models, calculate extinction from observed extinction curves, and many many more applications. The <a href="http://docs.scipy.org/doc/scipy/reference/interpolate.html">scipy.interpolate</a> package in python has some nice built-in interpolation functions and I have gathered a few links describing the capabilities (in addition to the documentation). I would recommend using <a href="http://docs.scipy.org/doc/scipy/reference/generated/scipy.interpolate.splrep.html">splrep</a>/<a href="http://docs.scipy.org/doc/scipy/reference/generated/scipy.interpolate.splev.html">splev</a> over <a href="http://docs.scipy.org/doc/scipy/reference/generated/scipy.interpolate.interp1d.html#scipy.interpolate.interp1d">interp1d</a> for speed.</p>
<ul>
<li><a href="http://www.scipy.org/Cookbook/Interpolation">Scipy cookbook</a> on interpolation</li>
<li>A <a href="http://www.slideshare.net/enthought/interpolation-with-scipy-and-numpy">slideshow</a> outlining the interpolation capabilities in Scipy</li>
<li>A <a href="http://mail.scipy.org/pipermail/scipy-user/2010-February/024115.html">thread</a> explaining terms in spline interpolation/smoothing</li>
</ul>
<p><span id="more-2146"></span></p>
<h2>Integration</h2>
<p>Within Scipy, there is an integrate package with several different functions that perform definite or indefinite integrals. I have only played with these briefly; however, I tested both the <kbd>scipy.integrate.quad()</kbd> and <kbd>scipy.integrate.romberg()</kbd> functions. These all work in roughly the same way by taking a user-defined function, and the upper and lower boundaries of the integral. Here is a brief example:</p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;"><span style="color: #ff7700;font-weight:bold;">from</span> scipy <span style="color: #ff7700;font-weight:bold;">import</span> integrate
<span style="color: #ff7700;font-weight:bold;">def</span> myfunc<span style="color: black;">&#40;</span>x, a, b<span style="color: black;">&#41;</span>:
<span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: black;">&#40;</span>x<span style="color: #66cc66;">**</span>b<span style="color: black;">&#41;</span> + a
&nbsp;
<span style="color: #808080; font-style: italic;"># These are the arguments that will be passed as a and b to myfunc()</span>
args = <span style="color: black;">&#40;</span><span style="color: #ff4500;">1.0</span>, -<span style="color: #ff4500;">2.0</span><span style="color: black;">&#41;</span>
&nbsp;
<span style="color: #808080; font-style: italic;"># Integrate myfunc() from 0.5 to 1.5</span>
results = integrate.<span style="color: black;">quad</span><span style="color: black;">&#40;</span>myfunc, <span style="color: #ff4500;">0.5</span>, <span style="color: #ff4500;">1.5</span>, args<span style="color: black;">&#41;</span>
<span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">'Integral = '</span>, results<span style="color: black;">&#91;</span><span style="color: #ff4500;">0</span><span style="color: black;">&#93;</span>, <span style="color: #483d8b;">' with error = '</span>, results<span style="color: black;">&#91;</span><span style="color: #ff4500;">1</span><span style="color: black;">&#93;</span></pre></div></div>

<p>The well-established Fortran QUADPACK integration code lies underneath <kbd>quad()</kbd> while <kbd>romberg()</kbd> appears to be a python only implementation (??). While I would much rather use <kbd>quad()</kbd> for its robustness, it only supports user-functions that accept single value floats; while <kbd>romberg()</kbd> will pass in vectors of values. For some of my applications, <kbd>myfunc()</kbd> is computationally intensive, so there is an order of magnitude speed gain by having a properly vectorized <kbd>myfunc()</kbd> used in vector-form by the integration code. Only with <kbd>romberg()</kbd> have I matched the speed of IDL&#8217;s <a href="http://www.physics.wisc.edu/~craigm/idl/math.html#qpint1d">qpint1d</a> (from <a href="http://www.physics.wisc.edu/~craigm/idl/">Markwardt library</a>, also based on QUADPACK, but vectorized) for identical <kbd>myfunc()</kbd>.</p>



Share This:


	<a rel="nofollow"  href="http://www.printfriendly.com/print?url=http%3A%2F%2Fwww.astrobetter.com%2Finterpolation-and-integration-in-python%2F&amp;partner=sociable" title="Print"><img src="http://www.astrobetter.com/wp-content/plugins/sociable/images/printfriendly.png" title="Print" alt="Print" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.astrobetter.com%2Finterpolation-and-integration-in-python%2F&amp;title=Interpolation%20and%20Integration%20in%20Python&amp;bodytext=Interpolation%0D%0A%0D%0A%0D%0AInterpolation%20is%20a%20used%20for%20many%20astronomical%20applications.%20Interpolation%20is%20required%20to%20combine%20sub-pixel%20dithered%20images%20or%20spectroscopy%2C%20sample%20grids%20of%20stellar%20evolution%20or%20stellar%20atmosphere%20models%2C%20calculate%20extinction%20from%20o" title="Digg"><img src="http://www.astrobetter.com/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://delicious.com/post?url=http%3A%2F%2Fwww.astrobetter.com%2Finterpolation-and-integration-in-python%2F&amp;title=Interpolation%20and%20Integration%20in%20Python&amp;notes=Interpolation%0D%0A%0D%0A%0D%0AInterpolation%20is%20a%20used%20for%20many%20astronomical%20applications.%20Interpolation%20is%20required%20to%20combine%20sub-pixel%20dithered%20images%20or%20spectroscopy%2C%20sample%20grids%20of%20stellar%20evolution%20or%20stellar%20atmosphere%20models%2C%20calculate%20extinction%20from%20o" title="del.icio.us"><img src="http://www.astrobetter.com/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.astrobetter.com%2Finterpolation-and-integration-in-python%2F&amp;t=Interpolation%20and%20Integration%20in%20Python" title="Facebook"><img src="http://www.astrobetter.com/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fwww.astrobetter.com%2Finterpolation-and-integration-in-python%2F&amp;title=Interpolation%20and%20Integration%20in%20Python&amp;annotation=Interpolation%0D%0A%0D%0A%0D%0AInterpolation%20is%20a%20used%20for%20many%20astronomical%20applications.%20Interpolation%20is%20required%20to%20combine%20sub-pixel%20dithered%20images%20or%20spectroscopy%2C%20sample%20grids%20of%20stellar%20evolution%20or%20stellar%20atmosphere%20models%2C%20calculate%20extinction%20from%20o" title="Google Bookmarks"><img src="http://www.astrobetter.com/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="mailto:?subject=Interpolation%20and%20Integration%20in%20Python&amp;body=http%3A%2F%2Fwww.astrobetter.com%2Finterpolation-and-integration-in-python%2F" title="email"><img src="http://www.astrobetter.com/wp-content/plugins/sociable/images/email_link.png" title="email" alt="email" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://twitter.com/home?status=Interpolation%20and%20Integration%20in%20Python%20-%20http%3A%2F%2Fwww.astrobetter.com%2Finterpolation-and-integration-in-python%2F" title="Twitter"><img src="http://www.astrobetter.com/wp-content/plugins/sociable/images/twitter.png" title="Twitter" alt="Twitter" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.printfriendly.com/print?url=http%3A%2F%2Fwww.astrobetter.com%2Finterpolation-and-integration-in-python%2F&amp;partner=sociable" title="PDF"><img src="http://www.astrobetter.com/wp-content/plugins/sociable/images/pdf.png" title="PDF" alt="PDF" class="sociable-hovers" /></a>


<br/><br/><img src="http://www.astrobetter.com/?ak_action=api_record_view&id=2146&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://www.astrobetter.com/interpolation-and-integration-in-python/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Fourier Transforms of Images in Python</title>
		<link>http://www.astrobetter.com/fourier-transforms-of-images-in-python/</link>
		<comments>http://www.astrobetter.com/fourier-transforms-of-images-in-python/#comments</comments>
		<pubDate>Wed, 03 Mar 2010 23:26:08 +0000</pubDate>
		<dc:creator>Jessica</dc:creator>
				<category><![CDATA[analysis]]></category>
		<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://www.astrobetter.com/?p=1809</guid>
		<description><![CDATA[There are many applications for taking fourier transforms of images (noise filtering, searching for small structures in diffuse galaxies, etc.). I wanted to point out some of the python capabilities that I have found useful in my particular application, which is to calculate the power spectrum of an image (for later separation of the distribution [...]]]></description>
			<content:encoded><![CDATA[<p></p><p>There are many applications for taking fourier transforms of images (noise filtering, searching for small structures in diffuse galaxies, etc.). I wanted to point out some of the python capabilities that I have found useful in my particular application, which is to calculate the power spectrum of an image (for later separation of the distribution of stars from the PSF and the noise; see Sheehy et al. 2006).</p>
<p>Below I have posted an example snippet of code, which you can also find on the <a href="http://www.astrobetter.com/wiki/tiki-index.php?page=python_image_fft">wiki</a>. But first, some figures to show what we are doing &#8212;  an astronomical image (<em>left</em>), the 2D power spectrum of the image (<em>middle</em>), and the azimuthally averaged 1D power spectrum (<em>right</em>).<br />

<a href='http://www.astrobetter.com/fourier-transforms-of-images-in-python/image_fft_examp_image/' title='image_fft_examp_image'><img width="150" height="150" src="http://www.astrobetter.com/wp-content/uploads/2010/03/image_fft_examp_image-150x150.png" class="attachment-thumbnail" alt="" title="image_fft_examp_image" /></a>
<a href='http://www.astrobetter.com/fourier-transforms-of-images-in-python/image_fft_examp_psd2d/' title='image_fft_examp_psd2d'><img width="150" height="150" src="http://www.astrobetter.com/wp-content/uploads/2010/03/image_fft_examp_psd2d-150x150.png" class="attachment-thumbnail" alt="" title="image_fft_examp_psd2d" /></a>
<a href='http://www.astrobetter.com/fourier-transforms-of-images-in-python/image_fft_examp_psd1d/' title='image_fft_examp_psd1d'><img width="150" height="150" src="http://www.astrobetter.com/wp-content/uploads/2010/03/image_fft_examp_psd1d-150x150.png" class="attachment-thumbnail" alt="" title="image_fft_examp_psd1d" /></a>
<br />
<span id="more-1809"></span><br />
The bulk of the heavy lifting can be done using SciPy&#8217;s fftpack. I also wrote <a href="http://www.astrobetter.com/wiki/tiki-index.php?page=python_radial_profiles">radialProfile.py</a> and it is very crude at the moment.<br />
[code lang="python"]<br />
from scipy import fftpack<br />
import pyfits<br />
import numpy as np<br />
import pylab as py<br />
import radialProfile</p>
<p>image = pyfits.getdata('myimage.fits')</p>
<p># Take the fourier transform of the image.<br />
F1 = fftpack.fft2(image)</p>
<p># Now shift the quadrants around so that low spatial frequencies are in<br />
# the center of the 2D fourier transformed image.<br />
F2 = fftpack.fftshift( F1 )</p>
<p># Calculate a 2D power spectrum<br />
psd2D = np.abs( F2 )**2</p>
<p># Calculate the azimuthally averaged 1D power spectrum<br />
psd1D = radialProfile.azimuthalAverage(psd2D)</p>
<p># Now plot up both<br />
py.figure(1)<br />
py.clf()<br />
py.imshow( np.log10( image ), cmap=py.cm.Greys)</p>
<p>py.figure(2)<br />
py.clf()<br />
py.imshow( np.log10( psf2D ))</p>
<p>py.figure(3)<br />
py.clf()<br />
py.semilogy( psf1D )<br />
py.xlabel('Spatial Frequency')<br />
py.ylabel('Power Spectrum')</p>
<p>py.show()<br />
[/code]</p>
<p>If you have suggestions for the above examples or other related code snippets or helper functions, let me know or comment below. I have posted this example <a href="http://www.astrobetter.com/wiki/tiki-index.php?page=python_image_fft">on the wiki</a> and will keep it updated with your suggestions.</p>



Share This:


	<a rel="nofollow"  href="http://www.printfriendly.com/print?url=http%3A%2F%2Fwww.astrobetter.com%2Ffourier-transforms-of-images-in-python%2F&amp;partner=sociable" title="Print"><img src="http://www.astrobetter.com/wp-content/plugins/sociable/images/printfriendly.png" title="Print" alt="Print" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.astrobetter.com%2Ffourier-transforms-of-images-in-python%2F&amp;title=Fourier%20Transforms%20of%20Images%20in%20Python&amp;bodytext=There%20are%20many%20applications%20for%20taking%20fourier%20transforms%20of%20images%20%28noise%20filtering%2C%20searching%20for%20small%20structures%20in%20diffuse%20galaxies%2C%20etc.%29.%20I%20wanted%20to%20point%20out%20some%20of%20the%20python%20capabilities%20that%20I%20have%20found%20useful%20in%20my%20particular%20applicati" title="Digg"><img src="http://www.astrobetter.com/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://delicious.com/post?url=http%3A%2F%2Fwww.astrobetter.com%2Ffourier-transforms-of-images-in-python%2F&amp;title=Fourier%20Transforms%20of%20Images%20in%20Python&amp;notes=There%20are%20many%20applications%20for%20taking%20fourier%20transforms%20of%20images%20%28noise%20filtering%2C%20searching%20for%20small%20structures%20in%20diffuse%20galaxies%2C%20etc.%29.%20I%20wanted%20to%20point%20out%20some%20of%20the%20python%20capabilities%20that%20I%20have%20found%20useful%20in%20my%20particular%20applicati" title="del.icio.us"><img src="http://www.astrobetter.com/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.astrobetter.com%2Ffourier-transforms-of-images-in-python%2F&amp;t=Fourier%20Transforms%20of%20Images%20in%20Python" title="Facebook"><img src="http://www.astrobetter.com/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fwww.astrobetter.com%2Ffourier-transforms-of-images-in-python%2F&amp;title=Fourier%20Transforms%20of%20Images%20in%20Python&amp;annotation=There%20are%20many%20applications%20for%20taking%20fourier%20transforms%20of%20images%20%28noise%20filtering%2C%20searching%20for%20small%20structures%20in%20diffuse%20galaxies%2C%20etc.%29.%20I%20wanted%20to%20point%20out%20some%20of%20the%20python%20capabilities%20that%20I%20have%20found%20useful%20in%20my%20particular%20applicati" title="Google Bookmarks"><img src="http://www.astrobetter.com/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="mailto:?subject=Fourier%20Transforms%20of%20Images%20in%20Python&amp;body=http%3A%2F%2Fwww.astrobetter.com%2Ffourier-transforms-of-images-in-python%2F" title="email"><img src="http://www.astrobetter.com/wp-content/plugins/sociable/images/email_link.png" title="email" alt="email" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://twitter.com/home?status=Fourier%20Transforms%20of%20Images%20in%20Python%20-%20http%3A%2F%2Fwww.astrobetter.com%2Ffourier-transforms-of-images-in-python%2F" title="Twitter"><img src="http://www.astrobetter.com/wp-content/plugins/sociable/images/twitter.png" title="Twitter" alt="Twitter" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.printfriendly.com/print?url=http%3A%2F%2Fwww.astrobetter.com%2Ffourier-transforms-of-images-in-python%2F&amp;partner=sociable" title="PDF"><img src="http://www.astrobetter.com/wp-content/plugins/sociable/images/pdf.png" title="PDF" alt="PDF" class="sociable-hovers" /></a>


<br/><br/><img src="http://www.astrobetter.com/?ak_action=api_record_view&id=1809&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://www.astrobetter.com/fourier-transforms-of-images-in-python/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>3D Plotting in Python with matplotlib mplot3d</title>
		<link>http://www.astrobetter.com/3d-plotting-in-python-with-matplotlib-mplot3d/</link>
		<comments>http://www.astrobetter.com/3d-plotting-in-python-with-matplotlib-mplot3d/#comments</comments>
		<pubDate>Mon, 01 Feb 2010 18:28:56 +0000</pubDate>
		<dc:creator>Jessica</dc:creator>
				<category><![CDATA[figures]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[mplot3d]]></category>

		<guid isPermaLink="false">http://www.astrobetter.com/?p=1593</guid>
		<description><![CDATA[I recently needed to do some simple 3D plotting in python. The strongest choice as discussed on the web is Mayavi, which is part of the Enthought Python distribution. However, I have a previous python distribution already installed (via scisoft) with all of my favorite packages updated to the latest and greatest versions (e.g. matplotlib, [...]]]></description>
			<content:encoded><![CDATA[<p></p><p>I recently needed to do some simple 3D plotting in python. The strongest choice as discussed on the web is <a href="http://code.enthought.com/projects/mayavi/">Mayavi</a>, which is part of the Enthought Python distribution. However, I have a previous python distribution already installed (via scisoft) with all of my favorite packages updated to the latest and greatest versions (e.g. matplotlib, PyEphem, slalib for python, etc.). I wanted to install Mayavi into my existing pythong distribution. In theory this should have been straightforward as there are eggs (a python package zip-type file). However, no matter how hard I tried, I could not get Mayavi, and all its required software, installed properly. Part of this may have been that I was doing a local install without admin privileges.</p>
<p>After spending an entire day with Mayavi issues, just in my attempt to make a very simple 3D scatter plot, I ran across a much easier option. The latest edition of <a href="http://matplotlib.sourceforge.net/">matplotlib</a> (0.99.1) comes with a toolkit called mplot3d. After looking over examples <a href="http://www.scipy.org/Cookbook/Matplotlib/mplot3D">here</a> and <a href="http://matplotlib.sourceforge.net/mpl_toolkits/mplot3d/index.html#toolkit-mplot3d-index">here</a>, it took me about 5 minutes to download and install the latest matplotlib version and I was ready to go! Simple 3D figures are a snap to put together and you can interact in order to zoom and rotate around. The toolkit uses matplotlib on the backend, so if you are familiar with all of the plotting options there, then mplot3d follows on logically.</p>
<div id="attachment_1687" class="wp-caption alignright" style="width: 300px">
	<img class="size-medium wp-image-1687" title="for_astrobetter" src="http://www.astrobetter.com/wp-content/uploads/2010/01/for_astrobetter-300x300.png" alt="My plot from matplotlib.mplot3d" width="300" height="300" />
	<p class="wp-caption-text">My plot from matplotlib.mplot3d</p>
</div>
<p>There are still a few bugs/features that I haven&#8217;t quite figured out. Most notably, in <a href="http://matplotlib.sourceforge.net/mpl_toolkits/mplot3d/tutorial.html#wireframe-plots">wire</a> or <a href="http://matplotlib.sourceforge.net/examples/mplot3d/surface3d_demo.html">surface</a> plots, I can&#8217;t seem to set the rstride and cstride (row and column segment step sizes) to anything less than 1. But one of my favorite things about python is that I should be able to go into the source code for mplot3d and figure out what the issue is.</p>
<p>If you have experience with either Mayavi or mplot3d, let us know in the comments when you would need to use Mayavi over the simpler functionality of mplot3d or if you have run into other issues with either.</p>



Share This:


	<a rel="nofollow"  href="http://www.printfriendly.com/print?url=http%3A%2F%2Fwww.astrobetter.com%2F3d-plotting-in-python-with-matplotlib-mplot3d%2F&amp;partner=sociable" title="Print"><img src="http://www.astrobetter.com/wp-content/plugins/sociable/images/printfriendly.png" title="Print" alt="Print" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.astrobetter.com%2F3d-plotting-in-python-with-matplotlib-mplot3d%2F&amp;title=3D%20Plotting%20in%20Python%20with%20matplotlib%20mplot3d&amp;bodytext=I%20recently%20needed%20to%20do%20some%20simple%203D%20plotting%20in%20python.%20The%20strongest%20choice%20as%20discussed%20on%20the%20web%20is%20Mayavi%2C%20which%20is%20part%20of%20the%20Enthought%20Python%20distribution.%20However%2C%20I%20have%20a%20previous%20python%20distribution%20already%20installed%20%28via%20scisoft%29%20with" title="Digg"><img src="http://www.astrobetter.com/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://delicious.com/post?url=http%3A%2F%2Fwww.astrobetter.com%2F3d-plotting-in-python-with-matplotlib-mplot3d%2F&amp;title=3D%20Plotting%20in%20Python%20with%20matplotlib%20mplot3d&amp;notes=I%20recently%20needed%20to%20do%20some%20simple%203D%20plotting%20in%20python.%20The%20strongest%20choice%20as%20discussed%20on%20the%20web%20is%20Mayavi%2C%20which%20is%20part%20of%20the%20Enthought%20Python%20distribution.%20However%2C%20I%20have%20a%20previous%20python%20distribution%20already%20installed%20%28via%20scisoft%29%20with" title="del.icio.us"><img src="http://www.astrobetter.com/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.astrobetter.com%2F3d-plotting-in-python-with-matplotlib-mplot3d%2F&amp;t=3D%20Plotting%20in%20Python%20with%20matplotlib%20mplot3d" title="Facebook"><img src="http://www.astrobetter.com/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fwww.astrobetter.com%2F3d-plotting-in-python-with-matplotlib-mplot3d%2F&amp;title=3D%20Plotting%20in%20Python%20with%20matplotlib%20mplot3d&amp;annotation=I%20recently%20needed%20to%20do%20some%20simple%203D%20plotting%20in%20python.%20The%20strongest%20choice%20as%20discussed%20on%20the%20web%20is%20Mayavi%2C%20which%20is%20part%20of%20the%20Enthought%20Python%20distribution.%20However%2C%20I%20have%20a%20previous%20python%20distribution%20already%20installed%20%28via%20scisoft%29%20with" title="Google Bookmarks"><img src="http://www.astrobetter.com/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="mailto:?subject=3D%20Plotting%20in%20Python%20with%20matplotlib%20mplot3d&amp;body=http%3A%2F%2Fwww.astrobetter.com%2F3d-plotting-in-python-with-matplotlib-mplot3d%2F" title="email"><img src="http://www.astrobetter.com/wp-content/plugins/sociable/images/email_link.png" title="email" alt="email" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://twitter.com/home?status=3D%20Plotting%20in%20Python%20with%20matplotlib%20mplot3d%20-%20http%3A%2F%2Fwww.astrobetter.com%2F3d-plotting-in-python-with-matplotlib-mplot3d%2F" title="Twitter"><img src="http://www.astrobetter.com/wp-content/plugins/sociable/images/twitter.png" title="Twitter" alt="Twitter" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.printfriendly.com/print?url=http%3A%2F%2Fwww.astrobetter.com%2F3d-plotting-in-python-with-matplotlib-mplot3d%2F&amp;partner=sociable" title="PDF"><img src="http://www.astrobetter.com/wp-content/plugins/sociable/images/pdf.png" title="PDF" alt="PDF" class="sociable-hovers" /></a>


<br/><br/><img src="http://www.astrobetter.com/?ak_action=api_record_view&id=1593&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://www.astrobetter.com/3d-plotting-in-python-with-matplotlib-mplot3d/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Read IDL ‘save’ files into Python</title>
		<link>http://www.astrobetter.com/read-idl-save-files-into-python/</link>
		<comments>http://www.astrobetter.com/read-idl-save-files-into-python/#comments</comments>
		<pubDate>Tue, 24 Nov 2009 14:00:37 +0000</pubDate>
		<dc:creator>Tom</dc:creator>
				<category><![CDATA[idl]]></category>
		<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://www.astrobetter.com/?p=1109</guid>
		<description><![CDATA[One of the most popular posts on this blog is Kelle&#8217;s reposting of Greenfield and Jedrzejewski&#8217;s IDL vs Python earlier this year. I am an avid Python user and have never installed IDL on my computer. Recently, I developed IDLSave, a package to read IDL ‘save’ files into Python, after being sent a few such [...]]]></description>
			<content:encoded><![CDATA[<p></p><p><img src="http://www.astrobetter.com/wp-content/uploads/2009/11/python-logo-new2.png" alt="python-logo-new2" title="python-logo-new2" width="150" height="44" class="alignright size-full wp-image-1154" />One of the most popular posts on this blog is Kelle&#8217;s reposting of Greenfield and Jedrzejewski&#8217;s <a href="http://www.astrobetter.com/idl-vs-python/">IDL vs Python</a> earlier this year. I am an avid Python user and have never installed IDL on my computer. Recently, I developed <a href="http://idlsave.sourceforge.net/">IDLSave</a>, a package to read <a href="http://idlastro.gsfc.nasa.gov/idl_html_help/SAVE.html">IDL ‘save’ files</a> into Python, after being sent a few such files by collaborators. In this package, scalars are converted to their respective Python types, while arrays and structures are mapped to <a href="http://numpy.scipy.org">Numpy</a> arrays and recarrays respectively. Most importantly, IDLSave does not require an installation of IDL.</p>
<p>With this package, there will be no need to bug your collaborators who send you IDL save files to resend them in a different format. This also means that if you are an IDL user holding back from switching over to Python because you have a large number of legacy IDL save files, you can now read these files directly into Python without first re-converting them to another format. </p>
<p><span id="more-1109"></span><br />
Using IDLSave is easy. Let&#8217;s say you (or a collaborator) writes a save file with</p>
<p><code>IDL&gt; save, wavelength, flux, file='spectrum.sav'</code></p>
<p>you will now be able to open this file in Python using</p>
<p><code>&gt;&gt;&gt; import idlsave<br />
&gt;&gt;&gt; s = idlsave.read('spectrum.sav')</code></p>
<p>after which you will be able to access the values using <code>s.wavelength</code> and <code>s.flux</code>.</p>
<p>The IDLSave <a href="http://idlsave.sourceforge.net/">homepage</a> includes download and installation instructions. If you encounter problems reading in save files, don&#8217;t give up &#8211; please submit a bug report through the <a href="https://sourceforge.net/tracker/?group_id=282358&amp;atid=1197649">bug tracker</a>, and I will look into it! One of the main limitations worth noting is that while it is possible to read save files into Python, it isn&#8217;t (currently) possible to write save files for reading back into IDL. It also is not possible to read special variables such as pointers or system variables from save files.</p>
<p>Enjoy!</p>



Share This:


	<a rel="nofollow"  href="http://www.printfriendly.com/print?url=http%3A%2F%2Fwww.astrobetter.com%2Fread-idl-save-files-into-python%2F&amp;partner=sociable" title="Print"><img src="http://www.astrobetter.com/wp-content/plugins/sociable/images/printfriendly.png" title="Print" alt="Print" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.astrobetter.com%2Fread-idl-save-files-into-python%2F&amp;title=Read%20IDL%20%E2%80%98save%E2%80%99%20files%20into%20Python&amp;bodytext=One%20of%20the%20most%20popular%20posts%20on%20this%20blog%20is%20Kelle%27s%20reposting%20of%20Greenfield%20and%20Jedrzejewski%27s%20IDL%20vs%20Python%20earlier%20this%20year.%20I%20am%20an%20avid%20Python%20user%20and%20have%20never%20installed%20IDL%20on%20my%20computer.%20Recently%2C%20I%20developed%20IDLSave%2C%20a%20package%20to%20read%20I" title="Digg"><img src="http://www.astrobetter.com/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://delicious.com/post?url=http%3A%2F%2Fwww.astrobetter.com%2Fread-idl-save-files-into-python%2F&amp;title=Read%20IDL%20%E2%80%98save%E2%80%99%20files%20into%20Python&amp;notes=One%20of%20the%20most%20popular%20posts%20on%20this%20blog%20is%20Kelle%27s%20reposting%20of%20Greenfield%20and%20Jedrzejewski%27s%20IDL%20vs%20Python%20earlier%20this%20year.%20I%20am%20an%20avid%20Python%20user%20and%20have%20never%20installed%20IDL%20on%20my%20computer.%20Recently%2C%20I%20developed%20IDLSave%2C%20a%20package%20to%20read%20I" title="del.icio.us"><img src="http://www.astrobetter.com/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.astrobetter.com%2Fread-idl-save-files-into-python%2F&amp;t=Read%20IDL%20%E2%80%98save%E2%80%99%20files%20into%20Python" title="Facebook"><img src="http://www.astrobetter.com/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fwww.astrobetter.com%2Fread-idl-save-files-into-python%2F&amp;title=Read%20IDL%20%E2%80%98save%E2%80%99%20files%20into%20Python&amp;annotation=One%20of%20the%20most%20popular%20posts%20on%20this%20blog%20is%20Kelle%27s%20reposting%20of%20Greenfield%20and%20Jedrzejewski%27s%20IDL%20vs%20Python%20earlier%20this%20year.%20I%20am%20an%20avid%20Python%20user%20and%20have%20never%20installed%20IDL%20on%20my%20computer.%20Recently%2C%20I%20developed%20IDLSave%2C%20a%20package%20to%20read%20I" title="Google Bookmarks"><img src="http://www.astrobetter.com/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="mailto:?subject=Read%20IDL%20%E2%80%98save%E2%80%99%20files%20into%20Python&amp;body=http%3A%2F%2Fwww.astrobetter.com%2Fread-idl-save-files-into-python%2F" title="email"><img src="http://www.astrobetter.com/wp-content/plugins/sociable/images/email_link.png" title="email" alt="email" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://twitter.com/home?status=Read%20IDL%20%E2%80%98save%E2%80%99%20files%20into%20Python%20-%20http%3A%2F%2Fwww.astrobetter.com%2Fread-idl-save-files-into-python%2F" title="Twitter"><img src="http://www.astrobetter.com/wp-content/plugins/sociable/images/twitter.png" title="Twitter" alt="Twitter" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.printfriendly.com/print?url=http%3A%2F%2Fwww.astrobetter.com%2Fread-idl-save-files-into-python%2F&amp;partner=sociable" title="PDF"><img src="http://www.astrobetter.com/wp-content/plugins/sociable/images/pdf.png" title="PDF" alt="PDF" class="sociable-hovers" /></a>


<br/><br/><img src="http://www.astrobetter.com/?ak_action=api_record_view&id=1109&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://www.astrobetter.com/read-idl-save-files-into-python/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>CosmoloPy: Cosmology Routines for Python</title>
		<link>http://www.astrobetter.com/cosmolopy-cosmology-routines-for-python/</link>
		<comments>http://www.astrobetter.com/cosmolopy-cosmology-routines-for-python/#comments</comments>
		<pubDate>Thu, 17 Sep 2009 23:14:05 +0000</pubDate>
		<dc:creator>Kelle</dc:creator>
				<category><![CDATA[python]]></category>
		<category><![CDATA[cosmology]]></category>

		<guid isPermaLink="false">http://www.astrobetter.com/?p=873</guid>
		<description><![CDATA[This is a guest post by Roban Hultman Kramer, who is currently an astronomy grad student at Columbia University and will be starting as a Zwicky Fellow at ETH Zurich in January.
CosmoloPy is a package of basic cosmology routines for Python, designed for use with NumPy and SciPy. Features currently include: calculation of cosmological distance [...]]]></description>
			<content:encoded><![CDATA[<p></p><p><em>This is a guest post by <a href="http://www.astro.columbia.edu/~roban/">Roban Hultman Kramer</a>, who is currently an astronomy grad student at <a href="http://www.astro.columbia.edu/">Columbia University</a> and will be starting as a <a href="http://www.exp-astro.phys.ethz.ch/zwicky_program.html">Zwicky Fellow</a> at <a href="http://www.astro.phys.ethz.ch/">ETH Zurich</a> in January.</em></p>
<p><a href="http://www.astrobetter.com/wp-content/uploads/2009/09/dist2d_D_A.png"><img src="http://www.astrobetter.com/wp-content/uploads/2009/09/dist2d_D_A-300x245.png" alt="angular diameter distance plot" width="210" style="float:left; margin: 0.5em 1em" /></a><a href="http://roban.github.com/CosmoloPy/">CosmoloPy</a> is a package of basic cosmology routines for Python, designed for use with <a href="http://scipy.org/">NumPy and SciPy</a>. Features currently include: calculation of cosmological distance measures, perturbation-theory-based calculation of the matter power spectrum and halo collapse fraction (courtesy of <a href="http://background.uchicago.edu/~whu/transfer/transferpage.html">Eisenstein &#038; Hu&#8217;s transfer function code</a>), and integration of simple reionization models and the resulting electron scattering optical depth due to reionization. I hope it will prove useful to the increasing number of astronomers turning to Python. Read on to find out more.<br />
<span id="more-873"></span><br />
Using CosmoloPy is as simple as setting up a dictionary of cosmological parameters (some <a href="http://lambda.gsfc.nasa.gov/product/map/dr3/parameters_summary.cfm">WMAP5 parameters</a> are provided for convenience in <code>cosmolopy.parameters</code>) and passing it to the functions you want to use. For instance, we could quickly calculate the comoving distance to redshift 6 like this:<br />
<code><br />
>>> import cosmolopy.distance as cd<br />
>>> cosmo = {'omega_M_0' : 0.3,<br />
...          'omega_lambda_0' : 0.7,<br />
...          'h' : 0.72}<br />
>>> d_co, err = cd.comoving_distance(z=6., **cosmo)<br />
>>> print "Comoving distance to z=6 is %.1f Mpc" % (d_co)<br />
Comoving distance to z=6 is 8017.8 Mpc<br />
</code></p>
<p>A few more lines of <a href="http://github.com/roban/CosmoloPy/blob/master/cosmolopy/examples/plot_2d_distances.py">code</a>, and you can produce a plot like the one shown above.<br />
CosmoloPy is released under the <a href="http://www.opensource.org/licenses/mit-license.php">MIT software license</a>, which allows it to be freely used and modified. So please <a href="http://roban.github.com/CosmoloPy/#download">download it</a>, use it, and request or add features you&#8217;d like to see included (and point out bugs we need to fix). Anyone can access the <a href="http://github.com/roban/CosmoloPy/tree/master">git repository</a>, so please edit the code and send in useful changes and additions. All questions about use or development can be posted to the <a href="http://groups.google.com/group/cosmolopy-devel">developer discussion group</a>.</p>



Share This:


	<a rel="nofollow"  href="http://www.printfriendly.com/print?url=http%3A%2F%2Fwww.astrobetter.com%2Fcosmolopy-cosmology-routines-for-python%2F&amp;partner=sociable" title="Print"><img src="http://www.astrobetter.com/wp-content/plugins/sociable/images/printfriendly.png" title="Print" alt="Print" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.astrobetter.com%2Fcosmolopy-cosmology-routines-for-python%2F&amp;title=CosmoloPy%3A%20Cosmology%20Routines%20for%20Python&amp;bodytext=This%20is%20a%20guest%20post%20by%20Roban%20Hultman%20Kramer%2C%20who%20is%20currently%20an%20astronomy%20grad%20student%20at%20Columbia%20University%20and%20will%20be%20starting%20as%20a%20Zwicky%20Fellow%20at%20ETH%20Zurich%20in%20January.%0D%0A%0D%0ACosmoloPy%20is%20a%20package%20of%20basic%20cosmology%20routines%20for%20Python%2C%20design" title="Digg"><img src="http://www.astrobetter.com/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://delicious.com/post?url=http%3A%2F%2Fwww.astrobetter.com%2Fcosmolopy-cosmology-routines-for-python%2F&amp;title=CosmoloPy%3A%20Cosmology%20Routines%20for%20Python&amp;notes=This%20is%20a%20guest%20post%20by%20Roban%20Hultman%20Kramer%2C%20who%20is%20currently%20an%20astronomy%20grad%20student%20at%20Columbia%20University%20and%20will%20be%20starting%20as%20a%20Zwicky%20Fellow%20at%20ETH%20Zurich%20in%20January.%0D%0A%0D%0ACosmoloPy%20is%20a%20package%20of%20basic%20cosmology%20routines%20for%20Python%2C%20design" title="del.icio.us"><img src="http://www.astrobetter.com/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.astrobetter.com%2Fcosmolopy-cosmology-routines-for-python%2F&amp;t=CosmoloPy%3A%20Cosmology%20Routines%20for%20Python" title="Facebook"><img src="http://www.astrobetter.com/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fwww.astrobetter.com%2Fcosmolopy-cosmology-routines-for-python%2F&amp;title=CosmoloPy%3A%20Cosmology%20Routines%20for%20Python&amp;annotation=This%20is%20a%20guest%20post%20by%20Roban%20Hultman%20Kramer%2C%20who%20is%20currently%20an%20astronomy%20grad%20student%20at%20Columbia%20University%20and%20will%20be%20starting%20as%20a%20Zwicky%20Fellow%20at%20ETH%20Zurich%20in%20January.%0D%0A%0D%0ACosmoloPy%20is%20a%20package%20of%20basic%20cosmology%20routines%20for%20Python%2C%20design" title="Google Bookmarks"><img src="http://www.astrobetter.com/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="mailto:?subject=CosmoloPy%3A%20Cosmology%20Routines%20for%20Python&amp;body=http%3A%2F%2Fwww.astrobetter.com%2Fcosmolopy-cosmology-routines-for-python%2F" title="email"><img src="http://www.astrobetter.com/wp-content/plugins/sociable/images/email_link.png" title="email" alt="email" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://twitter.com/home?status=CosmoloPy%3A%20Cosmology%20Routines%20for%20Python%20-%20http%3A%2F%2Fwww.astrobetter.com%2Fcosmolopy-cosmology-routines-for-python%2F" title="Twitter"><img src="http://www.astrobetter.com/wp-content/plugins/sociable/images/twitter.png" title="Twitter" alt="Twitter" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.printfriendly.com/print?url=http%3A%2F%2Fwww.astrobetter.com%2Fcosmolopy-cosmology-routines-for-python%2F&amp;partner=sociable" title="PDF"><img src="http://www.astrobetter.com/wp-content/plugins/sociable/images/pdf.png" title="PDF" alt="PDF" class="sociable-hovers" /></a>


<br/><br/><img src="http://www.astrobetter.com/?ak_action=api_record_view&id=873&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://www.astrobetter.com/cosmolopy-cosmology-routines-for-python/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Hungry for Plots? Get some APLpy!</title>
		<link>http://www.astrobetter.com/hungry-for-plots-get-some-aplpy/</link>
		<comments>http://www.astrobetter.com/hungry-for-plots-get-some-aplpy/#comments</comments>
		<pubDate>Mon, 20 Jul 2009 11:00:06 +0000</pubDate>
		<dc:creator>Eli</dc:creator>
				<category><![CDATA[analysis]]></category>
		<category><![CDATA[figures]]></category>
		<category><![CDATA[productivity]]></category>
		<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://www.astrobetter.com/?p=637</guid>
		<description><![CDATA[Today APLpy 0.9.3 is out! It is a Python plotting package made to generate publication-quality plots in multiple formats such as EPS, PDF, PS, PNG, and SVG.
APLpy was created by Thomas Robitaille and Eli Bressert, who come from a Fortran and IDL background. With Python&#8217;s ease of use, portability, and programming they decided to make [...]]]></description>
			<content:encoded><![CDATA[<p></p><p>Today <a href="http://aplpy.sourceforge.net/" target="_blank">APLpy</a> 0.9.3 is out! It is a Python plotting package made to generate publication-quality plots in multiple formats such as EPS, PDF, PS, PNG, and SVG.</p>
<p><a href="http://aplpy.sourceforge.net/" target="_blank">APLpy</a> was created by Thomas Robitaille and Eli Bressert, who come from a Fortran and IDL background. With Python&#8217;s ease of use, portability, and programming they decided to make a plotting package for astronomers. APLpy&#8217;s objective is easy usage with great looking publication plots. In other words, more bang for the buck. Here&#8217;s an example of what an <a href="http://aplpy.sourceforge.net/" target="_blank">APLpy</a> plot looks like:</p>
<p style="text-align: center;">
<div class="wp-caption aligncenter" style="width: 384px">
	<a href="http://sourceforge.net/apps/gallery/aplpy/index.php?g2_itemId=37"><img title="GLIMPSE / M16" src="http://sourceforge.net/apps/gallery/aplpy/main.php?g2_view=core.DownloadItem&amp;g2_itemId=39&amp;g2_serialNumber=2" alt="" width="384" height="346" /></a>
	<p class="wp-caption-text">A color generated APLpy plot from FITS files with grid lines. </p>
</div>
<p style="text-align: center;">
<p>To see more examples and how to make the plots in Python check out this <a href="http://sourceforge.net/apps/gallery/aplpy/index.php" target="_blank">link</a>.</p>
<p><a href="http://aplpy.sourceforge.net/" target="_blank">APLpy</a> has quite a few features (some listed below &#8211; from the APLpy site) and is continuing to expand. Fortunately, there&#8217;s good <a href="http://aplpy.sourceforge.net/documentation/index.html" target="_blank">documentation</a> to accompany the features.</p>
<ul>
<li>Make plots interactively or using scripts</li>
<li>Show grayscale, colorscale, and 3-color RGB images of FITS files</li>
<li>Generate co-aligned FITS cubes to make 3-color RGB images</li>
<li>Overlay any number of contour sets</li>
<li>Overlay markers with fully customizable symbol</li>
<li>Plot customizable shapes like circles, ellipses, and rectangles</li>
<li>Overlay coordinate grids</li>
<li>Customize the appearance of labels and ticks</li>
<li>Hide, show, and remove different contour and marker layers</li>
<li>Pan, zoom, and save any view as a full publication-quality plot</li>
<li>Save plots as EPS, PDF, PS, PNG, and SVG</li>
</ul>
<p style="text-align: left;">The plotting package is under active development and there has been extensive interaction between the users and developers. We should be seeing some exciting features added to <a href="http://aplpy.sourceforge.net/" target="_blank">APLpy</a> in the next few releases.</p>



Share This:


	<a rel="nofollow"  href="http://www.printfriendly.com/print?url=http%3A%2F%2Fwww.astrobetter.com%2Fhungry-for-plots-get-some-aplpy%2F&amp;partner=sociable" title="Print"><img src="http://www.astrobetter.com/wp-content/plugins/sociable/images/printfriendly.png" title="Print" alt="Print" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.astrobetter.com%2Fhungry-for-plots-get-some-aplpy%2F&amp;title=Hungry%20for%20Plots%3F%20Get%20some%20APLpy%21&amp;bodytext=Today%20APLpy%200.9.3%20is%20out%21%20It%20is%20a%20Python%20plotting%20package%20made%20to%20generate%20publication-quality%20plots%20in%20multiple%20formats%20such%20as%20EPS%2C%20PDF%2C%20PS%2C%20PNG%2C%20and%20SVG.%0D%0A%0D%0AAPLpy%20was%20created%20by%20Thomas%20Robitaille%20and%20Eli%20Bressert%2C%20who%20come%20from%20a%20Fortran%20and%20IDL%20b" title="Digg"><img src="http://www.astrobetter.com/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://delicious.com/post?url=http%3A%2F%2Fwww.astrobetter.com%2Fhungry-for-plots-get-some-aplpy%2F&amp;title=Hungry%20for%20Plots%3F%20Get%20some%20APLpy%21&amp;notes=Today%20APLpy%200.9.3%20is%20out%21%20It%20is%20a%20Python%20plotting%20package%20made%20to%20generate%20publication-quality%20plots%20in%20multiple%20formats%20such%20as%20EPS%2C%20PDF%2C%20PS%2C%20PNG%2C%20and%20SVG.%0D%0A%0D%0AAPLpy%20was%20created%20by%20Thomas%20Robitaille%20and%20Eli%20Bressert%2C%20who%20come%20from%20a%20Fortran%20and%20IDL%20b" title="del.icio.us"><img src="http://www.astrobetter.com/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.astrobetter.com%2Fhungry-for-plots-get-some-aplpy%2F&amp;t=Hungry%20for%20Plots%3F%20Get%20some%20APLpy%21" title="Facebook"><img src="http://www.astrobetter.com/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fwww.astrobetter.com%2Fhungry-for-plots-get-some-aplpy%2F&amp;title=Hungry%20for%20Plots%3F%20Get%20some%20APLpy%21&amp;annotation=Today%20APLpy%200.9.3%20is%20out%21%20It%20is%20a%20Python%20plotting%20package%20made%20to%20generate%20publication-quality%20plots%20in%20multiple%20formats%20such%20as%20EPS%2C%20PDF%2C%20PS%2C%20PNG%2C%20and%20SVG.%0D%0A%0D%0AAPLpy%20was%20created%20by%20Thomas%20Robitaille%20and%20Eli%20Bressert%2C%20who%20come%20from%20a%20Fortran%20and%20IDL%20b" title="Google Bookmarks"><img src="http://www.astrobetter.com/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="mailto:?subject=Hungry%20for%20Plots%3F%20Get%20some%20APLpy%21&amp;body=http%3A%2F%2Fwww.astrobetter.com%2Fhungry-for-plots-get-some-aplpy%2F" title="email"><img src="http://www.astrobetter.com/wp-content/plugins/sociable/images/email_link.png" title="email" alt="email" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://twitter.com/home?status=Hungry%20for%20Plots%3F%20Get%20some%20APLpy%21%20-%20http%3A%2F%2Fwww.astrobetter.com%2Fhungry-for-plots-get-some-aplpy%2F" title="Twitter"><img src="http://www.astrobetter.com/wp-content/plugins/sociable/images/twitter.png" title="Twitter" alt="Twitter" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.printfriendly.com/print?url=http%3A%2F%2Fwww.astrobetter.com%2Fhungry-for-plots-get-some-aplpy%2F&amp;partner=sociable" title="PDF"><img src="http://www.astrobetter.com/wp-content/plugins/sociable/images/pdf.png" title="PDF" alt="PDF" class="sociable-hovers" /></a>


<br/><br/><img src="http://www.astrobetter.com/?ak_action=api_record_view&id=637&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://www.astrobetter.com/hungry-for-plots-get-some-aplpy/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Scisoft OSX 2009.5.2 Released</title>
		<link>http://www.astrobetter.com/scisoft-osx-200952-released/</link>
		<comments>http://www.astrobetter.com/scisoft-osx-200952-released/#comments</comments>
		<pubDate>Mon, 18 May 2009 22:59:40 +0000</pubDate>
		<dc:creator>Jessica</dc:creator>
				<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://www.astrobetter.com/?p=439</guid>
		<description><![CDATA[For those of you who use scisoft, IRAF, PyRAF, Python, etc. there has been an update of the Scisoft package for Macs. This package is a very nice way to install some of the most commonly used astronomy software tools (at least in optical/IR). The Urania blog as a breakdown of some of the updates:
Urania [...]]]></description>
			<content:encoded><![CDATA[<p></p><p>For those of you who use scisoft, IRAF, PyRAF, Python, etc. there has been an update of the Scisoft package for Macs. This package is a very nice way to install some of the most commonly used astronomy software tools (at least in optical/IR). The Urania blog as a breakdown of some of the updates:</p>
<p><a title="Urania Blog" href="http://iparrizar.mnstate.edu/~juan/urania/2009/05/15/scisoft-osx-200952-released/">Urania Blog &#8211; Scisoft OSX 2009.5.2 Released</a></p>



Share This:


	<a rel="nofollow"  href="http://www.printfriendly.com/print?url=http%3A%2F%2Fwww.astrobetter.com%2Fscisoft-osx-200952-released%2F&amp;partner=sociable" title="Print"><img src="http://www.astrobetter.com/wp-content/plugins/sociable/images/printfriendly.png" title="Print" alt="Print" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.astrobetter.com%2Fscisoft-osx-200952-released%2F&amp;title=Scisoft%20OSX%202009.5.2%20Released&amp;bodytext=For%20those%20of%20you%20who%20use%20scisoft%2C%20IRAF%2C%20PyRAF%2C%20Python%2C%20etc.%20there%20has%20been%20an%20update%20of%20the%20Scisoft%20package%20for%20Macs.%20This%20package%20is%20a%20very%20nice%20way%20to%20install%20some%20of%20the%20most%20commonly%20used%20astronomy%20software%20tools%20%28at%20least%20in%20optical%2FIR%29.%20The%20Ura" title="Digg"><img src="http://www.astrobetter.com/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://delicious.com/post?url=http%3A%2F%2Fwww.astrobetter.com%2Fscisoft-osx-200952-released%2F&amp;title=Scisoft%20OSX%202009.5.2%20Released&amp;notes=For%20those%20of%20you%20who%20use%20scisoft%2C%20IRAF%2C%20PyRAF%2C%20Python%2C%20etc.%20there%20has%20been%20an%20update%20of%20the%20Scisoft%20package%20for%20Macs.%20This%20package%20is%20a%20very%20nice%20way%20to%20install%20some%20of%20the%20most%20commonly%20used%20astronomy%20software%20tools%20%28at%20least%20in%20optical%2FIR%29.%20The%20Ura" title="del.icio.us"><img src="http://www.astrobetter.com/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.astrobetter.com%2Fscisoft-osx-200952-released%2F&amp;t=Scisoft%20OSX%202009.5.2%20Released" title="Facebook"><img src="http://www.astrobetter.com/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fwww.astrobetter.com%2Fscisoft-osx-200952-released%2F&amp;title=Scisoft%20OSX%202009.5.2%20Released&amp;annotation=For%20those%20of%20you%20who%20use%20scisoft%2C%20IRAF%2C%20PyRAF%2C%20Python%2C%20etc.%20there%20has%20been%20an%20update%20of%20the%20Scisoft%20package%20for%20Macs.%20This%20package%20is%20a%20very%20nice%20way%20to%20install%20some%20of%20the%20most%20commonly%20used%20astronomy%20software%20tools%20%28at%20least%20in%20optical%2FIR%29.%20The%20Ura" title="Google Bookmarks"><img src="http://www.astrobetter.com/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="mailto:?subject=Scisoft%20OSX%202009.5.2%20Released&amp;body=http%3A%2F%2Fwww.astrobetter.com%2Fscisoft-osx-200952-released%2F" title="email"><img src="http://www.astrobetter.com/wp-content/plugins/sociable/images/email_link.png" title="email" alt="email" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://twitter.com/home?status=Scisoft%20OSX%202009.5.2%20Released%20-%20http%3A%2F%2Fwww.astrobetter.com%2Fscisoft-osx-200952-released%2F" title="Twitter"><img src="http://www.astrobetter.com/wp-content/plugins/sociable/images/twitter.png" title="Twitter" alt="Twitter" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.printfriendly.com/print?url=http%3A%2F%2Fwww.astrobetter.com%2Fscisoft-osx-200952-released%2F&amp;partner=sociable" title="PDF"><img src="http://www.astrobetter.com/wp-content/plugins/sociable/images/pdf.png" title="PDF" alt="PDF" class="sociable-hovers" /></a>


<br/><br/><img src="http://www.astrobetter.com/?ak_action=api_record_view&id=439&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://www.astrobetter.com/scisoft-osx-200952-released/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>IDL vs. Python</title>
		<link>http://www.astrobetter.com/idl-vs-python/</link>
		<comments>http://www.astrobetter.com/idl-vs-python/#comments</comments>
		<pubDate>Tue, 05 May 2009 04:19:02 +0000</pubDate>
		<dc:creator>Kelle</dc:creator>
				<category><![CDATA[idl]]></category>
		<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://www.astrobetter.com/?p=212</guid>
		<description><![CDATA[
Here is a really nice listing of the pros and cons of IDL and Python for astronomers. It&#8217;s an Appendix of the Python tutorial Using Python for Interactive Data Analysis by Greenfield and Jedrzejewski at STScI. Data and scripts for the examples and exercises in the tutorial are available at scipy.org.
Update 28 Jan 2010: We&#8217;ve [...]]]></description>
			<content:encoded><![CDATA[<p></p><p><img class="size-medium wp-image-243 alignright" style="margin: 0px 1em;" title="python-logo-master-v3" src="http://www.astrobetter.com/wp-content/uploads/2009/05/python-logo-master-v3-300x101.png" alt="python-logo-master-v3" width="126" height="43" /></p>
<p id="head-a186f4a7f86f1dd693335cdee2908df0394a044b">Here is a really nice listing of the pros and cons of IDL and Python for astronomers. It&#8217;s an Appendix of the Python tutorial <a href="http://stsdas.stsci.edu/perry/pydatatut.pdf" target="_blank"><em>Using Python for Interactive Data </em><img class="size-full wp-image-240 alignright" style="margin-top: 0px; margin-bottom: 0px; margin-right: 0px; margin-left: 1em;" title="idl" src="http://www.astrobetter.com/wp-content/uploads/2009/05/idl.jpg" alt="idl" width="125" height="40" /><em>Analysis</em></a> by Greenfield and Jedrzejewski at STScI. Data and scripts for the examples and exercises in the tutorial are available at <a href="http://www.scipy.org/wikis/topical_software/Tutorial" target="_blank">scipy.org</a>.</p>
<p><i><b>Update 28 Jan 2010: We&#8217;ve transferred this article to the <a href="http://www.astrobetter.com/wiki/tiki-index.php?page=idl_vs_python">wiki</a> so that it can be updated as Python evolves.</i></b></p>
<h3>Why would I switch from IDL to Python (or not)?</h3>
<p><small><strong>by Greenfield and Jedrzejewski</strong></small></p>
<p>We do not claim that all, or even most, current IDL users should switch to using Python now. IDL suits many people’s needs very well and we recognize that there must be a strong motivation for starting to use Python over IDL. This appendix will present the pros and cons of each so that users can make a better informed decision about whether they should consider using Python. At the end we give a few cases where we feel users should give serious consideration to using Python over IDL.<br />
<span id="more-212"></span></p>
<p>Pros and Cons are addressed below in a comparative sense. Attributes that both share, e.g., that they are interpreted and relatively slow for very simple operations, are not listed.</p>
<h3>Pros of IDL</h3>
<ul>
<li>Mature many numerical and astronomical libraries available</li>
<li>Wide astronomical user base</li>
<li>Numerical aspect well integrated with language itself</li>
<li>Many local users with deep experience</li>
<li>Faster for small arrays</li>
<li>Easier installation</li>
<li>Good, unified documentation</li>
<li>Standard GUI run/debug tool (IDLDE)</li>
<li>Single widget system (no angst about which to choose or learn)</li>
<li>SAVE/RESTORE capability</li>
<li>Use of keyword arguments as flags more convenient</li>
</ul>
<h3>Cons of IDL</h3>
<ul>
<li>Narrow applicability, not well suited to general programming</li>
<li>Slower for large arrays</li>
<li>Array functionality less powerful</li>
<li>Table support poor</li>
<li>Limited ability to extend using C or Fortran, such extensions hard to distribute and support</li>
<li>Expensive, sometimes problem collaborating with others that don’t have or can’t afford licenses.</li>
<li>Closed source (only RSI can fix bugs)</li>
<li>Very awkward to integrate with IRAF tasks</li>
<li>Memory management more awkward</li>
<li>Single widget system (useless if working within another framework)</li>
<li>Plotting:
<ul>
<li>Awkward support for symbols and math text</li>
<li>Many font systems, portability issues (v5.1 alleviates somewhat)</li>
<li>not as flexible or as extensible</li>
<li>plot windows not intrinsically interactive (e.g., pan &amp; zoom)</li>
</ul>
</li>
</ul>
<h3>Pros of Python</h3>
<ul>
<li>Very  general  and  powerful  programming  language,  yet  easy  to  learn. Strong, but optional, Object Oriented programming support</li>
<li>Very large user and developer community, very extensive and broad library base</li>
<li>Very   extensible   with   C,   C++,   or   Fortran,   portable   distribution mechanisms available</li>
<li>Free; non-restrictive license; Open Source</li>
<li>Becoming the standard scripting language for astronomy</li>
<li>Easy to use with IRAF tasks</li>
<li>Basis of STScI application efforts</li>
<li>More general array capabilities</li>
<li>Faster for large arrays, better support for memory mapping</li>
<li>Many  books  and  on-line  documentation  resources  available  (for  the language and its libraries)</li>
<li>Better support for table structures</li>
<li>Plotting
<ul>
<li>framework (matplotlib) more extensible and general</li>
<li>Better font support and portability (only one way to do it too)</li>
<li>Usable within many windowing frameworks (GTK, Tk, WX, Qt&#8230;)</li>
<li>Standard plotting functionality independent of framework used</li>
<li>plots are embeddable within other GUIs</li>
<li>more   powerful   image   handling   (multiple   simultaneous   LUTS, optional resampling/rescaling, alpha blending, etc)</li>
</ul>
</li>
<li>Support for many widget systems</li>
<li>Strong local influence over capabilities being developed for Python</li>
</ul>
<h3>Cons of Python</h3>
<ul>
<li>More items to install separately</li>
<li>Not  as  well  accepted  in  astronomical  community  (but  support  clearly growing)</li>
<li>Scientific libraries not as mature:
<ul>
<li>Documentation not as complete, not as unified</li>
<li>Not as deep in astronomical libraries and utilities</li>
<li>Not   all   IDL   numerical   library   functions   have   corresponding functionality in Python</li>
</ul>
</li>
<li>Some numeric constructs not quite as consistent with language (or slightly less convenient than IDL)</li>
<li>Array indexing convention “backwards”</li>
<li>Small array performance slower</li>
<li>No standard GUI run/debug tool</li>
<li>Support for many widget systems (angst regarding which to choose)</li>
<li>Current lack of function equivalent to SAVE/RESTORE in IDL</li>
<li>matplotlib does not yet have equivalents for all IDL 2-D plotting capability (e.g., surface plots)</li>
<li>Use of keyword arguments used as flags less convenient</li>
<li>Plotting:
<ul>
<li>comparatively immature, still much development going on</li>
<li>missing some plot type (e.g., surface)</li>
<li>3-d capability requires VTK (though matplotlib has some basic 3-d capability)</li>
</ul>
</li>
</ul>
<h3>Specific cases where using Python provides strong advantages over IDL</h3>
<ul>
<li>Your processing needs depend on running a few hard-to-replicate IRAF tasks, but you don’t want to do most of your data manipulation in IRAF, but would rather write your own IDL-style programs to do so (and soon other systems will be accessible from Python, e.g., MIDAS, ALMA, slang, etc)</li>
<li>You have algorithms that cannot be efficiently coded in IDL. They likely won’t be efficiently coded in Python either, but you will find interfacing the needed C or Fortran code easier, more flexible, more portable, and distributable. (Question: how many distributed IDL libraries developed by 3rd parties include C or Fortran code?) Or you need to wrap existing C libraries (Python has many tools to make this easier to do).</li>
<li>You do work on algorithms that may migrate into STSDAS packages. Using Python means that your work will be more easily adapted as a distributed and supported tool.</li>
<li>You wish to integrate data processing with other significant non-numerical processing  such  as  databases,  web  page  generation,  web  services,  text processing, process control, etc.</li>
<li>You want to learn object-oriented programming and use it with your data analysis. (But you don’t need to learn object-oriented programming to do data analysis in Python.)</li>
<li>You want to be able to use the same language you use for data analysis for most of your other scripting and programming tasks.</li>
<li>Your boss makes you.</li>
<li>You want to be a cool, with-it person.</li>
<li>You are honked off at ITT Space Systems/RSI.</li>
</ul>
<p>Obviously using a new language and libraries entails time spent learning. Despite what people say, it’s never that easy, especially if one has a lot of experience and code invested in an existing language. If you don’t have any strong motivations to switch, you should probably wait.</p>
<p>Reproduced with permission. Copyright 2007, Association of Universities for Research in Astronomy, Inc (AURA).</p>
<p><i><b>Update 28 Jan 2010: We&#8217;ve transferred this article to the <a href="http://www.astrobetter.com/wiki/tiki-index.php?page=idl_vs_python">wiki</a> so that it can be updated as Python evolves.</i></b></p>



Share This:


	<a rel="nofollow"  href="http://www.printfriendly.com/print?url=http%3A%2F%2Fwww.astrobetter.com%2Fidl-vs-python%2F&amp;partner=sociable" title="Print"><img src="http://www.astrobetter.com/wp-content/plugins/sociable/images/printfriendly.png" title="Print" alt="Print" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.astrobetter.com%2Fidl-vs-python%2F&amp;title=IDL%20vs.%20Python&amp;bodytext=%0D%0AHere%20is%20a%20really%20nice%20listing%20of%20the%20pros%20and%20cons%20of%20IDL%20and%20Python%20for%20astronomers.%20It%27s%20an%20Appendix%20of%20the%20Python%20tutorial%20Using%20Python%20for%20Interactive%20Data%20Analysis%20by%20Greenfield%20and%20Jedrzejewski%20at%20STScI.%20Data%20and%20scripts%20for%20the%20examples%20and%20" title="Digg"><img src="http://www.astrobetter.com/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://delicious.com/post?url=http%3A%2F%2Fwww.astrobetter.com%2Fidl-vs-python%2F&amp;title=IDL%20vs.%20Python&amp;notes=%0D%0AHere%20is%20a%20really%20nice%20listing%20of%20the%20pros%20and%20cons%20of%20IDL%20and%20Python%20for%20astronomers.%20It%27s%20an%20Appendix%20of%20the%20Python%20tutorial%20Using%20Python%20for%20Interactive%20Data%20Analysis%20by%20Greenfield%20and%20Jedrzejewski%20at%20STScI.%20Data%20and%20scripts%20for%20the%20examples%20and%20" title="del.icio.us"><img src="http://www.astrobetter.com/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.astrobetter.com%2Fidl-vs-python%2F&amp;t=IDL%20vs.%20Python" title="Facebook"><img src="http://www.astrobetter.com/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fwww.astrobetter.com%2Fidl-vs-python%2F&amp;title=IDL%20vs.%20Python&amp;annotation=%0D%0AHere%20is%20a%20really%20nice%20listing%20of%20the%20pros%20and%20cons%20of%20IDL%20and%20Python%20for%20astronomers.%20It%27s%20an%20Appendix%20of%20the%20Python%20tutorial%20Using%20Python%20for%20Interactive%20Data%20Analysis%20by%20Greenfield%20and%20Jedrzejewski%20at%20STScI.%20Data%20and%20scripts%20for%20the%20examples%20and%20" title="Google Bookmarks"><img src="http://www.astrobetter.com/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="mailto:?subject=IDL%20vs.%20Python&amp;body=http%3A%2F%2Fwww.astrobetter.com%2Fidl-vs-python%2F" title="email"><img src="http://www.astrobetter.com/wp-content/plugins/sociable/images/email_link.png" title="email" alt="email" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://twitter.com/home?status=IDL%20vs.%20Python%20-%20http%3A%2F%2Fwww.astrobetter.com%2Fidl-vs-python%2F" title="Twitter"><img src="http://www.astrobetter.com/wp-content/plugins/sociable/images/twitter.png" title="Twitter" alt="Twitter" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.printfriendly.com/print?url=http%3A%2F%2Fwww.astrobetter.com%2Fidl-vs-python%2F&amp;partner=sociable" title="PDF"><img src="http://www.astrobetter.com/wp-content/plugins/sociable/images/pdf.png" title="PDF" alt="PDF" class="sociable-hovers" /></a>


<br/><br/><img src="http://www.astrobetter.com/?ak_action=api_record_view&id=212&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://www.astrobetter.com/idl-vs-python/feed/</wfw:commentRss>
		<slash:comments>23</slash:comments>
		</item>
	</channel>
</rss>
