Scipy

SciPy is an open source library of high-quality scientific tools for the Python programming language. It must not be confused with the concurrent project Scientific Python. SciPy uses the array handling of the NumPy or/and Numarray modules. Furthermore, it contains modules for graphics and plotting, optimization, integration, special functions, signal and image processing, genetic algorithms, ODE solvers, and others. SciPy is targeted towards similar applications as MATLAB and Scilab. SciPy is sponsored by Enthought. It is currently distributed under the BSD license (just don't sue us).

Data structures

The basic data structure in SciPy is the array. The SciPy project is slowly moving from the original NumPy Numeric array type to the newer Numarray implementation.

Modules

Overview

Available subpackages:
  • plt, gplt, xplt: graphics
  • special: Special Functions
  • linalg: Linear algebra routines
    • sparse: Sparse matrix
    • cluster: Vector Quantization / Kmeans
  • fftpack: Discrete Fourier Transform algorithms
  • optimize: Optimization Tools
  • interpolate: Interpolation Tools
  • integrate: Integration routines
  • ga: Genetic Algorithms
  • stats: Statistical Functions
  • cow: Cluster Of Workstations
  • signal: Signal Processing Tools
  • io: Data input and output

Graphics

Currently, SciPy has three graphics packages:
  • scipy.plt, a cross-platform package written from scratch,
  • scipy.gplt, a front-end to the cross-platform plotting tool Gnuplot, and
  • scipy.xplt, based on Gist, therefore limited to systems running X11.
Ultimately, their functionalities shall be merged in scipy.plt. As of November 2004, scipy.plt is still missing advanced graphics capabilities such as 3-d-plotting. The following sample shows a SciPy session with a simple plot:
  >>> import gui_thread  >>> gui_thread.start()  >>> from scipy import plt  >>> plt.plot((1,2,3)) 
If SciPy is used from a wxPython shell such as Boa constructor or PyCrust, the above sample simplifies to
  >>> from scipy import plt  >>> plt.plot((1,2,3)) 
Image processing capabilities are available through the Python Imaging Library (PIL).

Complex example

The following code demonstrates several capabilities of SciPy: the one-dimensional motion of an object in the Earth's gravity field is calculated by integrating Newton's equation of motion, then fitted by a parabola:
  ## Initializations: 
  print "initializing ..."  import gui_thread  gui_thread.start()  from scipy import plt  from numarray import arange  from scipy.integrate import odeint  from scipy.optimize import leastsq  print "running ..." 
  ## Simulate 1-dimensional Newtonian dynamics: 
  # set times for which we want data (these are NOT the integration steps):  T=arange(0,4.,.01)  
  # given acceleration as function of position, velocity or/and time:  def acc(s,v,t):      return -9.81 
  # set initial position and velocity:  sv0=0,10 
  # first derivative of s,v will be equated with fu:  def fu(sv,t):  	returnsv[1,acc(sv0,sv1,t)] 
  # integrate equation of motion:  SV = odeint(fu,sv0,T)  S=SV:,0 # obtain s(t) as a slice of sv(t) 
  ## Fit resulting s(t): 
  # model function (a parabola):  def model(p,t):      return p0+p1*t+p2*t*t 
  # initial values for fit parameters:  p0=.1,.6,4. 
  # perform the fit:  def residue(param,datum,t):      return datum - model(param,t)  fit=leastsq(residue,p0,args=(S,T))  p=fit0 # final fit parameters 
  # print and plot results:  print "fit result: ", p  Sfit = model(p,T) # fitted parabola  plt.plot(T,S,'bx',T,Sfit,'m-') 

External links

* www.scipy.org

 

<< PreviousWord BrowserNext >>
glareolidae
glen rock
glenrock
grand junction
homosexuality and psychology
slappy
true cross
nick mccabe
brighton (disambiguation)
james stirling
a northern soul
pub song
clopyralid
ernesto teodoro moneta
tarahumara
margaret gibson
richard hakluyt
hector boece
robert armin
belikin
armand hammer
san pedro town
west bromwich
borussia mnchengladbach
ambergris caye
thomas, earl of lancaster
peter reid
livingston, scotland
jim laker
nippon budokan hall
deviation
michael noonan
burlington northern santa fe railway
james dillon
trans fat
cattle mutilation
phoenix command
bounce (musical)
lisa guerrero
joanna glass
adam guettel
stephen leacock memorial medal for humour
battle of boroughbridge
morphos