Welcome to Python Bootcamp - a highly-condensed, fast-paced, incomplete tour of the Python language and some of its essential packages used in physics and astronomy with Python. This course is meant for students who are experienced programmers in a language other than Python. We will give you broad and shallow exposure to the plethora of tools that may be useful to you in Python, starting at the basics of the language and moving up to scientific computation in Python.
Bootcamp will be held in PAA 216 from 9am-4pm with a one hour lunch break beginning at noon, and short breaks throughout. Take the staircase surrounding the pendulum up to the second floor and walk south towards the planetarium to find the classroom.
Topics
In this two-day "course", we'll introduce you to:
- efficient calculations with numpy
- visualization with matplotlib
- writing functions and modules
- optimization with numpy and scipy
- object-oriented programming
- handling "big data" with HDF5
- astronomical calculations with astropy
- version control and collaboration with git and GitHub
Getting set up for Bootcamp
Before arriving at Bootcamp, we will assume that you have Python and the required packages installed. The easiest way to do that (and I very strongly encourage that you do it this way) is to use the Anaconda package manager. Download and install Anaconda (or miniconda if disk space is a concern) for Python 3, and then install the dependencies for this course with the following command in your terminal:
conda install numpy scipy astropy matplotlib h5py jupyter ipython
conda install -c astropy astroquery
This will download and install all of the required dependencies for our tutorials. Contact me if you have trouble getting set up before bootcamp begins (but be warned: I will only provide installation support if you're using anaconda)! If you plan to stick around for the git tutorial, you should also install git.
Testing your setup
You can test if you've successfully installed Python and the required depedencies by doing the following.
- Open a new terminal window, and type
ipython
. This will open an interactive iPython shell, giving you a prompt that saysIn [1]:
. - Copy this code to your clipboard:
import numpy
import scipy
import astropy
import matplotlib
import h5py
import astroquery
- Type into the iPython shell the word
paste
, and press enter. - If no errors are raised, you're ready for bootcamp. You may close the terminal window.
Instructor
Brett Morris is a fourth-year graduate student of Astronomy and Astrobiology. He maintains the astropy-affiliated package astroplan, among others.
Resources
In addition to the notebooks in this repository, we will use Jake Vanderplas' 2014 Python Bootcamp notebooks, which I've forked here.
Further reading
For additional resources on getting up to speed in Python, I recommend Jake's book A Whirlwind Tour of Python, which is currently available for free. If you're ready to go deeper, there are many freely available books on Python to try.
Preliminary schedule
Time | Lesson |
---|---|
Mon 9-10:30 | Basic training |
Mon 10:30-11:30 | Data structures |
Mon 11:30-12 | iPython |
Mon 1-2 | Functions, modules |
Mon 2-3:30 | Git intro |
Tues 9-10:30 | Numpy intro |
Tues 10:30-11 | Matplotlib intro |
Tues 11-12:00 | Optimization intro |
Tues 1-1:45 | Intro to astropy |
Tues 1:45-2:30 | Intro to OO |
Tues 2:30-3:00 | Intro to HDF5 |
Tues 3-4 | GitHub intro |