Smiley face

Python for Astronomers Advance Course Materials

Class I - 7 Nov. 2013


Python Introduction

Python Basic Sintaxe


Python Script Template



Possible resolutions

Exercises Solutions Alternatives

Class II - 21 Nov. 2013


Objects in Python



Possible resolutions

Star class
Planet class
Planetary System class
Numpy Solutions
100 Numpy Exercises

Class III - 5 Dec. 2013




Matplotlib Simple Exercises
IDL Sav File to Read
Wav File to Read

Possible resolutions

Matplotlib Exercises (from pdf file) solution
Scipy Exercises solution

Class IV - 17 Dec. 2013

Pyraf Example

In order to run this simple script you need pyraf module in your python system.

Pyfits Example

In order to run this you need pyraf module in your python system.

Pyfits Example 1 : this example shows how to read a 2 extension fits file and create a new fits file with only 1 extension ready for splot or ARES.
Test Data Example 1

Pyfits Example 2 : this example shows how to take a simple 1D fits spectra and add a new extension to a new fits file.
Test Data Example 2

Pyfits Example 3 : this example shows a solution to create a new fits table file.
Test Data Example 3

Cython for wrapping C - Some simple Examples

I strongly recommend the reading of Chapter 18 of Python Scientific Lecture Notes. Specially the section related with Cython after page 324.

Note that you should have cythin installed in your system. To create the module for python for each example, just unpack the tar files for each example, inside each folder run: python build_ext --inplace

Cython Example 1 : Simple call of a cos function from "math.h".

Cython Example 2 : Simple call a test.c code implemented in the folder.

Cython Example 3 : Simple example to interface with numpy arrays.

Cython Example 4 : Calling functions defined in TMCalc code downloadable in the ARES Webpage.

Cython Example 5 : Wrapping a c code that uses an external library. In this case the Gnu Scientific Library is used as an example.


Python 2.7. Quick Reference

Python Scientific Lecture Notes -
Python Oficial WebPage
Python Online Documentation
PyRAF by Ureka


S. G. Sousa (sousasag(-at-) | Last modification: December 2013
Supported by FCT in the form of the grant: SFRH/BPD/47611/2008