[AstroPy] aplpy.FITSFigure only works from ipython --pylab

Jazmin Berlanga Medina jazmin.berlanga at gmail.com
Wed Jun 25 12:57:00 EDT 2014


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

------------------------------
>
> Message: 2
> Date: Tue, 24 Jun 2014 16:09:29 -0600
> From: Alexander Joseph Conley <Alexander.Conley at Colorado.EDU>
> Subject: Re: [AstroPy] aplpy.FITSFigure only works from ipython
>         --pylab
> To: Astronomical Python mailing list <astropy at scipy.org>
> Message-ID: <9A2E23F4-C85B-41FC-B1E8-4D7B5F6D93E9 at colorado.edu>
> Content-Type: text/plain; charset="us-ascii"
>
> Try fig.show()
> On Jun 24, 2014, at 3:48 PM, Jazmin Berlanga Medina <
> jazmin.berlanga at gmail.com> wrote:
>
> > Hi all,
> >
> > I've tried posting this topic to the APLpy users group on Google, but
> the posting has failed (and I see no threads at all on their page, so the
> group may be inactive or having issues with their page).
> >
> > Is there a reason why aplpy.FITSFigure's display would work only from
> ipython called with the --pylab option, but not from the python interpreter
> or from a script called at the command line (or ipython not called with
> --pylab)?
> >
> > I can get the commands in my script to show me a display when I invoke
> Python with ipython --pylab, but not in any other circumstance.  I've tried
> combing through APLpy's documentation and googling for a connection between
> pylab/aplpy, but I can't find anything.  I need to be able to call this
> function from a script or otherwise be able to script plots on top of FITS
> files, and a simple addition of import pylab does not work.
> >
> > Contents of program:
> >
> > #!/usr/bin/env python
> >
> > import aplpy
> >
> > fig = aplpy.FITSFigure('2.100Gyr_crop.fit')
> >
> > fig.show_grayscale()
> >
> >
> > Thanks!
> > Jazmin
> >
> > --
> >
> > Jazmin Berlanga M.
> > M.S. Student
> > Department of Physics
> > University of Arkansas
> > _______________________________________________
> > AstroPy mailing list
> > AstroPy at scipy.org
> > http://mail.scipy.org/mailman/listinfo/astropy
>



-- 

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/ce8e7424/attachment.html>


More information about the AstroPy mailing list