<?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; idl</title>
	<atom:link href="http://www.astrobetter.com/category/idl/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.astrobetter.com</link>
	<description>Tips and Tricks for Professional Astronomers</description>
	<lastBuildDate>Fri, 03 Feb 2012 14:05:00 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Introducing Coyote Graphics: The New Old Graphics System for IDL</title>
		<link>http://www.astrobetter.com/introducing-coyote-graphics-the-new-old-graphics-system-for-idl/</link>
		<comments>http://www.astrobetter.com/introducing-coyote-graphics-the-new-old-graphics-system-for-idl/#comments</comments>
		<pubDate>Tue, 22 Mar 2011 12:00:41 +0000</pubDate>
		<dc:creator>Guest</dc:creator>
				<category><![CDATA[idl]]></category>
		<category><![CDATA[figures]]></category>

		<guid isPermaLink="false">http://www.astrobetter.com/?p=4439</guid>
		<description><![CDATA[This is a guest post by David &#8220;Coyote&#8221; Fanning. The Coyote is familiar to many of us since his web page, Coyote&#8217;s Guide to IDL Programming, is the most informative web page on IDL. He has been working with IDL software for nearly 25 years. He developed the first IDL training course and became the [...]]]></description>
			<content:encoded><![CDATA[<p></p><p><em>This is a guest post by David &#8220;<a href="http://www.idlcoyote.com/documents/coyote.html" title="Coyote as a Mythic Symbol">Coyote</a>&#8221; Fanning. The Coyote is familiar to many of us since his web page, <a href="http://www.idlcoyote.com/">Coyote&#8217;s Guide to IDL Programming</a>, is the most informative web page on IDL. He has been working with IDL software for nearly 25 years. He developed the first IDL training course and became the Director of Training at Research Systems, Inc., the original creators of IDL software. You can run into David most days, hanging out, answering questions, on the <a href="http://groups.google.com/group/comp.lang.idl-pvwave/topics">IDL newsgroup (comp.lang.idl-pvwave)</a>.<br />
</em></p>
<p><P>I&#8217;ve had a couple of Big Ideas in 25 years of IDL programming, but none bigger than the idea that struck me late one night, after several months of writing a new IDL book. &#8220;Wait a minute! I can duplicate <i>all</i> the functionality of the new <a href="http://www.ittvis.com/language/en-US/ProductsServices/IDL/IDLGraphicSystem.aspx" title="IDL Graphics">IDL 8 function graphics</a> commands, and I can do it with these old, traditional IDL commands that everyone already knows how to use!&#8221;</p>
<p>After an almost sleepless night, I was up at 5:30 the next morning, and an hour later I had a graphics system working. Everything was there: resizeable graphics windows, the ability to automatically save whatever was shown in the graphics window to a PostScript file, or to automatically save the contents to any of five different raster file formats, with professional looking fonts I didn&#8217;t have to be embarrassed to use in a presentation. A few minutes later, there were even fancy <i>Layout</i> keywords and the ability to save the entire visualization to a file so that it could be &#8220;recalled&#8221; at some later date, saved for provenance, or e-mailed to a colleague so they could be viewing the same visualization I was looking at. Wow! I&#8217;ve been excited about IDL before, but this was taking passion to a whole new level. The best part of the new system: you could use this new graphics system in <i>any </i>version of IDL. Even Coyote, cynical to his core, was impressed.
<p>&#8220;Nobody will buy it,&#8221; he pointed out.</p>
<p>&#8220;You&#8217;re right about that,&#8221; I said morosely, thinking of my nearly non-existent bank account. &#8220;But, heck, let&#8217;s give it away! We&#8217;re more interested in fame than fortune, right?&#8221;
</p>
<p><div class="toggle"></p>
<p>So that&#8217;s what we did. We are calling this the <a href="http://www.idlcoyote.com/graphics_tips/coyote_graphics.php">Coyote Graphics System</a>. It pulls together programs from the <a href="http://www.idlcoyote.com/documents/programs.html">Coyote Library</A>, many of them <a href="http://www.idlcoyote.com/misc_tips/namechange.php">renamed to better reflect their purpose</a>, to create a complete graphics system that rivals any of the five new IDL graphics systems that have come and gone in the past 10 years, including the latest &#8220;new&#8221;graphics system, function graphics in IDL 8. But, unlike these new systems, this graphics system can actually be used and programmed by mortals to create new visual displays. Any data visualization you can imagine, you can create with the Coyote Graphics System. </p>
<p>There are two programs at the heart of the system. The <a href="http://www.idlcoyote.com/graphics_tips/coyote_graphics.php#cgCOLOR">cgColor</a> program doesn&#8217;t care whether you are stuck in the past and will use indexed color until the day you die or whether you have moved on to the 21st century and want get your money&#8217;s worth out of that expensive 24-bit graphics card you bought for your computer, it always give you the color you ask for. And <a href="http://www.idlcoyote.com/graphics_tips/cgwindow.php">cgWindow</a> is a resizeable graphics window that can be used almost exactly like you are currently using normal IDL graphics windows. These two programs can work with any traditional IDL command (e.g., <i>Plot</i>, <i>Contour</i>, <i>Surface</i>, <i>TV</i>, etc.), but the equivalent Coyote Graphics commands (e.g, <a href="http://www.idlcoyote.com/graphics_tips/coyote_graphics.php#cgPLOT">cgPlot</a>, <a href="http://www.idlcoyote.com/graphics_tips/coyote_graphics.php#cgCONTOUR">cgContour</a>, <a href="http://www.idlcoyote.com/graphics_tips/coyote_graphics.php#cgSURF">cgSurf</a>, and <a href="http://www.idlcoyote.com/graphics_tips/coyote_graphics.php#cgImage">cgImage</a>) are designed specifically to work with these routines to produce device and color model independent programs.</p>
<p>What does this mean for you? It means you can write one program and have it work and look exactly the same on your display and in a PostScript file. It means you can stop apologizing about the poor quality of IDL graphics displays when you are presenting your results to your colleagues. And it means you can spend more time doing science and less time fooling around with recalcitrant graphics programs.</p>
<p><iframe src="http://rcm.amazon.com/e/cm?lt1=_blank&#038;bc1=000000&#038;IS2=1&#038;npa=1&#038;bg1=FFFFFF&#038;fc1=000000&#038;lc1=0000FF&#038;t=astro0d5-20&#038;o=1&#038;p=8&#038;l=as4&#038;m=amazon&#038;f=ifr&#038;ref=ss_til&#038;asins=0966238354" style="float: right; margin-left:1em; width:120px;height:240px;" scrolling="no" marginwidth="0" marginheight="0" frameborder="0"></iframe></p>
<p>Wayne Landsman has already <a href="http://www.idlcoyote.com/graphics_tips/astrocoyote.php">converted every plotting routine</a> in the <a href="http://idlastro.gsfc.nasa.gov/homepage.html">NASA IDL Astronomy Library</a> to Coyote Graphics. Other <a href="http://groups.google.com/group/comp.lang.idl-pvwave/browse_thread/thread/85d7a357530ef069?hl=en">astronomy libraries</a> are doing the same. You can do this, too, with programs you have already written. My new book, <a href="http://www.amazon.com/gp/product/0966238354/ref=as_li_ss_tl?ie=UTF8&#038;tag=astro0d5-20&#038;linkCode=as2&#038;camp=1789&#038;creative=390957&#038;creativeASIN=0966238354">Coyote&#8217;s Guide to Traditional IDL Graphics: Using Familiar Tools Creatively</a> (<a href="http://www.idlcoyote.com/store/index.php?act=viewProd&#038;productId=22">$70 softcover limited time pre-publication price</a>, <a href="http://www.amazon.com/gp/product/0966238354/ref=as_li_ss_tl?ie=UTF8&#038;tag=astro0d5-20&#038;linkCode=as2&#038;camp=1789&#038;creative=390957&#038;creativeASIN=0966238354">$90 softcover</a>, <a href="http://www.idlcoyote.com/store/index.php?act=viewProd&#038;productId=15">$60 PDF</a>) explains the technique in detail. It is incredibly simple and <a href="http://www.idlcoyote.com/documents/programs.html">Coyote Library</a> routines have already been written to do most of the dirty work for you.</p>
<p><P>Here is what Ben Tupper, an IDL veteran and Mac user, had to say about the Coyote Graphics System when I introduced it to him:<br />
<BLOCKQUOTE style="text-indent:2em;">I have just perused Chapter 12, &#8220;Using the Coyote Graphics System,&#8221; and I am thunderstruck (again!) by what a brilliant thing you have done for simple-to-use-right-out-of-the-box-but-wicked-powerful graphics. This is exactly what all of us need whether we are just cutting our teeth or we are getting long in the tooth.  It&#8217;s freakin&#8217; marvelous!<br />
</BLOCKQUOTE>
</p>
<p><P>If you are tired of working with IDL graphics programs that look like they were written in the 1970s, I invite you to try something completely different. Here, for example, is how easy it is to create a filled contour plot in a resizeable graphics window.</P></p>

<div class="wp_syntax"><div class="code"><pre class="idl" style="font-family:monospace;">   IDL&gt; cgLoadCT, <span style="color: #0000dd;">4</span>, <span style="color: #66cc66;">/</span>Brewer, <span style="color: #66cc66;">/</span>Reverse
   IDL&gt; data <span style="color: #66cc66;">=</span> cgDemoData<span style="color: #808080;">&#40;</span><span style="color: #0000dd;">2</span><span style="color: #808080;">&#41;</span>
   IDL&gt; cgContour, data, NLevels<span style="color: #66cc66;">=</span><span style="color: #0000dd;">12</span>, <span style="color: #66cc66;">/</span>Fill, Position<span style="color: #66cc66;">=</span><span style="color: #808080;">&#91;</span><span style="color: #0000dd;">0.1</span>,<span style="color: #0000dd;">0.1</span>,<span style="color: #0000dd;">0.9</span>,<span style="color: #0000dd;">0.75</span><span style="color: #808080;">&#93;</span>, <span style="color: #66cc66;">/</span>Window
   IDL&gt; cgContour, data, Color<span style="color: #66cc66;">=</span><span style="color: #ff0000;">'Charcoal'</span>, NLevels<span style="color: #66cc66;">=</span><span style="color: #0000dd;">12</span>, <span style="color: #66cc66;">/</span>Overplot, <span style="color: #66cc66;">/</span>Add
   IDL&gt; cgColorbar, Divisions<span style="color: #66cc66;">=</span><span style="color: #0000dd;">12</span>, Range<span style="color: #66cc66;">=</span><span style="color: #808080;">&#91;</span>Min<span style="color: #808080;">&#40;</span>data<span style="color: #808080;">&#41;</span>, Max<span style="color: #808080;">&#40;</span>data<span style="color: #808080;">&#41;</span><span style="color: #808080;">&#93;</span>, XMinor<span style="color: #66cc66;">=</span><span style="color: #0000dd;">0</span>, $
           XTicklen<span style="color: #66cc66;">=</span><span style="color: #0000dd;">1.0</span>, Charsize<span style="color: #66cc66;">=</span><span style="color: #0000dd;">1.25</span>, <span style="color: #66cc66;">/</span>Add</pre></div></div>

<p><P>And here is the result. I think if you try these commands, it just might change the way you write IDL graphics programs forever!</p>
<p><img src="http://www.astrobetter.com/wp-content/uploads/2011/03/coyote_graphics_example.png" alt="Coyote Graphics Example" height="421" width="719">
</p>
<p>
So, please give the new Coyote Graphics a whirl and let me know what you think in the comments!</p>
</div>]]></content:encoded>
			<wfw:commentRss>http://www.astrobetter.com/introducing-coyote-graphics-the-new-old-graphics-system-for-idl/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Add Symbols and Equations to IDL Figures with LaTeX and PSfrag</title>
		<link>http://www.astrobetter.com/idl-psfrag/</link>
		<comments>http://www.astrobetter.com/idl-psfrag/#comments</comments>
		<pubDate>Tue, 04 Jan 2011 11:00:23 +0000</pubDate>
		<dc:creator>saurav</dc:creator>
				<category><![CDATA[figures]]></category>
		<category><![CDATA[idl]]></category>
		<category><![CDATA[fonts]]></category>
		<category><![CDATA[latex]]></category>
		<category><![CDATA[psfrag]]></category>

		<guid isPermaLink="false">http://www.astrobetter.com/?p=3944</guid>
		<description><![CDATA[While IDL does support math equations and symbols&#8212;often made easier by routines like sunsymbol.pro and textoidl.pro&#8212;the results are not aesthetically pleasing. One particular instance that has annoyed many of us astronomers has been the sunsymbol (⦿). The available solutions are not ideal: the dot inside the circle is off-center in sunsymbol.pro, the vertical alignment is [...]]]></description>
			<content:encoded><![CDATA[<p></p><p>While IDL does support math equations and symbols&#8212;often made easier by routines like <tt>sunsymbol.pro</tt> and <tt>textoidl.pro</tt>&#8212;the results are not aesthetically pleasing. One particular instance that has annoyed many of us astronomers has been the sunsymbol (⦿).</p>
<div class="wp-caption alignright" style="width: 270px;"><img src="http://www.astrobetter.com/wp-content/uploads/2011/01/Msun.png" alt="" width="265px;" height="77px;" /></div>
<p>The available solutions are not ideal: the dot inside the circle is off-center in <tt>sunsymbol.pro</tt>, the vertical alignment is off in <tt>textoidl.pro</tt>, and only Hershey fonts are supported when using Unicode. In the figure, I have produced the M<sub>⦿</sub> symbol using <tt>textoidl.pro</tt>, <tt>sunsymbol.pro</tt>, and LaTeX&#8217;s <tt>PSfrag</tt> package (left to right); the improvement represented by the third method is clear and expected. as this is produced directly using LaTeX. Also see the <a href="http://www.dfanning.com/misc_tips/sun_symbol.html">Coyote&#8217;s post</a> for a more detailed discussion.</p>
<p>One way to resolve this issue is to use LaTeX&#8217;s <a href="http://www.ctan.org/tex-archive/help/Catalogue/entries/psfrag.html">PSfrag</a> package (solution via Manodeep S. via <a href="http://groups.google.com/group/comp.lang.idl-pvwave/topics">IDL Google Groups</a>), which basically &#8220;precisely superimposes any LaTeX construction&#8221; (e.g. symbols, equations) into over EPS figures. So you have to create a tag for your LaTeX construction, which then is replaced by the appropriate symbol during TeX compilation. Let me give an example for the M<sub>⦿</sub> in IDL; but this can be used for EPS figures made in any program.<br />
<div class="toggle"><br />
In IDL (or any plotting package of your choice) create your EPS (or PS) figure:</p>

<div class="wp_syntax"><div class="code"><pre class="idl" style="font-family:monospace;">SET_PLOT, <span style="color: #ff0000;">'PS'</span>,<span style="color: #66cc66;">/</span>Encapsulated
<span style="color: #66cc66;">!</span>P.FONT<span style="color: #66cc66;">=</span><span style="color: #0000dd;">0</span>
DEVICE, FILENAME<span style="color: #66cc66;">=</span><span style="color: #ff0000;">'figure.eps'</span>,<span style="color: #66cc66;">/</span>times
plot,findgen<span style="color: #808080;">&#40;</span><span style="color: #0000dd;">10</span><span style="color: #808080;">&#41;</span>,xtitle<span style="color: #66cc66;">=</span><span style="color: #ff0000;">'Msun'</span>
DEVICE, <span style="color: #66cc66;">/</span>CLOSE</pre></div></div>

<p>where <tt>Msun</tt> works as the tag that PSfrag will replace with the ⦿. The tag can be whatever you want, as long as it is a series of letters. <em>[Update: As Michael Galloy points out below, <tt>PSfrag</tt> cannot replace substrings, i.e., the string being fed into PSfrag needs to be the entire <tt>XTITLE</tt>.]</em> Then, create a basic LaTeX document (say, figure.tex):</p>

<div class="wp_syntax"><div class="code"><pre class="latex" style="font-family:monospace;"><span style="color: #E02020; ">\</span><span style="color: #800000;">documentclass</span><span style="color: #E02020; ">{</span><span style="color: #2020C0; font-weight: normal;">article</span><span style="color: #E02020; ">}</span>
<span style="color: #E02020; ">\</span><span style="color: #800000;">usepackage</span><span style="color: #E02020; ">{</span><span style="color: #2020C0; font-weight: normal;">geometry, graphicx, psfrag</span><span style="color: #E02020; ">}</span>
<span style="color: #E02020; ">\</span><span style="color: #800000;">pagestyle</span><span style="color: #E02020; ">{</span><span style="color: #2020C0; font-weight: normal;">empty</span><span style="color: #E02020; ">}</span>
<span style="color: #800000; font-weight: normal;">\geometry</span><span style="color: #E02020; ">{</span><span style="color: #2020C0; font-weight: normal;">paperwidth=12.1cm,paperheight=8.1cm,margin=0pt</span><span style="color: #E02020; ">}</span>
&nbsp;
<span style="color: #C00000; font-weight: normal;">\begin</span><span style="color: #E02020; ">{</span><span style="color: #2020C0; font-weight: normal;"><span style="color: #0000D0; font-weight: normal;">document</span></span><span style="color: #E02020; ">}</span>
 <span style="color: #2C922C; font-style: italic;">%%% Msun is the tag in the eps file to be replaced by M⦿</span>
<span style="color: #800000; font-weight: normal;">\psfrag</span><span style="color: #E02020; ">{</span><span style="color: #2020C0; font-weight: normal;">Msun</span><span style="color: #E02020; ">}[</span><span style="color: #C08020; font-weight: normal;">c</span><span style="color: #E02020; ">][</span><span style="color: #C08020; font-weight: normal;">][1.75</span><span style="color: #E02020; ">]{</span><span style="color: #2020C0; font-weight: normal;">Mass (M<span style="color: #8020E0; font-weight: normal;">$_{<span style="color: #800000; font-weight: normal;">\odot</span></span>}$</span>)<span style="color: #E02020; ">}</span>
<span style="color: #E02020; ">\</span><span style="color: #800000;">includegraphics</span><span style="color: #E02020; ">[</span><span style="color: #C08020; font-weight: normal;">width=11.9cm,height=7.9cm</span><span style="color: #E02020; ">]{</span><span style="color: #2020C0; font-weight: normal;">figure.eps</span><span style="color: #E02020; ">}</span>
<span style="color: #C00000; font-weight: normal;">\end</span><span style="color: #E02020; ">{</span><span style="color: #2020C0; font-weight: normal;"><span style="color: #0000D0; font-weight: normal;">document</span></span><span style="color: #E02020; ">}</span></pre></div></div>

<p>Then, compile LaTeX and convert the resultant PS file to EPS, if you so desire.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">latex figure.tex
dvips <span style="color: #660033;">-o</span> fig.ps figure.dvi
<span style="color: #c20cb9; font-weight: bold;">ps2epsi</span> fig.ps fig.epsi
<span style="color: #666666; font-style: italic;">### strip out the preview part from fig.epsi</span>
<span style="color: #c20cb9; font-weight: bold;">perl</span> <span style="color: #660033;">-ne</span> <span style="color: #ff0000;">'print unless /^%%BeginPreview/../^%%EndPreview/'</span> <span style="color: #000000; font-weight: bold;">&lt;</span> fig.epsi <span style="color: #000000; font-weight: bold;">&gt;</span> fig.eps</pre></div></div>

<p>Done! The <tt>Msun</tt> in the original figure.eps is replaced by a properly aligned, TeX-like M<sub>⦿</sub> in the new fig.eps!</p>
<p>A couple notes as I experiment more with <tt>PSfrag</tt>:</p>
<p>1)  Note that <tt>PSfrag</tt> only replaces tags in EPS figures, allowing you to mix your LaTeX with your figures. In other words, you can create all of your figures with tags and add them in your manuscript. All the tags will be replaced when you TeX your document.</p>
<p>2) You can have local a <tt>\PSfrag</tt> that immediately precedes the <tt>\includegraphics</tt> in addition to a global <tt>PSfrags</tt>. The definition in the local environment will have precedence. Really nifty!</p>
</div>]]></content:encoded>
			<wfw:commentRss>http://www.astrobetter.com/idl-psfrag/feed/</wfw:commentRss>
		<slash:comments>7</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><div class="toggle"><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>
</div>]]></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>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: [...]]]></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 />
<div class="toggle"></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>
</div>]]></content:encoded>
			<wfw:commentRss>http://www.astrobetter.com/idl-vs-python/feed/</wfw:commentRss>
		<slash:comments>23</slash:comments>
		</item>
		<item>
		<title>Making Fonts Better in IDL Postscript Output</title>
		<link>http://www.astrobetter.com/making-fonts-better-in-idl-postscript-output/</link>
		<comments>http://www.astrobetter.com/making-fonts-better-in-idl-postscript-output/#comments</comments>
		<pubDate>Thu, 23 Apr 2009 20:13:22 +0000</pubDate>
		<dc:creator>Kelle</dc:creator>
				<category><![CDATA[idl]]></category>
		<category><![CDATA[figures]]></category>
		<category><![CDATA[fonts]]></category>

		<guid isPermaLink="false">http://www.astrobetter.com/?p=33</guid>
		<description><![CDATA[We&#8217;ve all seen it before, illegible labels on a figure in a paper or talk. I don&#8217;t know how to remedy this problem in SuperMongo or other popular plotting programs, but I do in IDL. I&#8217;ve addressed the topic of postscript output on my IDL figures page but in this post I&#8217;m just going to [...]]]></description>
			<content:encoded><![CDATA[<p></p><p>We&#8217;ve all seen it before, illegible labels on a figure in a paper or talk. I don&#8217;t know how to remedy this problem in SuperMongo or other popular plotting programs, but I do in IDL. I&#8217;ve addressed the topic of postscript output on <a href="http://www.astro.caltech.edu/~kelle/figs.html" target="_blank">my IDL figures page</a> but in this post I&#8217;m just going to focus on the issue of figure size and fonts. Symbols, line thickness, and colors will be discussed in future posts.</p>
<p><div class="toggle"></p>
<div id="attachment_74" class="wp-caption alignleft" style="width: 195px">
	<img class="size-medium wp-image-74" title="blog_fonts_bad" src="http://www.astrobetter.com/wp-content/uploads/2009/04/blog_fonts_bad-300x200.jpg" alt="Bad" width="195" />
	<p class="wp-caption-text"> BAD: 18 cm across and vector font</p>
</div>
<div id="attachment_75" class="wp-caption alignright" style="width: 195px">
	<img class="size-medium wp-image-75" title="blog_fonts_good" src="http://www.astrobetter.com/wp-content/uploads/2009/04/blog_fonts_good-300x200.jpg" alt="Better" width="195" />
	<p class="wp-caption-text">BETTER: 9 cm across and Postscript font</p>
</div>
<h3>Make the figure close to the actual printed size</h3>
<p>First thing, size matters. That old manuscript preparation document that said figures should fill a letter-sized page is misguided. No matter what type of font you use, if the text size looks right when the figure is 8 inches across, it will be too small when printed as a single column figure only 9 cm across. The BAD figure above is designed at 18 cm across while the BETTER one is 9 cm. Notice the difference in font size. (<code>Charsize</code> was not specified for either plot.) Design the figures to be tiny from the beginning and no further adjustments to the font size will be necessary for either publications or talks.</p>
<p>When these &#8220;small from the start&#8221; figures are blown up to fill a letter-sized page (i.e., in Latex preprint mode), the fonts might seem too large and look funny to your eye but, since it ensures that nobody will ever have trouble reading your axis labels, you should just get used to it.</p>

<div class="wp_syntax"><div class="code"><pre class="idl" style="font-family:monospace;">aspect_ratio<span style="color: #66cc66;">=</span><span style="color: #0000dd;">1.5</span> <span style="color: #66cc66;">;</span>rectangle
device, xsize<span style="color: #66cc66;">=</span><span style="color: #0000dd;">9</span>, ysize<span style="color: #66cc66;">=</span>xsize<span style="color: #66cc66;">/</span>aspect_ratio</pre></div></div>

<h3>Use Postscript instead of Vector fonts <img class="alignright size-medium" title="fontvect" src="http://www.astrobetter.com/wp-content/uploads/2009/04/fontvect-300x40.gif" alt="fontvect" width="210" height="28" /></h3>
<h3><img class="alignright size-medium" title="fontdev" src="http://www.astrobetter.com/wp-content/uploads/2009/04/fontdev-300x44.gif" alt="fontdev" width="210" height="31" /></h3>
<p>Inevitably, when a figure is illegible during a talk, a vector (Hershey) font was used instead of a Postscript font. For the purposes of 2D figures, the relevant difference is that vector fonts are thin and have a tendency to disappear while Postscript fonts are thick. The above BAD figure uses the default vector font while the BETTER one uses a Postscript font.</p>
<p>It&#8217;s so simple to switch from vector to device fonts! All you need is <code>!p.font=0</code>. While you&#8217;re at it, you might as well specify Helvetica for good measure even though, as far as I can tell, it&#8217;s the default Postscript typeface.</p>

<div class="wp_syntax"><div class="code"><pre class="idl" style="font-family:monospace;">set_plot, <span style="color: #ff0000;">'ps'</span>
<span style="color: #66cc66;">!</span>p.font<span style="color: #66cc66;">=</span><span style="color: #0000dd;">0</span>
device, <span style="color: #66cc66;">/</span>helvetica <span style="color: #66cc66;">;</span> a classic sans<span style="color: #66cc66;">-</span>serif font</pre></div></div>

<p>Everything you ever wanted to know about fonts in IDL is in the <a href="http://idlastro.gsfc.nasa.gov/idl_html_help/Fonts.html" target="_blank">Reference Guide</a>.</p>
<h3>Putting it together</h3>

<div class="wp_syntax"><div class="code"><pre class="idl" style="font-family:monospace;">aspect_ratio<span style="color: #66cc66;">=</span><span style="color: #0000dd;">1.5</span>
xsize<span style="color: #66cc66;">=</span><span style="color: #0000dd;">9</span>
ysize<span style="color: #66cc66;">=</span>xsize<span style="color: #66cc66;">/</span>aspect_ratio
set_plot, <span style="color: #ff0000;">'ps'</span>
<span style="color: #66cc66;">!</span>p.font<span style="color: #66cc66;">=</span><span style="color: #0000dd;">0</span>
device, filename<span style="color: #66cc66;">=</span><span style="color: #ff0000;">'fig_better.eps'</span>, encapsulated<span style="color: #66cc66;">=</span><span style="color: #0000dd;">1</span>, <span style="color: #66cc66;">/</span>helvetica
device, xsize<span style="color: #66cc66;">=</span>xsize, ysize<span style="color: #66cc66;">=</span>ysize
plot, a, b, xtitle<span style="color: #66cc66;">=</span><span style="color: #ff0000;">'X Title'</span>, ytitle<span style="color: #66cc66;">=</span><span style="color: #ff0000;">'Y Title'</span>
device, <span style="color: #66cc66;">/</span>close
set_plot, <span style="color: #ff0000;">'x'</span>
<span style="color: #66cc66;">!</span>p.font<span style="color: #66cc66;">=-</span><span style="color: #0000dd;">1</span></pre></div></div>

<p>Know how to get nice legible fonts in other plotting programs? Share it in the comments.</p>
</div>]]></content:encoded>
			<wfw:commentRss>http://www.astrobetter.com/making-fonts-better-in-idl-postscript-output/feed/</wfw:commentRss>
		<slash:comments>21</slash:comments>
		</item>
	</channel>
</rss>

