SciPy : Scientific Python
SciPy (pronounced "Sigh Pie" ) is an open-source collection of mathematical algorithms like minimization, Fourier transformation, regression , and other applied mathematical and scientific techniques. Many of the SciPy routines are Python "wrappers ", this means that Python routines that provide an interface for numerical and scientific libraries originally written in Fortran, C, or C++.
SciPy builds on the Python NumPy extention and is part of the NumPy stack. SciPy has optimized and added functions that are frequently used in NumPy, which provides convenient and fast N-dimensional array manipulation, and Data Science. SciPy adds numerical integration and optimization power to the interactive Python session by providing the user with high-level commands and classes for manipulating and visualizing data. Also, it is widely used by researchers across academia and industry, and has been used in the production of some major scientific results such as the LIGO gravitational wave detection , and the recent imaging of a black hole at the centre of galaxy M87 by the Event Horizon Telescope . As mentioned earlier, SciPy builds on NumPy N-dimensional array and therefore if you import SciPy in Python , there is no need to import NumPy.
SciPy - Installation
You can install SciPy in Windows via pip.
pip install scipy
Subpackages in SciPy
Package Name | Description |
---|---|
constants | Physical constants and conversion factors |
cluster | Clustering algorithms |
fft | Discrete Fourier Transform algorithms |
fftpack | Fast Fourier Transforms algorithms |
integrate | Numerical integration routines |
interpolate | Interpolation tools |
io | Data input and output |
lib | Python wrappers to external libraries |
linalg | linear algebra routines |
misc | Miscellaneous utilities (e.g. image reading/writing) |
ndimage | N-dimensional image processing |
optimize | Optimization algorithms including linear programming |
signal | Signal processing tools |
sparse | Sparse matrix and associated algorithms |
spatial | Spatial data structure and algorithms |
special | Special functions |
stats | Statistical functions |
weave | Tool for writing C/C++ code as Python multiline strings |
from scipy import constants
example
>>> from scipy import constants
>>> print(constants.liter)
0.001
Above code output how many cubic meters are in one liter.
SciPy Constants
You can find a large collection of mathematical and physical constants in scipy.constants. These SciPy constants can be helpful when you are working with Data Science projects.
>>> from scipy import constants
>>> print(constants.pi)
3.141592653589793
Spatial Data
Spatial data refers to data that is represented in a geometric space such as Triangulation, Voronoi Diagram and Convex Hulls of a set of points, by leveraging the Qhull library.Triangulation example
A Triangulation of a polygon is to divide the polygon into various triangles with which we can calculate an area of the polygon. Delaunay() Triangulation in Spatial Data is a method to generate triangulations through points.Text
from scipy.spatial import Delaunay
import matplotlib.pyplot as plt
points = np.array([[0, 0], [0, 1.1], [1, 0], [1, 1]])
tri = Delaunay(points)
plt.triplot(points[:,0], points[:,1], tri.simplices)
plt.plot(points[:,0], points[:,1], 'o')
plt.savefig("d:\graph.png")
output 
Related Topics