Over the course of the last 50 years, programming has become increasingly essential to the research of an astrophysicist and/or astronomer. In the early days, when Hubble discovered the existence of other galaxies, observational astronomy was performed by eye, with drawings, handwritten notes, and manual calculations and plots. The theory was a pencil-and-paper endeavor. Fast-forward through the invention of glass plate exposures to the modern era of CCD (charge-coupled device) telescopes, full-sky surveys, and supercomputer simulations, the importance of a solid foundation in computing becomes clear.
In fact, the need for a strong background in computer programming has drifted younger in the past decade or two — now, undergraduates are expected to be proficient in at least one language when conducting research and applying to graduate schools. Between 2014 and 2018, I taught the entry-level Python programming course at the UC Berkeley Astronomy Department. This is the text that I wrote for that course — but which I am continuing to update and revise.
What this Book Is
This text is designed to be an introduction to the Python programming language — which is now used nearly ubiquitously in astronomy — with applications to the types of tasks an undergraduate (or beginning graduate student) might have to tackle. It is not, in any way, meant to be comprehensive; my focus is on bringing you up to speed as efficiently and quickly as possible. This text might have useful information for those with a working knowledge of Python outside of a research setting but is primarily designed for those with no prior programming experience. By the end of this text, I hope to have shared enough to make you feel comfortable taking the first steps into research-type problems (of which this book will contain several examples), whether in an astronomy course, a research internship, or on-campus research.
Chapter 1 focuses on UNIX/Linux, and can be skipped initially if you want to jump into Python. More advanced topics can be found near the end of the book. The course accompanying this text is generally taught in 1 semester, and interactive tutorials for this text are available online.