skip to content

Coding

Below I list just a few of my personal coding projects that I have developed throughout the years. These are complete enough for others to use as they wish. In addition to the packages below, I keep numerous other tools on github at nlcpython and nlctools. I make no guarantees about readability of any of the code I keep on github.

Danube - I use DS9 for opening FITS files. DS9 is like a swiss-army knife; it has a tool for everything. Unfortunately, some of the pulldown menus are ridiculously long. On a laptop, these menus can literally be longer than the height of the screen (thanks to "widescreen" laptops, which in my mind are "vertically challenged".) So, to actually use DS9 on my laptop, I wrote a companion program to organize many of the more used functions in DS9 in a simpler way. In keeping with the Star Trek theme, I named the program danube.py. This uses tkinter for the GUI (built into python) and the XPA access points to control DS9 itself. You can get it here

Go - As I learned Linux/UNIX, I became dissatisfied with the shell. I eventually started adding my own commands for things I perceived to be missing. I added things like bookmarks, history, back and up commands, trash commands, and much more. You can get it all right here

PyWIP - WIP is a plotting package included with Miriad, the official software package for CARMA. While outdated, back in 2007 it was my goto plotting package. I always felt it was rather clunky, so, eventually, when I should have been writing my thesis, I made a python wrapper around WIP and called it PyWIP. With PyWIP you have a significantly improved plotting package which can be accessed from python. There is significant documentation and examples which can be gotten here. The documentation is also online.

After many years of usage, this package is no longer being maintained. I am slowly transitioning to using matplotlib in conjunction with pyfits. However, there are still some things I can do easier with PyWIP than with matplotlib. PyWIP is a very polished product, and I am quite proud of it. Furthermore, it is nice to have a plotting package that works the way I think plotting should work.

readcmd - This is a simple package to read command line arguments in a keyword=value format. It is still my favorite method for reading command line arguments. Its advantages are that it is easy for the programmer to read the code and figure out what keywords are available, easy for a programmer to write the code for new keywords, and is still very powerful. It includes numerous features for type-checking and error-checking. html documentation and python code. The python code contains a detailed version history going back to 2003 (when it was called miriad.py).

worldpos - A common problem I run into in astronomy is converting world coordinates to pixel coordinates on an image or vice-versa. This can be very tricky because of the numerous possible projections. Fortunately, others have written C code to solve all this. I adapted the C code to python. To my knowledge, this is the only independent python implementation of wcs/xy pixel conversions. (There is now a package called pywcs that can do the same thing). worldpos doesn't require anything except python (pyfits is probably also helpful to read in the fits header, though you can work around this if you don't have it). You can download worldpos.py here. The documentation is also online.

Links

I wrote this python tutorial as a graduate student when I was teaching a short class on python to new graduate students. It covers a few basic features of python to try and motivate why python is so great. My python tutorial

Nicholas Chapman 2014-May-27