This lesson is being piloted (Beta version)

Programming for Astronomy and Astrophysics 2: Programming Skills, Arrays and Scientific Libraries

This is the second of three Lessons from the course Programming for Astronomy and Astrophysics. This Lesson follows on from Lesson 1: Basic Python and covers more advanced topics such as programming style, errors and debugging, defensive programming (preventing errors) and how to check and optimize the speed of your programs. We will also look in-depth at at Numpy arrays and using Numpy and Scipy functions. We will end by looking at some of the Astropy sub-packages for working with astronomical calculations and data.

Prerequisites

You need to understand the concepts of files and directories and how to start a Python interpreter before tackling this lesson. This lesson sometimes references Jupyter Notebook although in practice you can use any Python interpreter (for iPython ` ‘magic commands’ you will need to use a Notebook or a suitable interpreter such as iPython).

The commands in this lesson pertain to Python 3.

Getting Started

To get started, follow the directions on the “Setup” page to download data and install a Python interpreter.

Schedule

Setup Download files required for the lesson
00:00 1. Programming Style How can I make my programs more readable?
How do most programmers format their code?
00:30 2. Errors and Exceptions How does Python report errors?
How can I handle errors in Python programs?
01:00 3. Defensive Programming How can I make my programs more reliable?
01:40 4. Debugging How can I debug my programs?
02:30 5. Timing and Speeding Up Your Programs How can I speed-test my programs, and if necessary, make it faster?
03:00 6. Working with Numpy Arrays How do I create, modify and select from numpy arrays?
04:20 7. Array Calculations with Numpy How can I perform calculations on large arrays quickly, using numpy functions?
05:10 8. Numerical Methods with Scipy What numerical methods are available in the Scipy library?
05:50 9. Introduction to Astropy How can the Astropy library help me with astronomical calculations and tasks?
06:30 10. Working with FITS Data How do I access the data in FITS files?
07:00 Finish

The actual schedule may vary slightly depending on the topics and exercises chosen by the instructor.