SciPy Cookbook

This is the “SciPy Cookbook” — a collection of various user-contributed recipes, which once lived under wiki.scipy.org. Note that some are fairly old (2005–2009), and may not be as relevant today. If you want to contribute additions/corrections, see the the SciPy-CookBook repository.

Compiling Extensions

Compiling Extension Modules on Windows using mingw

Graphics

Line Integral Convolution Mayavi Vtk volume rendering

Input Output

Data Acquisition with NIDAQmx Data acquisition with PyUL Fortran I/O Formats Input and output LAS reader Reading SPE file from CCD camera Reading mat files hdf5 in Matlab

Matplotlib / 3D Plotting

Matplotlib VTK integration Matplotlib: mplot3d

Matplotlib / Embedding Plots in Apps

Embedding In Wx Matplotlib: pyside Matplotlib: scrolling plot

Matplotlib / Misc

Load image Matplotlib: adjusting image size Matplotlib: compiling matplotlib on solaris10 Matplotlib: deleting an existing data series Matplotlib: django Matplotlib: interactive plotting Matplotlib: matplotlib and zope Matplotlib: multiple subplots with one axis label Matplotlib: qt with ipython and designer Matplotlib: using matplotlib in a CGI script

Matplotlib / Pseudo Color Plots

Matplotlib: colormap transformations Matplotlib: converting a matrix to a raster image Matplotlib: gridding irregularly spaced data Matplotlib: loading a colormap dynamically Matplotlib: plotting images with special values Matplotlib: show colormaps

Matplotlib / Simple Plotting

Matplotlib: animations Matplotlib: arrows Matplotlib: bar charts Matplotlib: custom log labels Matplotlib: hint on diagrams Matplotlib: legend Matplotlib: maps Matplotlib: multicolored line Matplotlib: multiline plots Matplotlib: plotting values with masked arrays Matplotlib: shaded regions Matplotlib: sigmoidal functions Matplotlib: thick axes Matplotlib: transformations Matplotlib: unfilled histograms

Matplotlib / Typesetting

Matplotlib: latex examples Matplotlib: using tex

Mayavi

Mayavi surf Mayavi tips Mayavi: running mayavi 2 Scripting Mayavi 2

Mayavi / TVTK

Mayabi: mlab Mayavi tvtk

Numpy & Scipy / Advanced topics

Views versus copies in NumPy

Numpy & Scipy / Interpolation

Interpolation Using radial basis functions for smoothing/interpolation

Numpy & Scipy / Linear Algebra

Rank and nullspace of a matrix

Numpy & Scipy / Matplotlib

Histograms

Numpy & Scipy / Optimization and fitting techniques

Fitting data Large-scale bundle adjustment in scipy Least squares circle Linear regression OLS Optimization and fit demo Optimization demo RANSAC Robust nonlinear regression in scipy Solving a discrete boundary-value problem in scipy

Numpy & Scipy / Ordinary differential equations

Coupled spring-mass system Korteweg de Vries equation Matplotlib: lotka volterra tutorial Modeling a Zombie Apocalypse Theoretical ecology: Hastings and Powell

Numpy & Scipy / Other examples

Applying a FIR filter Brownian Motion Butterworth Bandpass Communication theory Correlated Random Samples Easy multithreading Eye Diagram FIR filter Filtfilt Finding the Convex Hull of a 2-D Dataset Finding the minimum point in the convex hull of a finite set of points Frequency swept signals KDTree example Kalman filtering Linear classification Particle filter Rebinning Savitzky Golay Filtering Smoothing of a 1D signal Solving large Markov Chains Watershed

Numpy & Scipy / Root finding

Function intersections Spherical Bessel Zeros

Numpy & Scipy / Tips and tricks

Addressing Array Columns by Name Building arrays Convolution-like operations Indexing numpy arrays MetaArray Multidot Object arrays using record arrays Stride tricks for the Game of Life accumarray like function

Other examples

C Extensions for Using NumPy Arrays Embedding in Traits GUI Matplotlib: drag’n’drop text example Matplotlib: treemap Mayavi: Install python stuff from source Mayavi: examples Reading custom text files with Pyparsing Scripting Mayavi 2: basic modules Scripting Mayavi 2: filters Scripting Mayavi 2: main modules

Performance

A beginners guide to using Python for performance computing Parallel Programming with numpy and scipy

Scientific GUIs

wxPython dialogs

Scientific Scripts

FDTD Algorithm Applied to the Schrödinger Equation

Using NumPy With Other Languages (Advanced)

C extensions Ctypes F2py Inline Weave With Basic Array Conversion (no Blitz) Pyrex And NumPy SWIG Numpy examples SWIG and Numpy SWIG memory deallocation f2py and numpy

Outdated

A numerical agnostic pyrex class Array, struct, and Pyrex Data Frames Python Imaging Library Recipes for timeseries The FortranFile class dbase xplt