Size: 1027
Comment:
|
Size: 3190
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.
http://www.pythonxy.com/ Python(x,y) is a scientific python distribution with many modules included
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
= Links and References
http://heim.ifi.uio.no/~hpl/scripting/all-nosplit/index.html
http://www.springer.com/math/cse/book/978-3-540-73915-9 Python Scripting for Computational Science