Astropy Tutorials: Learn how to do common astro tasks with astropy and Python

This is a guest post by Adrian Price-Whelan (@adrianprw), an NSF graduate fellow at Columbia University. Adrian works on tidal streams and Galactic dynamics, is an open source enthusiast, Python developer, and plays bass for death ray architect. He is also an instructor in the SciCoder workshops and Python workshops at AAS meetings.

Astropy is a community-developed Python package intended to provide much of the core functionality and common tools needed for astronomy and astrophysics research (c.f., IRAF, idlastro). In order to provide demonstrations of the package and subpackage features and how they interact, we are announcing Astropy tutorials. These tutorials are aimed to be accessible by folks with little-to-no python experience and we hope they will be useful exercises for those just getting started with programming, Python, and/or the Astropy package. (The tutorials complement the Astropy documentation, which provides more detailed and complete information about the contents of the package along with short examples of code usage.)

The Astropy tutorials work through software tasks common in astronomical data manipulation and analysis. For example, the “Read and plot catalog information from a text file” tutorial demonstrates using astropy.io.ascii for reading and writing ASCII data, astropy.coordinates and astropy.units for converting RA (as a sexagesimal angle) to decimal degrees, and then uses matplotlib for making a color-magnitude diagram an all-sky projection of the source positions.

http://i.imgur.com/08uBjAu.png

Several of the tutorials also demonstrate how to use matplotlib to make 2D images with different color maps, stretches, and colorbars.

http://i.imgur.com/744tSiD.png

http://i.imgur.com/7gP8NwN.png

http://i.imgur.com/cpKGJ1h.png

So far, we’ve made five tutorials:

We welcome feedback and improvements to these tutorials via the Astropy Tutorials repo on Github. If you find a typo or would like to clarify some text, please either create an issue or make the change yourself and then submit a pull request directly to the repository. Questions and/or comments about the tutorials are welcome on the astropy-dev mailing list.

If you are interested in contributing an IPython notebook as a tutorial, please check the README or contact the developer list. Also, if you have an idea for a tutorial or a tutorial request, please post to the developer list or leave a comment below. If you would like to contribute to this effort, but need some inspiration, check out the open issues. This is a collaborative effort and we are looking for contributions and ideas from users like you!

If you use Astropy directly—or as a dependency to another package—for your work, please remember to include the following acknowledgment at the end of papers:

This research made use of Astropy, a community-developed core Python package for Astronomy (Astropy Collaboration, 2013).

where “(Astropy Collaboration, 2013)” is the Astropy paper.

7 comments… add one
  • Annie JC Jul 7, 2014 @ 11:10

    Sometimes the astronomy gets lost in the code… e.g., the RAs should increase to the left in the first and third figures. We are inside the Universe, not outside!

  • Ginny McSwain Jul 7, 2014 @ 12:13

    The link to the first tutorial is broken; it points to the 5th tutorial instead.

  • Austen Jul 8, 2014 @ 10:40

    Is there any easy way in astropy to plot the location of an object of interest over top of a survey footprint? Even better, would be to over-plot this object on an actual image from an overlapping survey.

  • Ray Roberts Aug 13, 2017 @ 4:34

    Hi
    Trying to use Astropy without any success using python 2 or python 3.
    I can not find any short programs in Astropy to test if the software has been installed correctly.

    For example I tried this short program, just have multiple errors occurring.

    Would anyone please have a short program for telling Sidereal time.
    Just something that I can start on.

    from astropy.time import Time

    A = t.sidereal_time(‘apparent’, ‘greenwich’)

    print (‘A’)

    Thanks Ray

  • robert Aug 26, 2022 @ 9:31

    the tutorial:Spectroscopic Data Reduction Part 1: Tracing
    calls for the file:aldebaran_3s_1.bmp
    but I am unable to find it on my computer or on line.
    any ideas where it is located?

Leave a Reply

Your email address will not be published. Required fields are marked *