Ellipsefits
Simple Python code for reading, analyzing, and plotting ellipse fits to galaxy isophotes.
Install / Use
/learn @perwin/EllipsefitsREADME
ellipsefits
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).
Really Simple Installation:
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.
Examples of use:
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)
<img src="extra/n5831_efit_raw.png" width=70%>
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)
<img src="extra/n5831_efit_nice.png" width=75%>
Requirements:
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.
License
This code is released under a standard 3-clause BSD license.
Related Skills
node-connect
347.6kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
108.4kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
347.6kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
347.6kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
