Astronomy Education

Introductory Astronomy Codes
A set of introductory astronomy animations (Kepler's laws, Doppler shifts, parallax, ...) coded in python. These are also available on YouTube.

Codes from my Numerical Methods Class
There are a number of examples of various methods (mostly in python) on my course webpage: Numerical Methods for (Astro)Physics. Some of these are repeated below.
Simple Numerical PDE Examples

Godunov methods for linear advection
A simple secondorder accurate finitevolume method for the linear advection equation in onedimension. A choice of reconstruction is provided: Godunov (piecewise constant), Piecewise Linear, and Piecewise Parabolic (PPM). This advects the initial condition through a periodic domain. The code is structured to with the subroutines you would find in a typical hydrodynamics code. Sample output showing a tophat advected for 5 periods with 128 zones.
advect.f90
A python version (without ppm) is available on my github page:
advection.py 
2^{nd} order finite volume method for Burgers' equation
A simple Fortran secondorder accurate finitevolume method for the 1d Inviscid Burgers' Equation:
u_{t} + [1/2 u^{2}]_{x} = 0
A choice of limiters is provided, and periodic BCs are implemented. The code is structured to with the subroutines you would find in a typical hydrodynamics code.
burger.f90
An alternate python version is available on my github page:
burgers.py 
Viscous Burgers' equation solver
Solve:
u_{t} + [ 1/2 u^{2} ]_{x} = ε u_{xx}
using a secondorder Godunov method for advection and CrankNicolson implicit diffusion for the viscous term. The two processes are coupled together.
burgervisc.py

Multigrid examples
A simple python class for solving 1d Poisson and constantcoefficient Helmholtz equations on a finitevolume grid. The driver program (mg_test.py) solves u_{xx} = sin(x), u(0)=0, u(1)=0. The discretization is second order (mgconverge.png).
multigrid solver github page
Also see pyro for a 2d solver. 
Diffusion
Simple 1d secondorder explicit and implicit diffusion codes. The implicit code uses a CrankNicolson time discretization and the banded matrix solver from SciPy.
diffusion_explicit.py diffusion_implicit.py
Also see pyro for a 2d solver. 
Diffusionreaction equation
Solve:
φ_{t} = κ φ_{xx} + (1/τ) R(φ)
using CrankNicolson diffusion and Strangsplit reactions. This setup gives rises to a spreading burning front.
diffreact.py
Computational Hydrodynamics

pyro: hydro by example
A tutorial code and set of notes to introduce new students into computational hydrodynamics. The (mostly) python code implements 2d solvers for linear advection, compressible hydrodynamics, multigrid, implicit diffusion, and incompressible hydrodynamics.
The code and documentation can be found on the pyro website 
hydro1d: a 1d compressible hydro solver
A simple 1d compressible hydrodynamics code that implements piecewise constant (Godunov), piecewise linear, and piecewise parabolic (PPM) slope reconstruction in a finitevolume framework. Some simple test problems (e.g. Sod) are included.
get hydro1d

Castro: an AMR parallel hydro code
Castro solves the equations of compressible hydrodynamics using a dimensionally unsplit PPM method, includes reactions, support for a general equation of state, and self gravity, and uses an adaptive mesh refinement integration strategy with subcycling in time. Castro is developed primarily by my collaborators at CCSE/LBL (I've hacked a bit on the hydro and microphysics). Castro is opensource and distributed can be cloned/forked from its github page. 
Maestro: low Mach number stellar hydro
Maestro is optimized to solve low speed convective flow problems in tight hydrostatic equilibrium. A full description can be found on the Maestro page. Maestro can be cloned/forked from its github page.
Parallel Programming

OpenMP Relaxation Solver of Poisson's Equation
Solve the 2d Poisson equation with pure relaxation (we do a fixed number of iterations). This is parallelized with OpenMP.
relaxomp.f90 
MPI Relaxation Solver of Poisson's Equation
Solve the 2d Poisson equation with pure relaxation (we do a fixed number of iterations). This is parallelized with MPI, doing a onedimensional domain decomposition in the x direction.
relaxmpi.f90

Parallel I/O Tutorial
A simple parallel I/O tutorial showing various ways to output data from a parallel hydrodynamics code into a single HDF5 file.
Microphysics

Python interface to nuclear reaction rate databases
An objectoriented interface to the nuclear reaction databases (including JINA Reaclib).
pynucastro
Other Numerical Examples

Matplotlib Examples
Some useful bits for matplotlib that I've used.

Monte Carlo Demo (Poker Odds)
A simple demonstration of Monte Carlo techniques—computing the odds of the different hands in a straight 5card poker game.
poker.py
Utilities

Simple Backup Script
A simple script for automatically backing up several directories in your home directory to another disk mounted on your local system. To have this run automatically, set it up as a cron job.
backupmachine.py 
Fortran Makefile Dependency Generator
A simple simply python script to generate dependency pairs for Fortran 90 source files for use in makefiles.
dep.py 
ApJ Submission Formatter
A simple python script that takes a LaTeX ApJ manuscript and renames all the figures (both in the file and on disk) to conform to the f1.eps, f2.eps, ... naming convention that ApJ wants. Use at your own riskthis is still beta quality. See the notes contained within.
apjify.py

Research Journal
A python script to manage a research journal / logbook in LaTeX. It is distributed (uses git under the hood), so you can use it on all of the machines you work on and keep things in sync, and it is commandline driven, so the barrier to entry to make a journal entry is very low. It supports images in an entry, editing previous entries, and has simple subcommands to build and display your PDF journal.
pyjournal 
Makefile Examples
Makefile examples of increasing complexity, showing how to use macros, the clean target, file interdependencies, debug/production builds, debugging the makefile itself, and storing the git hash of your project into your source code at build time.
makefiles.tar 
mencoder Wrapper
A simple python script that can be used to convert a series of PNG images into AVI and MP4 movies (with MPEG4 encoding). Supports doubling frames and adding some extra frames at the end. The mencoder options picked seem to be supported on most platforms.
mkmovie.py