<?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; figures</title>
	<atom:link href="http://www.astrobetter.com/category/figures/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>Pretty plotting of spectra?  [Ask AstroBetter]</title>
		<link>http://www.astrobetter.com/pretty-plotting-of-spectra-ask-astrobetter/</link>
		<comments>http://www.astrobetter.com/pretty-plotting-of-spectra-ask-astrobetter/#comments</comments>
		<pubDate>Fri, 27 Jan 2012 13:00:33 +0000</pubDate>
		<dc:creator>Jane Rigby</dc:creator>
				<category><![CDATA[figures]]></category>

		<guid isPermaLink="false">http://www.astrobetter.com/?p=5559</guid>
		<description><![CDATA[What tools (or self-rolled code) do people prefer when making big publishable figures of spectra?  The example given was an echelle spectrum, where the spectrum is loooong, and has many spectral orders to stack onto one or more pages of the journal. Since this is a shamelessly self-generated Ask AstroBetter, I will award a beer [...]]]></description>
			<content:encoded><![CDATA[<p></p><p>What tools (or self-rolled code) do people prefer when making big publishable figures of spectra?  The example given was an echelle spectrum, where the spectrum is loooong, and has many spectral orders to stack onto one or more pages of the journal.</p>
<p>Since this is a shamelessly self-generated Ask AstroBetter, I will award a beer for the best answer (or source code.)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.astrobetter.com/pretty-plotting-of-spectra-ask-astrobetter/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Digitize that figure, fast</title>
		<link>http://www.astrobetter.com/digitize-that-figure-fast/</link>
		<comments>http://www.astrobetter.com/digitize-that-figure-fast/#comments</comments>
		<pubDate>Thu, 17 Nov 2011 13:00:23 +0000</pubDate>
		<dc:creator>Jane Rigby</dc:creator>
				<category><![CDATA[applications]]></category>
		<category><![CDATA[figures]]></category>

		<guid isPermaLink="false">http://www.astrobetter.com/?p=5262</guid>
		<description><![CDATA[Here&#8217;s a common workflow:  &#8221;I want to overplot a curve from the literature on my new plot.  I could write the author and wait several days for them to dig up the plot file and send me the digitized version, but I want to compare now!&#8221; One solution is to digitize the published plot. I [...]]]></description>
			<content:encoded><![CDATA[<p></p><p>Here&#8217;s a common workflow:  &#8221;I want to overplot a curve from the literature on my new plot.  I could write the author and wait several days for them to dig up the plot file and send me the digitized version, but I want to compare now!&#8221; One solution is to digitize the published plot.</p>
<p>I used to use <a href="http://adsdoc.harvard.edu/abs_doc/help_pages/dexter.html">Dexter</a>, but now I&#8217;m in love with <a href="http://www.arizona-software.ch/graphclick/">GraphClick</a> ($8, shareware.)  Just screengrab the plot, paste it<div class="toggle"> into GraphClick, click a few key points on the x and y axes and type in coordinates, and then either choose your data by hand, or use one of GraphClick&#8217;s curve-finding algorithms to automatically identify data.  You can organize your digitized data into multiple datasets, which you can save as text files.  Plus you can save the whole project, should you need to come back later and alter a fit.</p>
<p>Here&#8217;s an example from a recent paper (Mannucci et al. 2010, Fig. 6).  I used the curve-finding algorithm to follow one of the curves; the digitized points are shown by little red dots.  This is a fairly perverse case, as there are multiple overlapping curves; but it took less than a half-hour, start to finish, including send the output text files to my collaborator.</p>
<p><a href="http://www.astrobetter.com/wp-content/uploads/2011/11/graphclic.jpg"><img class="alignleft size-large wp-image-5263" title="graphclic" src="http://www.astrobetter.com/wp-content/uploads/2011/11/graphclic-1024x660.jpg" alt="" width="614" height="396" /></a></p>
</div>]]></content:encoded>
			<wfw:commentRss>http://www.astrobetter.com/digitize-that-figure-fast/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>What Vector Drawing Packages Are Available? [Ask AstroBetter]</title>
		<link>http://www.astrobetter.com/vector-drawing-packag/</link>
		<comments>http://www.astrobetter.com/vector-drawing-packag/#comments</comments>
		<pubDate>Mon, 28 Mar 2011 10:00:51 +0000</pubDate>
		<dc:creator>saurav</dc:creator>
				<category><![CDATA[applications]]></category>
		<category><![CDATA[figures]]></category>
		<category><![CDATA[InkScape]]></category>
		<category><![CDATA[latex]]></category>
		<category><![CDATA[OmniGraffle]]></category>
		<category><![CDATA[xfig]]></category>

		<guid isPermaLink="false">http://www.astrobetter.com/?p=4480</guid>
		<description><![CDATA[Matthew K. sent in a question for our Ask AstroBetter series: What vector graphics drawing package do you use for your figures? I&#8217;ve been using xfig for all my &#8220;hand drawn&#8221; plots, but I wonder if anyone has successfully moved on to more recent drawing packages &#8230; [a package] to draw simple figures like optical [...]]]></description>
			<content:encoded><![CDATA[<p></p><p>Matthew K. sent in a question for our <em>Ask AstroBetter</em> series:</p>
<blockquote><p>What vector graphics drawing package do you use for your figures?</p>
<p>I&#8217;ve been using <em><a href="http://www.xfig.org/">xfig</a></em> for all my &#8220;hand drawn&#8221; plots, but I wonder if anyone has successfully moved on to more recent drawing packages &#8230; [a package] to draw simple figures like optical layouts or circuit diagrams, where freehand drawing is not good enough and you want text boxes with aligned text in them, something similar to <em><a href="http://inkscape.org/">Inkscape</a></em>.</p></blockquote>
<p>Ideally, Matthew would like the package to</p>
<blockquote>
<ul>
<li>have binary/compilable versions for all major platforms</li>
<li>be able to organize each item in a layer</li>
<li>snap items to grids of definable size</li>
<li>include other graphics (both vector and pixel) as input elements</li>
<li>export to PS/PDF</li>
</ul>
</blockquote>
<p><div class="toggle"><br />
I would recommend <a href="http://www.omnigroup.com/products/omnigraffle/">OmniGraffle</a>, which <a href="https://store.omnigroup.com/edu/943861224d0accd1ffffffff/" class="broken_link">costs</a> $59.95 for the Standard and $119.95 for the Pro version for a single-user license with educational discount (along with a free two-week trial period), for Mac users. While it does <em>not</em> meet (at least) one of the above requirements, it is a fairly powerful and easy-to-use software.</p>
<p>Another excellent option, especially if you do not care about GUI,  is using LaTeX&#8217;s <a href="http://sourceforge.net/projects/pgf/">pgf and tikz packages</a>.  While layers can be tricky and learning curve is steep, it can do pretty much any schematic drawing, unless you are an engineer designing <em>actual </em>circuit boards (see some nifty examples <a href="http://www.texample.net/tikz/examples/all/">here</a>). And it is open source!</p>
<p>A quick look around the web tells me that the open source <a href="http://opencircuitdesign.com/xcircuit/">XCircuit</a> and CADsoft&#8217;s <a href="http://www.cadsoftusa.com/">Eagle</a> are also used &#8220;widely&#8221; for schematic drawings.  So what programs do you all use to <em>draw</em> your figures?</p>
<p><em>Got a nagging question? Ask AstroBetter by sending it to tips@astrobetter.com.</em></p>
</div>]]></content:encoded>
			<wfw:commentRss>http://www.astrobetter.com/vector-drawing-packag/feed/</wfw:commentRss>
		<slash:comments>9</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>Making RGB images from FITS files with python/matplotlib.</title>
		<link>http://www.astrobetter.com/making-rgb-images-from-fits-files-with-pythonmatplotlib/</link>
		<comments>http://www.astrobetter.com/making-rgb-images-from-fits-files-with-pythonmatplotlib/#comments</comments>
		<pubDate>Fri, 22 Oct 2010 16:24:54 +0000</pubDate>
		<dc:creator>Jessica</dc:creator>
				<category><![CDATA[figures]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[analysis]]></category>

		<guid isPermaLink="false">http://www.astrobetter.com/?p=3221</guid>
		<description><![CDATA[Converting astronomical data taken in multiple filters into representative-color RGB images often provides one of the most visually appealing (and informative) views of a target. This can be done in ds9 very easily; however, if you want a little more control, then python/matplotlib can be used in a very similar fashion. I also note that [...]]]></description>
			<content:encoded><![CDATA[<p></p><p><a href="http://www.astrobetter.com/wp-content/uploads/2010/10/w51a_3color_ukidss.png"><img class="alignright size-medium wp-image-3353" title="w51a_3color_ukidss" src="http://www.astrobetter.com/wp-content/uploads/2010/10/w51a_3color_ukidss-300x300.png" alt="" width="300" height="300" /></a>Converting astronomical data taken in multiple filters into representative-color RGB images often provides one of the most visually appealing (and informative) views of a target. This can be done in ds9 very easily; however, if you want a little more control, then python/matplotlib can be used in a very similar fashion. I also note that <a href="http://aplpy.sourceforge.net/documentation/index.html">APLpy</a> has excellent capabilities for images with proper World Coordinate System headers already (see the <a href="http://aplpy.sourceforge.net/documentation/howto_rgb.html">APLpy RGB tutorial</a>). APLpy is far easier to use, but if you don&#8217;t have that choice, then you can use matplotlib as I am going to show below.</p>
<p>First, lets assume we are starting with three images, say J.fits, H.fits, and K.fits and that these images all have the same plate scale, the same angle, and the same position on the sky but lacks WCS information (as is often the case for ground-based OIR observations). Load up the images into numpy arrays using the pyfits module.</p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;"><span style="color: #ff7700;font-weight:bold;">import</span> pyfits
<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> pylab <span style="color: #ff7700;font-weight:bold;">as</span> py
<span style="color: #ff7700;font-weight:bold;">import</span> img_scale
&nbsp;
j_img = pyfits.<span style="color: black;">getdata</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'J.fits'</span><span style="color: black;">&#41;</span>
h_img = pyfits.<span style="color: black;">getdata</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'H.fits'</span><span style="color: black;">&#41;</span>
k_img = pyfits.<span style="color: black;">getdata</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'K.fits'</span><span style="color: black;">&#41;</span></pre></div></div>

<p><div class="toggle"><br />
You can use pylab.imshow on a NxMx3 array; however, each layer of the image must first be mapped onto the luminosity scale. This is done with a module called img_scale.py that I borrowed from Min-Su Shin at U. of Michigan who very generously freely distributed his code (thanks!). You can get img_scale.py from this <a href="http://www.astrobetter.com/wiki/tiki-index.php?page=RGB+Images+with+matplotlib">AstroBetter wiki page</a>. Using this module you can linear, log, sqrt, or asinh stretch each color channel independently and set minimum or maximum flux values.</p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;">img = np.<span style="color: black;">zeros</span><span style="color: black;">&#40;</span><span style="color: black;">&#40;</span>j_img.<span style="color: black;">shape</span><span style="color: black;">&#91;</span><span style="color: #ff4500;">0</span><span style="color: black;">&#93;</span>, j_img.<span style="color: black;">shape</span><span style="color: black;">&#91;</span><span style="color: #ff4500;">1</span><span style="color: black;">&#93;</span>, <span style="color: #ff4500;">3</span><span style="color: black;">&#41;</span>, dtype=<span style="color: #008000;">float</span><span style="color: black;">&#41;</span>
img<span style="color: black;">&#91;</span>:,:,<span style="color: #ff4500;">0</span><span style="color: black;">&#93;</span> = img_scale.<span style="color: black;">sqrt</span><span style="color: black;">&#40;</span>k_img, scale_min=<span style="color: #ff4500;">0</span>, scale_max=<span style="color: #ff4500;">10000</span><span style="color: black;">&#41;</span>
img<span style="color: black;">&#91;</span>:,:,<span style="color: #ff4500;">1</span><span style="color: black;">&#93;</span> = img_scale.<span style="color: black;">sqrt</span><span style="color: black;">&#40;</span>h_img, scale_min=<span style="color: #ff4500;">0</span>, scale_max=<span style="color: #ff4500;">10000</span><span style="color: black;">&#41;</span>
img<span style="color: black;">&#91;</span>:,:,<span style="color: #ff4500;">2</span><span style="color: black;">&#93;</span> = img_scale.<span style="color: black;">sqrt</span><span style="color: black;">&#40;</span>j_img, scale_min=<span style="color: #ff4500;">0</span>, scale_max=<span style="color: #ff4500;">10000</span><span style="color: black;">&#41;</span></pre></div></div>

<p>Finally, we can display the image:</p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;">py.<span style="color: black;">clf</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
py.<span style="color: black;">imshow</span><span style="color: black;">&#40;</span>img, aspect=<span style="color: #483d8b;">'equal'</span><span style="color: black;">&#41;</span>
py.<span style="color: black;">title</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'Blue = J, Green = H, Red = K'</span><span style="color: black;">&#41;</span>
py.<span style="color: black;">savefig</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'my_rgb_image.png'</span><span style="color: black;">&#41;</span></pre></div></div>

<p>If your input images don&#8217;t have the same rotation angles, plate scales, or positions, then IRAF&#8217;s handy <em>imlintran </em>can be used to rescale, rotate, and translate. This can still be done in python via pyraf. Here is an example of calling imlintran from within python for a J.fits image that I want to rotate, shift, and rescale to match H and K images. I will assume the H and K images have a position angle of zero.</p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;"><span style="color: #ff7700;font-weight:bold;">from</span> pyraf <span style="color: #ff7700;font-weight:bold;">import</span> iraf <span style="color: #ff7700;font-weight:bold;">as</span> ir
&nbsp;
h_img = pyfits.<span style="color: black;">getdata</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'H.fits'</span><span style="color: black;">&#41;</span>
k_img = pyfits.<span style="color: black;">getdata</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'K.fits'</span><span style="color: black;">&#41;</span>
scaleK = <span style="color: #ff4500;">0.1</span>   <span style="color: #808080; font-style: italic;"># arcsec per pixel</span>
scaleJ = <span style="color: #ff4500;">0.15</span> <span style="color: #808080; font-style: italic;"># arcsec per pixel)</span>
paJ = <span style="color: #ff4500;">30.0</span>  <span style="color: #808080; font-style: italic;"># degrees</span>
&nbsp;
ir.<span style="color: black;">unlearn</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'imlintran'</span><span style="color: black;">&#41;</span>
&nbsp;
ir.<span style="color: black;">imlintran</span>.<span style="color: black;">boundary</span> = <span style="color: #483d8b;">'constant'</span>
ir.<span style="color: black;">imlintran</span>.<span style="color: black;">constant</span> = <span style="color: #ff4500;">0</span>
ir.<span style="color: black;">imlintran</span>.<span style="color: black;">interpolant</span> = <span style="color: #483d8b;">'spline3'</span>
ir.<span style="color: black;">imlintran</span>.<span style="color: black;">fluxconserve</span> = <span style="color: #483d8b;">'yes'</span>
&nbsp;
<span style="color: #808080; font-style: italic;"># the input pixel position of a reference source</span>
ir.<span style="color: black;">imlintran</span>.<span style="color: black;">xin</span> = <span style="color: #ff4500;">0</span>
ir.<span style="color: black;">imlintran</span>.<span style="color: black;">yin</span> = <span style="color: #ff4500;">0</span>
&nbsp;
<span style="color: #808080; font-style: italic;"># the output pixel position of a reference source</span>
ir.<span style="color: black;">imlintran</span>.<span style="color: black;">xout</span> = <span style="color: #ff4500;">10</span>
ir.<span style="color: black;">imlintran</span>.<span style="color: black;">yout</span> = <span style="color: #ff4500;">10</span>
&nbsp;
<span style="color: #808080; font-style: italic;"># Set the output size of the final image</span>
ir.<span style="color: black;">imlintran</span>.<span style="color: black;">ncols</span> = k_img.<span style="color: black;">shape</span><span style="color: black;">&#91;</span><span style="color: #ff4500;">1</span><span style="color: black;">&#93;</span>
ir.<span style="color: black;">imlintran</span>.<span style="color: black;">nlines</span> = k_img.<span style="color: black;">shape</span><span style="color: black;">&#91;</span><span style="color: #ff4500;">0</span><span style="color: black;">&#93;</span>
&nbsp;
ir.<span style="color: black;">imlintran</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'j.fits'</span>, <span style="color: #483d8b;">'j_rot_scale.fits'</span>, angleJ, angleJ, scaleK/scaleJ, scaleK/scaleJ<span style="color: black;">&#41;</span>
&nbsp;
j_img = pyfits.<span style="color: black;">getdata</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'j_rot_scale.fits'</span><span style="color: black;">&#41;</span></pre></div></div>

<p>Alternatively, you can use scipy.ndimage.interpolate to shift images.</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: black;">ndimage</span> <span style="color: #ff7700;font-weight:bold;">import</span> interpolation <span style="color: #ff7700;font-weight:bold;">as</span> interp
&nbsp;
old_j = pyfits.<span style="color: black;">getdata</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'j.fits'</span><span style="color: black;">&#41;</span>
new_j = interp.<span style="color: black;">shift</span><span style="color: black;">&#40;</span>old_j, <span style="color: black;">&#91;</span>shiftY, shiftX<span style="color: black;">&#93;</span><span style="color: black;">&#41;</span></pre></div></div>

<p>The image attached in this post was plotted using imshow as described above and is a JHK color composite from the UKIDSS galactic plane survey.</p>
</div>]]></content:encoded>
			<wfw:commentRss>http://www.astrobetter.com/making-rgb-images-from-fits-files-with-pythonmatplotlib/feed/</wfw:commentRss>
		<slash:comments>3</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>
]]></content:encoded>
			<wfw:commentRss>http://www.astrobetter.com/3d-plotting-in-python-with-matplotlib-mplot3d/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Your friend Convert</title>
		<link>http://www.astrobetter.com/your-friend-convert/</link>
		<comments>http://www.astrobetter.com/your-friend-convert/#comments</comments>
		<pubDate>Wed, 18 Nov 2009 20:25:00 +0000</pubDate>
		<dc:creator>Jane Rigby</dc:creator>
				<category><![CDATA[applications]]></category>
		<category><![CDATA[figures]]></category>
		<category><![CDATA[convert]]></category>
		<category><![CDATA[imagemagick]]></category>

		<guid isPermaLink="false">http://www.astrobetter.com/?p=939</guid>
		<description><![CDATA[Do you use the tool &#8220;convert&#8221; to manipulate plots and images?  It&#8217;s simple, powerful and downright great!  Quick examples: Modify a plot for presentation use, by swapping to a black background with white lines, so it&#8217;s easier to read on a screen: &#62; convert  -negate frompaper.ps  forscreen.jpg Make a thumbnail: &#62; convert -geometry 50&#215;50 big.jpg [...]]]></description>
			<content:encoded><![CDATA[<p></p><p>Do you use the tool &#8220;<a href="http://amath.colorado.edu/computing/software/man/convert.html">convert</a>&#8221; to manipulate plots and images?  It&#8217;s simple, powerful and downright great!  Quick examples:</p>
<p>Modify a plot for presentation use, by swapping to a black background with white lines, so it&#8217;s easier to read on a screen:</p>
<blockquote><p>&gt; convert  -negate frompaper.ps  forscreen.jpg</p></blockquote>
<p>Make a thumbnail:</p>
<blockquote><p>&gt; convert -geometry 50&#215;50 big.jpg thumbnail.gif</p></blockquote>
<p><div class="toggle">Blur an image w a Gaussian (for easier Journal Club reading of little datapoints):</p>
<blockquote><p>&gt;convert -gaussian 2&#215;2  hard2read.ps  easy2read.gif</p></blockquote>
<p>Other tools can do all these tasks, of course.  The advantage of Convert is that it&#8217;s very simple, fast to type, and scriptable.  Convert is part of the open-source <a href="http://www.imagemagick.org/script/index.php">ImageMagick</a> package, which is easy to install in linux or OS X.   Quick, what are some other astronomy-relevant uses of Convert?</p>
</div>]]></content:encoded>
			<wfw:commentRss>http://www.astrobetter.com/your-friend-convert/feed/</wfw:commentRss>
		<slash:comments>1</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[figures]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[APLpy]]></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 [...]]]></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>
]]></content:encoded>
			<wfw:commentRss>http://www.astrobetter.com/hungry-for-plots-get-some-aplpy/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
	</channel>
</rss>

