1 / 36

Python for Scientific Computing and Visualization

Dive into Python's high-level, open-source capabilities for scientific computing, including NumPy, SciPy, and Matplotlib. Learn about interfacing with C/C++ and Fortran and enhancing productivity with IPython.

junewall
Download Presentation

Python for Scientific Computing and Visualization

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Python for Scientific Computing Wim R.M. Cardoen Center for High Performance Computing wim.cardoen@utah.edu Fall 2010

  2. Overview • Python • NumPy • SciPy • Matplotlib • Python using C/C++ and Fortran • IPython

  3. Why Python? • High-level interpreted language • Very clear syntax =>easy-to-read • Open source • Platform independent • Large number of libraries • Binding to all standard GUI kits (TkInter, Qt, ..) • Powerful automated testing tools • Easily integrated with C/C++, and Fortran • Actively used and extended by scientists

  4. Python Language • Clear syntax -> easy to understand • Indentation for blocks • Use of namespace, exception handling • Automatic doc.: doc strings & pydoc • Dynamic typing • Supports both procedural & OO approach • Easy code testing • Garbage collecting • Functional programming, iterators,…

  5. Numpy:Why? The “trad.” Python list: • can contain data of whatever type => memory el. may have different sizes • the list can grow & shrink dynamically • passing through list by loops/iterators => not very efficient for numerical calculations. We need something more efficient: python + fast math=> NumPy

  6. Multi-dimensional array object i.e. ndarray 1. homogeneous (all have the same type) 2. indexing/slicing 3. vectorization 4. broadcasting • Derived objects such as masked arrays, matrices 1. matrix: derived from ndarray: always 2D attributes: T(transpose), H (hermit. conj.), I (invert) 2. masked arrays: missing or invalid entries • Universal func.: operates on ndarrays in el-by-el fashion • NumPy: basic toolkit for other packages e.g. SciPy,...

  7. What’s under the hood? NumPy and Scipy require: • Fast Linear Algebra routines: BLAS, LAPACK / ATLAS / GOTO-BLAS • FFT Routines: routines for computing the DFT • UMFPACK: routines for solving unsymmetric sparse linear systems Alternative: MKL (Intel)

  8. SciPy • collection of mathematical algorithms • contains several subpackages, e.g.: • scipy.linalg • scipy.fftpack • scipy.optimize • scipy.integrate • scipy.interpolate • scipy.special • …

  9. MatplotLib • produces publication quality 2D plots • supports Latex commands • >= 0.99: inclusion of mplot3D (3D pics) Note: Mayavi: 3D Scientific Data Visualization http://code.enthought.com/projects/mayavi/

  10. Source: http://en.wikipedia.org/wiki/Delaunay_triangulation

  11. Interfacing C/C++ and Python Approaches for C/C++: • SWIG: SimpliedWrapper & Interface Generator • Weave: inclusion C/C++ code in Python • PyInline: inline other languages in Python • Pyrex: python with C-data types Approaches for Fortan: f2py f2py -c --fcompiler=gfortran -m essai essai.f90 import essai essai.trial(13) # subroutine trial(x) defined in “essai.f90”

  12. Ipython Enhanced interactive Python shell • TAB-completion • explore objects using ? • %run command • debug python script • output/input cache • history • Suppress output • call system commands • …

  13. Additional packages • MPI: MPI4PY • SymPy: Symbolic Math • PIL: Python Imaging Library • Mayavi Interactive 3D Visualization • PyMol : 3D Molecular Viewer • NLopt: Non-linear optimization

  14. Links: • http://www.python.org/ • http://numpy.scipy.org • http://www.scipy.org • http://matplotlib.sourceforge.net • http://ipython.scipy.org

More Related