Thursday, September 25, 2014

The astropy library

2014 Python Lecture. Part VII

The Astropy Project is a community effort to develop a single core package for Astronomy in Python and foster interoperability between Python astronomy packages. More informations here: http://www.astropy.org/

In this lecture we will see some of the facilities of the astorpy library, including:

  • Constants and Units
  • Data Table (a very useful one!)
  • Time and Dates
  • Etc...

The lecture is here:

https://github.com/Morisset/Python-lectures-Notebooks/blob/master/Notebooks/Using_astropy.ipynb

Thursday, September 18, 2014

Useful libraries

2014 Python Lecture. Part VI

This lecture will give some insights to the most useful python libraries. It is NOT exhaustive, you have to read the corresponding manual pages to find the best use you can have of them. The list of all python-included libraries is here: https://docs.python.org/2/library/

I mention in this lecture:

  • time and datetime
  • timeit
  • os
  • sys
  • subprocess
  • glob
  • re
  • urllib2
The lecture is here:

Wednesday, September 17, 2014

Introduction to Scipy

2014 Python Lecture. Part V

SciPy (pronounced “Sigh Pie”) is a Python-based ecosystem of open-source software for mathematics, science, and engineering. In particular, these are some of the core packages: Numpy, Scipy library, Matplotlib, ipython, Simpy, and Panda.


In this lecture, I will show exemples covering:
  • Some useful methods
    • nanmean
    • constants
  • Integrations
  • Interpolations
  • 2D-interpolations
  • data fitting
  • multivariate estimation
The lecture is here:

https://github.com/Morisset/Python-lectures-Notebooks/blob/master/Notebooks/intro_Scipy.ipynb

Wednesday, September 10, 2014

How to make plots, images, 3D, etc, using Matplotlib

2014 Python Lecture. Part IV


This lecture is dedicated to the plotting library matplotlib. The topics are:


  • Simple plot
  • Controlling colors ans symbols
  • Overplot
  • Fixing axes limits
  • Labels, titles
  • Legends
  • The object oriented way to use Matplotlib
  • Scatter
  • log plots
  • Multiple plots
  • Everything is object
  • Error bars
  • Sharing axes
  • Histograms
  • Boxplots
  • Ticks, axes and spines
  • A plot inside a plot
  • Play with all the objects of a plot
  • Filled regions
  • 2D-histograms
  • 2D data sets and images
  • Contour
  • 3D scatter plots
  • Saving plots
  • Access and clear the current figure and axe
  • What's happen when not in a Notebook? plt.show() and plt.ion() commands
The lecture Notebook is there:
https://github.com/Morisset/Python-lectures-Notebooks/blob/master/Notebooks/intro_Matplotlib.ipynb

Wednesday, September 3, 2014

Interacting with files: reading writing, ascii and fits

2014 Python lecture. Part III


It's time to play with files containing data! In this lecture, we'll see how to read and write files (ascii and fits).

  • Reading a simple ASCII file
  • How to treat special rows (comments, header)
    • classical way
    • using numpy.loadtxt
    • using numpy.genfromtxt
  • Dealing with missing data
  • Data in a fixed size format
  • Writing files
    • simple method
  • Pickle files (python format)
  • FITS files
The ipython notebook is there:

https://github.com/Morisset/Python-lectures-Notebooks/blob/master/Notebooks/Interact%20with%20files.ipynb