Install Python

There are several Python distributions you can use. 

You can use Google Colab. 

If you prefer installing Python on your computer, consider using Anaconda. Anaconda is available cross-platform (Linux, Windows and Mac). Alternatively, you can use Python provided by your OS, and install the relevant libraries.

Use Python 3.x, and avoid using Python 2.7 as the latter is no longer supported. 

If you chose to use Anaconda, download the appropriate version for your operating system and run the installer

With Anaconda installed, you can run Python notebook from jupyter-lab. 

If you use the IDE "Spyder", set option Tools->Preferences->IPyhton console->Graphics->Graphics backend->Automatic for interactive plots (plots that you can move around and zoom into)

Libraries

Whether you use Anaconda or any other Python installation, you will need the following libraries

  1. Numpy 
  2. Scipy
  3. Astropy
  4. Matplotlib
  5. Emcee
  6. Pylightcurve
  7. Taurex3

The first 4 libraries (Numpy, Scipy, Astropy and Matplotlib) are  part of the Anaconda package, unless you chose miniconda in which case you have to install them yourself. The remaining libraries need to be installed by you following the instructions provided by the developers.

Choice of OS

In principle you can use Linux, MacOS or Windows. Linux and MacOS are Unix OS. If your computer runs Windows, please consider installing Linux as either 

  1. dual boot 
  2. A virtual box within your operating system (e.g. the excellent, and free Oracle Virtual Box https://www.virtualbox.org/)
While this is strictly not necessary, it makes installation of packages such as emcee, pylightcurve and taurex3 almost painless.  

Simple Example

This example shows how to do simple math and simple plots: code

Learning Python

Learn the basics in just 10 minutes with this online tutorial!

Learn how to use numpy with this extensive online tutorial.

Learn how to do plots with matplotlib with this online tutorial.

There are a number of resources available online and the physics library has several books in catalogue. 

Online you can read the Python tutorial (highly recommended) written by the developers: tutorial.pdf,  from python.org

Numpy

The Numpy library is a powerful implementation of virtually all numerical methods needed, from FFTs, to integration, signal processing, etc. A common mistake is that of confusing Numpy with the python language, but the language is the language and Numpy is a library of numerical methods written in the python language.

My recommendation is to read the Python tutorial first, and then have a quick look at the numpy documentation to be aware of the numerical methods implemented. In this way you will be aware that a method you might need exists, and lookup the detailed syntax in the online documentation.

You do all your analysis using numpy scalars, vectors, matrices and use with moderation python native objects (scalars, lists, dictionary etc.), most of the time. It is good practice to use Python native objects for bookkeeping only.

Installation: 

If not already installed, you can issue the following command in your conda environment prompt, or command prompt

conda install numpy

or

pip install numpy

Astropy

This library implements astronomy-specific numerical methods. 

Installation: 

If not already installed, you can issue the following command in your conda environment prompt, or command prompt

conda install astropy

or

pip install astropy

Plotting

The plotting library is matplotlib.pyplot. Several examples available online.

Installation: 

If not already installed, you can issue the following command in your conda environment prompt, or command prompt

conda install astropy

or

pip install astropy

PyLightcurce

It is an implementation of the exoplanet Light Curve model of Mandel and Agol (ApJ 580, 2002). The software can be downloaded from github, where you will find installation instructions.

pip install pylightcurve

is usually sufficient

emcee

This is a library implementing the Affine Invariant Markov Chane Montecarlo (MCMC). We will use this software to sample posterior probability density functions of model parameters. It can be downloaded from the developer's web page, where you also find installation instructions.

Installation: 

You can issue the following command in your conda environment prompt, or command prompt

pip install astropy

TauRex3

Implements a full exoplanet atmospheric spectrum modelling. TauRex estimates exoplanet atmospheric spectra in emission and transmission from a model atmosphere. It also runs retrievals: estimates the atmospheric parameters from an observerd spectrum in emission or transmission. The code is described in Al-Rafaie et al. 2019, and can be installed following instructions on github.

pip install taurex3

is usually sufficient

Last modified: Friday, 23 February 2024, 7:35 PM