Differences between revisions 2 and 5 (spanning 3 versions)
Revision 2 as of 2009-11-02 12:47:40
Size: 1027
Editor: anonymous
Comment:
Revision 5 as of 2010-11-01 10:22:44
Size: 3190
Editor: anonymous
Comment:
Deletions are marked like this. Additions are marked like this.
Line 27: Line 27:
Recommended book == Numpy ==

Numpy is the core library for multidimensional array objects (ndarray) and linear algebra. Most other scientific modules use the numpy array object. Numpy arrays and standard Python sequences have important differences:

 * Numpy arrays have a fixed size at creation, unlike Python lists
 * Numpy arrays facilitate mathematical operations on large numbers of data efficiently

The [[http://docs.scipy.org/doc/numpy/user/|User's guide]] [[http://docs.scipy.org/doc/numpy/numpy-user.pdf|PDF]] provides a good introduction.

== Scipy ==

The Scipy module is built on Numpy and offers a collection of mathematical algorithms such as

 * Clustering algorithms
 * Fast Fourier Transform routines
 * Integration and ordinary differential equation solvers
 * Interpolation and smoothing splines
 * Linear algebra
 * Maximum entropy methods
 * N-dimensional image processing and signal processing
 * Optimization and root-finding routines
 * Statistical distributions and functions

Furthermore it includes very handy routines for [[http://docs.python.org/dev/library/io.html#io|data input and output]].

== Pylab ==

[[http://matplotlib.sourceforge.net/|Pylab (aka Matplotlib)]] uses Numpy and Scipy and offers high-level functions that are similar in the name and syntax to those offered by Matlab. Matplotlib is the name of the core library and pylab provides the Matlab similarity. Pylab produces figures of great quality suitable for publications.

Making plots is easy. Start reading the [[http://matplotlib.sourceforge.net/contents.html|User's guide]]. For a specific problem look at the [[http://matplotlib.sourceforge.net/gallery.html|Gallery]] for a similar plot you would like to have and learn from the source code.


== Importing Numpy, Scipy, Pylab ==


The statement
{{{
from pylab import *
}}}
imports the most important functions/objects for numerical computation and plotting.

For more complex applications it is useful but not necessary to follow the conventions that the community has adopted

{{{#!python
import numpy as np
import scipy as sp
import matplotlib as mpl
import matplotlib.pyplot as plt
}}}


= Links and References

 * http://heim.ifi.uio.no/~hpl/scripting/all-nosplit/index.html
Line 29: Line 82:

== Slides for teaching ==

 * http://heim.ifi.uio.no/~hpl/scripting/all-nosplit/index.html

Python modules

There a several modules which are already included in the standard Python distribution:

Other modules have to be installed seperately, e.g. Numpy, Scipy, Pylab, etc.

Over 8000 special purpose modules and scripts can be found in the Python Package Index:

It is important to know where to find the functions that you need. We will go through some useful examples.

Numpy, Scipy and Pylab

Numpy

Numpy is the core library for multidimensional array objects (ndarray) and linear algebra. Most other scientific modules use the numpy array object. Numpy arrays and standard Python sequences have important differences:

  • Numpy arrays have a fixed size at creation, unlike Python lists
  • Numpy arrays facilitate mathematical operations on large numbers of data efficiently

The User's guide PDF provides a good introduction.

Scipy

The Scipy module is built on Numpy and offers a collection of mathematical algorithms such as

  • Clustering algorithms
  • Fast Fourier Transform routines
  • Integration and ordinary differential equation solvers
  • Interpolation and smoothing splines
  • Linear algebra
  • Maximum entropy methods
  • N-dimensional image processing and signal processing
  • Optimization and root-finding routines
  • Statistical distributions and functions

Furthermore it includes very handy routines for data input and output.

Pylab

Pylab (aka Matplotlib) uses Numpy and Scipy and offers high-level functions that are similar in the name and syntax to those offered by Matlab. Matplotlib is the name of the core library and pylab provides the Matlab similarity. Pylab produces figures of great quality suitable for publications.

Making plots is easy. Start reading the User's guide. For a specific problem look at the Gallery for a similar plot you would like to have and learn from the source code.

Importing Numpy, Scipy, Pylab

The statement

from pylab import *

imports the most important functions/objects for numerical computation and plotting.

For more complex applications it is useful but not necessary to follow the conventions that the community has adopted

   1 import numpy as np
   2 import scipy as sp
   3 import matplotlib as mpl
   4 import matplotlib.pyplot as plt

= Links and References

LehreWiki: OpenSource2010/Lesson3 (last edited 2010-11-01 14:03:52 by anonymous)