SCIPY Module
1, on File save and read operations, there are a variety of ways, such as
Use Io.savemat () and Io.loadmat () of Io in scipy;
For pictures you can use the Misc misc.imread () in scipy or Pyplot in Matplotlib ()
Among them, NumPy also provides the operation of text files: Numpy.loadtxt () and Numpy.savetxt ()
For reading text and CSV files, there are also Numpy.genfromtxt () and Numpy.recfromcsv ()
More efficient, numpy-specific binary form of numpy.save () and Numpy.load ()
More advanced image input and output methods have Skimage.io
2. Linear algebra Operation Scipy.linalg
For example, to find the value of the determinant, you can use Linalg.det (a), where a is a numpy-defined matrix;
For example, we can use LINALG.INV (arr) to find the inverse matrix of a square matrix, and if arr is singular, it will cause errors.
SVD has Uarr, spec, Vharr = LINALG.SVD (arr), where, Urarr, spec, Vharr can be combined to force the original matrix, specifically:
Sarr = Np.diag (spec)
>>> Svd_mat = Uarr. Dot (Sarr). Dot (Vharr) >>> NP. Allclose (Svd_mat, arr) True
3, interpolation operation: scipy.interpolate
For 1-dimensional interpolation functions, there are linear_interp = interp1d (measured_time, measures)
In which, you can set the parameter kind= ' cubic ' to change the interpolation type, the default is linear interpolation
4. Optimize and fit: scipy.optimize
Curve_fit (), Minimize (f, x0, method= "L-bfgs-b"), basinhopping to find the global best; parameters can be set in addition to method bounds, such as bounds= ((0,10),)
Minimize_scalar ()
If there are multiple arguments in the function, the variable can be written in the form of a vector;
Root finds a variable with a function of 0;
5, the geometric deformation of the image, from scipy import ndimage # Shift, Roate, zoom
6, Image expansion corrosion Operation Ndimage.binary_opening (IMG). Binary_closing (IMG)
7, the image of different areas of the block with different colors as a different label, you can use Ndimage.label (mask) method