Solutions to errors with APLpy show_regions()

Trying to display Ds9 region files on top of APLpy plots threw up two errors.

Creating an aplpy.FITSFigure subplot using some standard code in a python script worked fine, until the line where the show_regions() call to pyregion encountered an error – TypeError: must be classobj, not CardList – in pyregion/wcs_helper.py. The python I’m using is:

[code language=”python”]
import aplpy
import pyparsing
import pyregion
import pyfits
import matplotlib.pyplot as pyplot
import matplotlib as mpl

fig = pyplot.figure(figsize=(12, 12))
f1 = aplpy.FITSFigure(‘DSS_UGC4277.fits’, figure=fig,
subplot=[0.15,0.6275,0.222,0.222])
f1.set_frame_color(‘black’)
f1.set_tick_labels_font(size=’10’)
f1.set_axis_labels_font(size=’12’)
f1.set_tick_labels_format(xformat=’hh:mm:ss’,yformat=’dd:mm:ss’)
f1.set_tick_color(‘black’)
f1.recenter(x=123.4877,y=52.647714,radius=0.065)
f1.set_tick_xspacing(0.1)
f1.show_colorscale(stretch=’log’,cmap=’gist_heat’)
f1.show_regions(‘DSS_UGC4277.reg’)
[/code]

A bit of googling gave me the solution of reinstalling astropy and APLpy to update them to their latest versions.

[code language=”sh”]
~> git clone git://github.com/astropy/astropy.git
~> cd astropy
~> python setup.py install

~> git clone git://github.com/aplpy/aplpy.git
~> cd aplpy
~> python setup.py install
[/code]

This took care of the first error, but replaced it with a second error also occurring somewhere in pyregion/wcs_helper.py.

~> AttributeError: ‘Header’ object has no attribute ‘ascardlist’

I found that manually updating wcs_helper.py according to a recent commit fixed the problem.

Posted in Code, Programming | Tagged , | Leave a comment