This is Python code for reading, processing, and plotting isophotal ellipse fits generated by the IRAF/STSDAS "ellipse" task (part of the stsdas.analysis.isophote package).
For now, the simplest way to install this is to copy the files ellipsefits.py
and
datautils.py
to somewhere on your Python path. (You can also copy doellipse.cl
to somewhere on your IRAF script path if you think it might be useful for generating
ellipse fits.)
Eventually this will, I hope, turn into an Astropy affiliated package, but the setup for that is very incomplete at this point.
First, generate ellipse-fit output using the IRAF task ellipse
(part of
the STSDAS package, in stsdas.analysis.isophote), then convert the
output to either FITS table format or text-file format using the tcopy
or tdump
tasks (part of the TABLES package). The included IRAF script
doellipse.cl will automatically do both.
E.g., to fit an object in the image n5831rss.fit
with initial guesses
for the center of (x,y) = (1579.6, 897.5), initial semi-major axis of 30
pixels, initial ellipse position angle = 50 degrees and ellipticity =
0.2, and maximum semi-major axis = 220 pixels:
cl> doellipse n5831rss.fit el_n5831rss 1579.6 897.5 30 50 0.2 220
This will generate three output files: el_n5831rss.tab
(STSDAS TABLES format),
el_n5831rss_tdump.txt
(text table), and el_n5831rss.fits
(FITS table).
Then, in Python:
>>> import ellipsefit
>>> efit = ellipsefit.ReadEllipse("/path/to/el_n5831rss.fits")
>>> ellipsefit.PlotEllPA(efit)
The same, but now also specifying the pixel scale of the image (here, 0.396 arcsec/pixel) and its orientation on the sky, so that plots will display semi-major axis in arc seconds and correct position angle on the sky. The plotting command now specifies log spacing on the x-axis, a restricted x-axis range, an expanded y-axis range for the ellipticity, a restricted y-axis range for the position-angle plot, and merges the separate PA and ellipticity plots:
>>> efit = ellipsefit.ReadEllipse("/path/to/el_n5831rss.fits", pix=0.396, telPA=89.99)
>>> ellipsefit.PlotEllPA(efit, xlog=True, xrange=[1,100], erange=[0,0.35], parange=[100,155], merge=True)
This should work under any recent version of Python 3; it also works in Python 2.7 (and probably 2.6 as well, though I haven't tested that in a while).
Required Python libraries:
- numpy
- scipy
- matplotlib
- astropy
It cannot read the standard (STSDAS TABLES) output table files generated by
ellipse
; these tables should be converted to FITS tables using tcopy
or to
text file using tdump
(both of which are tasks in the STSDAS TABLES package).
The included IRAF script doellipse.cl
, which is a wrapper around the ellipse
task,
will automatically generate both conversions.
This code is released under a standard 3-clause BSD license.