Astronomical Data in Python: Notebooks#
This is self-study material: the workshop is not offered live now, but the notebooks are maintained and run on Colab.
Astronomical Data in Python is an introduction to tools and practices for working with astronomical data. Topics covered include:
Writing queries that select and download data from a database.
Using data stored in an Astropy
Tableor PandasDataFrame.Working with coordinates and other quantities with units.
Storing data in various formats.
Performing database join operations that combine data from multiple tables.
Visualizing data and preparing publication-quality figures.
As a running example, we will replicate part of the analysis in a 2018 paper, “Off the beaten path: Gaia reveals GD-1 stars outside of the main stream” by Adrian M. Price-Whelan and Ana Bonaca.
This material was developed in collaboration with The Carpentries and the Astronomy Curriculum Development Committee, and supported by funding from the American Institute of Physics through the American Astronomical Society. It became the Data Carpentry lesson Foundations of Astronomical Data Science, which The Carpentries retired in 2026. The lesson pages remain online, and they include notes for instructors, but these notebooks are the version that is maintained.
I am grateful for contributions from the members of the committee – Azalee Bostroem, Rodolfo Montez, and Phil Rosenfield – and from Erin Becker, Brett Morris and Adrian Price-Whelan.
Level: intermediate. You should be familiar with basic Python, including lists, dictionaries, and functions, but not necessarily Astropy or Pandas; and with astronomy at the undergraduate level.
Length: seven notebooks, about 20 hours in total.
The notebooks#
The pages on this site show the notebooks with solutions. To do the exercises, run the versions with blanks on Colab:
Queries: connecting to the Gaia archive and writing ADQL queries. Exercises on Colab
Coordinates and units:
Quantityobjects, coordinate frames, and selecting stars in a region of the sky. Exercises on ColabProper motion: transforming to the GD-1 frame and selecting stars by proper motion with Pandas. Exercises on Colab
Transformation and selection: doing the proper-motion selection as part of the query. Exercises on Colab
Joining tables: combining Gaia data with Pan-STARRS photometry. Exercises on Colab
Photometry: a color-magnitude diagram and a second round of selection. Run on Colab
Visualization: a publication-quality figure with several panels. Exercises on Colab
The notebooks query the Gaia archive, which limits anonymous users to queries of one minute and 50,000 rows; Notebook 1 explains how to register and log in. The code and the data files are in the GitHub repository, which explains how to run the notebooks on your own computer.
See also my other workshops.
The code is available under the MIT License. The text is available under the Creative Commons Attribution 4.0 International License.