Python Links

If you are new to Python, we're recommending that you install the Anaconda distribution on your computer. But if you already are up and running and happy with some other Python install, that's fine too, but you will want to make sure that astropy is installed (Anaconda installs/updates astropy automatically)..

Here is the general documentation for the various packages included in Anaconda.

And for writing/debugging python code, many of you use jupyter notebooks, which work fine. I have also found using the Spyder environment to be helpful.

Getting help

First of all, try python inline help. For example, help on the scatter command can be obtained by saying help(plt.scatter) (presuming you've already loaded the pyplot package, i.e. import matplotlib.pyplot as plt)

Second, check some online tutorials/references, such as:
Third (or maybe first), try THE GOOGLE. For example, if I want to figure out how to fit a curve to data using python, I'll just google fit curve to data python. Or if I have a bizarre error message that I don't understand, I'll google <bizarre error message> python. adding astropy to the search will often give you astro-specific results as well, which can be particularly helpful. You may have to poke around with the results of those searches to find the best answer, but it usually works out.

Fourth, ask your classmates, or the TA, or the python mentor, or me. I put this last not because we are reluctant to help -- we're happy to do so! -- but rather because the first three things are available to you 24/7 and give immediate (although admittedly not always helpful) responses.

Why Python?

A survey of coding tools used by research astronomers at all levels (left) and PhD astronomy students (right).
Taken from Momcheva & Tollerud (2015).