[AstroPy] aplpy.FITSFigure only works from ipython

Jazmin Berlanga Medina jazmin.berlanga at gmail.com
Wed Jun 25 13:08:56 EDT 2014


I realize that the code snippet (which uses pylab outside of ipython
--pylab just fine) I just sent out seems to contradict what I said about
pylab not having the same functionality outside of ipython.  I'd like to
clarify that for non-FITSFigure plot commands, the display seems to work,
but if I make the same import statements and then try to use
aplpy.FITSFigure, the display does not show.

I don't understand what's going on, I can only speculate that aplpy may be
configured to use some settings that are easily accessible from ipython
--pylab but not from the python interpreter or programs run from the
command line, even after importing all the pylab functions.

------------------------------

Message: 4
Date: Wed, 25 Jun 2014 11:57:00 -0500
From: Jazmin Berlanga Medina <jazmin.berlanga at gmail.com>
Subject: Re: [AstroPy] aplpy.FITSFigure only works from ipython
        --pylab
To: astropy at scipy.org
Message-ID:
        <CACp8_VqnL7ENbx1tr-cxjbXfAVNC0cib9RgVg-Bghjq5Kyf96w at mail.gmail.com>
Content-Type: text/plain; charset="utf-8"

Unfortunately, show() is not a function defined within FITSFigure.

I took a look at the source code, dug around for what makes graph displays
work in ipython with --pylab enabled, and I found the following pages.  The
information I read about matplotlib there implies that you can't use both
the MATLAB-esque syntax of pylab outside of ipython --pylab and still have
ipython's gui front-end behavior--you would have to use the matplotlib
syntax along with some interactive on & off switches.

I still could not find information specific to APLpy, and what you need to
do to get it to work outside of ipython --pylab--surely not everyone with
scripts that call this function is running them by copying/pasting into
ipython or runs all their codes as ipython notebooks.

http://python4astronomers.github.io/plotting/matplotlib.html#appendix-pylab-and-pyplot-and-numpy
http://matplotlib.org/faq/usage_faq.html#matplotlib-pylab-and-pyplot-how-are-they-related
http://aplpy.readthedocs.org/en/v0.9.11/_modules/aplpy/aplpy.html#FITSFigure


Since, at the moment, I'm not worried about finely-tuned graphs drawing
from the FITS file's data (the same file I want to overlay plots on), I
decided to look for an alternate to APLpy.  You can get a simple plot on
top of a FITS image using astropy.io.fits and matplotlib or pylab.

For instance, the following code will plot a FITS image, then some x,y
values, then finally display that image.

------------------
from pylab import *
from astropy.io import fits

galaxy_image = fits.getdata('my_image.fits')
imshow(galaxy_image,cmap='
gray',origin='lower') # My image was originally
flipped upside down, thus the origin argument.

plot(x_values_list,y_values_list)

show()
------------------


If anyone has some info on running APLpy functions outside of ipython
--pylab, I'd still like to know for future use--I hate to reinvent the
wheel when this module already has so many great tools.

Thanks,
Jazmin


-- 

Jazmin Berlanga M.
M.S. Student
Department of Physics
University of Arkansas
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/astropy/attachments/20140625/c2a28db1/attachment.html>


More information about the AstroPy mailing list