pybld (version 1.19.2)
index
/usr/local/lib/python3.6/dist-packages/PyBLD-3.2-py3.6-linux-x86_64.egg/pybld/__init__.py

# Copyright (C) 2000-2020 Hiroshi Watabe watabe@cyric.tohoku.ac.jp
# Define PYBld Class python implemantation of BLD originally developed by Richard E Carson
# $Id: __init__.py,v 4362b56d74f9 2020/01/13 02:04:21 watabe $

 
Package Contents
       
_bldanaimgc
_pybldc
bldanaimg
bldanaimgc
datafile
grace_np
numpyio
pybldc
qconv

 
Classes
       
builtins.object
PYBLD

 
class PYBLD(builtins.object)
    BLD with Python
Variables
gp_cmd = 'matplot' or 'grace' or 'gnuplot' for plotting data
view_cmd = 'matplot' or 'gpetview' to view data
show = 1 if you want to see detail of fitting
fit_z = results of fitting
comment = comment for output function
legend = list of legend for graph
title = title of graph
xlabel = label for X axis for graph
ylabel = label for X axis for graph
 
  Methods defined here:
__init__(self)
Initialize self.  See help(type(self)) for accurate signature.
checkarg(self, inp)
#check whether array or not
checkarray(self, inp)
#check whether array
combine(self, a, b)
combine(a,b) combines two arrays into one array
conv_exp(self, time, param, bld_tm, bld_cnt)
conv_exp(x,p,a,b)  returns  the  convolution  of  the  piecewise
linear  curve  described  by  the  variables  a  and  b with a sum of
exponentials defined by the parameter list p, evaluated at  times  x.
The  variable  'a' is the list of times of the sampled curve (assumed
to be in ascending order) and 'b' contains the function value at  the
times  in  'a'.   The  curve  being integrated is assumed to have the
value 0 for a<=0 (so the result of INTEGRATE is 0 for x<=0).   For  x
values  beyond  the  largest  value  of  a, the curve is extrapolated
linearly based on the final two points.  The exponential function has;
the following form depending on the number of values in p:
1 value    p(1)
2 values   p(1)exp(-p(2)x)
3 values   p(1)exp(-p(2)x)+p(3)
4 values   p(1)exp(-p(2)x)+p(3)exp(-p(4)x),    etc
dimen(self, a)
return dimension of array
even(self, x)
even(x) is the value x even (1=yes, 0=no)
exit(self)
#exit pybld
expf(self, x, p)
expf(x,p) - sum of exponentials  p[0]*exp(p[1]*x) + p[2]exp(...
expfit(self, x, obs, p, wt=array([0.]), fixm=array([0.]))
Exponential Fitting. The exponential fit routine fits the X,Y data to the function:
y(x) = p1  exp(p2  x) + p3 exp(p4 x) + ...
First you  must specify the number of parameters, two for one exponential, three for one exponential plus a constant,four for two exponentials, etc.
Then PyBLD requests initial estimates for the parameters.
Note that for exponential decay, p2 and p4 ,etc. should be negative.
The exponential function is non-linear in the parameters, 
so the fitting procedure is an iterative one.
This means that the program will find the best fitting parameters step by step,starting from the initial estimates that you supply.
The closer these parameters are to the true values, the quicker the convergence. The algorithm is Marquardt_-Levenberg with step halving.
expo(self, x, a, beta)
#  EXPo(X;A;beta) - sum of exponentials A(1)*exp(beta(1)*x) + ...
filter(self, x, f)
#filtering
fit(self, fitfunc, x, obs, p, wt=array([0.]), fixm=array([0.]))
Fitting to user-given funciton. fit(func,x,obs,p)
where 'func' is define function, 'x' is x-axis of function such as time, 'obs' is observed data, and 'p' is array of initial parameters to be fitted.
you must define func as func(x,p) and return fitted values.
Optionally you can give weight of data as variable 'wt'.
Optionally you can fix certain parameters by variable 'fixm'
fixm has format of array with elements of one or zero. If you want to fix second parameter in four parameters, you can give fixm = array([0,1,0,0])
this funciton returns estimated p values and their se. Also corrmat,fitresmat,fit_z contains results of fitting.
 
fitresmat[0]:standard error of the estimate
fitresmat[1]:sum of squares
fitresmat[2]:degree of freedom1
fitresmat[3]:degree of freedom2
fitresmat[4]:F value
fitresmat[5]:R square
fitresmat[6]:Correlation coefficient
fitd(self, fitfunc, x, obs, p, wt=array([0.]), fixm=array([0.]))
Fitting to user-given funciton with derivatives. fitd(func,x,obs,p)
where 'func' is define function, 'x' is x-axis of function such as time, 'obs' is observed data, and 'p' is array of initial parameters to be fitted.
you must define func as func(x,p). This function returns fitted values and derivatives of each parameter.
Optionally you can give weight of data as variable 'wt'.
Optionally you can fix certain parameters by variable 'fixm'
fixm has format of array with elements of one or zero. If you want to fix second parameter in four parameters, you can give fixm = array([0,1,0,0])
this funciton returns estimated p values and their se. Also corrmat,fitresmat,fit_z contains results of fitting.
gaus(self, mean, sd)
gaus(x,y) returns a list of gaussian random numbers with mean x
and  standard deviation y.  One value is returned for each element in
the list x.  
To get 100 random  numbers  with  mean  0  and  standard
deviation  1,  Use  gaus(zeros(100,'f'),1).  These numbers are pseudo
random and are generated from a seed variable.
gauss_filter1d(self, fwhm)
define gaussian kernel with fwhm in pixels (keep until 1% of gaussian)
gauss_filter2d(self, fwhm)
define gaussian kernel with fwhm in pixels (keep until 1% of gaussian)
gauss_smooth1d(self, x, fwhm)
perform 1d gaussian smooth of line x with fwhm
gauss_smooth2d(self, x, fwhm)
perform 2d gaussian smooth of image x with fwhm
gaussian_1d(self, x, f)
#gaussian filter
gaussian_2d(self, x, f)
calculate value of 2d gaussian at distances x from the center with fwhm of f
gnuplot(sel, tm, arg, ny)
Plot x,y points using gnuplot
graceplot(self, tm, arg, ny)
Plot x,y points using Grace
histogram(self, a, b0, bw, nbins)
histogram(a,b0,bw,nbins) the histogram of the list a where the
first bin starts at b0, the width of each bin is bw, and 
there are a total of nbin bins.
img(self, xdim=0, ydim=0, zdim=0, tdim=1, px=0.0, py=0.0, pz=0.0, type=2)
input(self, *arg)
Read data file if no argument are given, from standard input
integrate(self, newtime, time, cnt)
integrate(x,a,b) Integrates the piecewise linear curve described  by
the  variables  a  and  b  from  0  to the list of times x.  This
function assumes that the values in the variable a are  greater  than
or equal to 0 and are in ascending order.  The curve being integrated
is assumed to have the value 0 for a<=0 (so the result  of  INTEGRATE
is  0  for  x<=0).   For  x values beyond the largest value of a, the
curve is extrapolated linearly based on the  final  two  points.   To)
evaluate the integral from x1 to x2, use integrate(x2,a,b) - integrate(x1,a,b)
interpolate(self, newtime, time, cnt)
interpolate(x,a,b) interpolates  the  piecewise  linear   curve
described  by  a  and  b to the list of times x. This function assumes
that the values in the variable a are greater than or equal to 0  and
are  in  ascending order.  The curve being interpolated is assumed to
have the value 0 for a<=0 (so the result of INTEGRATE is 0 for x<=0).
For x values beyond the largest value of a, the curve is extrapolated(
linearly based on the final two points.
invmat(self, a)
inverse matrix
list2vec(self, x)
#list to vector
matplot(self, tm, arg, ny)
Plot x,y points using matplot
mean(self, a)
return mean value of matrix
mod(self, x, y)
# modular arithmetic  (x mod y) - remainder from x divided by y
mullin(self, dep_y, ind_x, wt=array([0.]), cst=0)
mullin(dependent,independents,[wt],cst=0 or 1) perform linear regression of one dependent variable against any number
   of independent variables.  To use this routine you must first select the
   variables of interest. 
   The first variable must be the dependent one,followed by the independent
    variables.  The order of the resulting parameters will correspond to the order
    of selection of the independent variables.
   The linear fitting routine will do a weighted regression when you create
    a variable named 'wt' with the same length as the independent variable. 
   This variable will be used to weight the sum of squares computed by the 
   regression routine. You will be notified that a weighted regression is being done.
If the user give cst=1, the routine includes constant.
   This funciton returns estimated p values and their se. Also corrmat,fitresmat,fit_z contains results of fitting.
 
   fitresmat[0]:standard error of the estimate
   fitresmat[1]:sum of squares
   fitresmat[2]:degree of freedom1
   fitresmat[3]:degree of freedom2
   fitresmat[4]:F value
   fitresmat[5]:R square
   fitresmat[6]:Correlation coefficient
mulmat(self, a, b)
Multiply Matrix
ncol(self, a)
normalize(self, x)
scale a vector/matrix so that its sum is 1
nrow(self, a)
#get numbers of row
odd(self, x)
odd(x) is the value x odd (1=yes, 0=no)
output(self, outfile, *arg)
Output text file from data. If first argument is null, print out to standard output
pconv_exp(self, time, param, bld_tm, bld_cnt)
pconv_exp(x,p,a,b)  returns  the  product convolution  of  the  piecewise
linear  curve  described  by  the  variables  a  and  b with a sum of
exponentials defined by the parameter list p, evaluated at  times  x.
The  variable  'a' is the list of times of the sampled curve (assumed
to be in ascending order) and 'b' contains the function value at  the
times  in  'a'.   The  curve  being integrated is assumed to have the
value 0 for a<=0 (so the result of INTEGRATE is 0 for x<=0).   For  x
values  beyond  the  largest  value  of  a, the curve is extrapolated
linearly based on the final two points.  The exponential function has;
the following form depending on the number of values in p:
1 value    p(1)
2 values   p(1)exp(-p(2)x)
3 values   p(1)exp(-p(2)x)+p(3)
4 values   p(1)exp(-p(2)x)+p(3)exp(-p(4)x),    etc
plot(self, _tm, *_arg)
polfit(self, deg_pol, x, y, wt=array([0.]))
polfit(degree,x,y,[wt])
The polynomial fitting routine will perform a polynomial fit. A polynomial function is of the form ;
y=a+bx+cx**2.......
The simplest polynomial fit is a linear fit;
y_=a_+bx    
First you must specify the order of the polynomial to be used, i.e. one=linear, two=quadratic, three=cubic, etc.
The routine will perform all fits starting with linear, quadratic, up to the requested order.  A statistical summary will be provided.
The polynomial fitting routine will do a weighted regression when you create a variable named 'wt' with the same number of elements as the independent (x) variable.  This variable will be used to weight the sum of squares computed by the regression routine.  You will be notified that a weighted regression is being done. 
This funciton returns estimated p values and their se. Also corrmat,fitresmat,fit_z contains results of fitting.
 
fitresmat[0]:standard error of the estimate
fitresmat[1]:sum of squares
fitresmat[2]:degree of freedom1
fitresmat[3]:degree of freedom2
fitresmat[4]:F value
fitresmat[5]:R square
fitresmat[6]:Correlation coefficient
ran(self, x, y)
ran(x,y) returns a list of uniform random numbers between x and y (x and y must be same length).
These numbers are pseudo_- random and are generated from 
a seed variable.
recall(self, file)
#recall BLD object
recall2(self, file)
save(self, file)
#save BLD object
sd(self, x)
return sd value of matrix
spline(self, newtime, time, cnt)
spline(X,R,S) The SPLine fit routine allows the  user  to  generate  a  smooth curve at many time points, simply by specifying the Y values at a few of these points.  First the user must specify the time points at which the curve should be computed (X),  and  the  original curve in  R and S.
Typing SPL will cause the routine to compute the spline fit.  The spline fit routine places the spline in X, and  the final fitted values in Y.  The original data (R and S) and the spline curve (X and Y) are selected upon completion, ready for plotting.
tran(self, a)
Transpose of matrix
var(self)
#BLD var list variables
variance(self, x)
return variance value of matrix
vec2mat(self, x)
#vector to matrix
vector(self, a, x)
VECTOR(a;x) returns a list of length 'a' filled with values  for x.   If  there  are less then 'a' values, the value will be recycled,
 
for example;
     x=1,2,3,4
     vector(2;x) returns 1,2
     vector(6;x) returns 1,2,3,4,1,2
     VECTOR(a) returns a vector filled with zeroes.

Data descriptors defined here:
__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)

 
Functions
       
add_docstring(...)
add_docstring(obj, docstring)
 
Add a docstring to a built-in obj if possible.
If the obj already has a docstring raise a RuntimeError
If this routine does not know how to add a docstring to the object
raise a TypeError
add_newdoc_ufunc = _add_newdoc_ufunc(...)
add_ufunc_docstring(ufunc, new_docstring)
 
Replace the docstring for a ufunc with new_docstring.
This method will only work if the current docstring for
the ufunc is NULL. (At the C level, i.e. when ufunc->doc is NULL.)
 
Parameters
----------
ufunc : numpy.ufunc
    A ufunc whose current doc is NULL.
new_docstring : string
    The new docstring for the ufunc.
 
Notes
-----
This method allocates memory for new_docstring on
the heap. Technically this creates a mempory leak, since this
memory will not be reclaimed until the end of the program
even if the ufunc itself is removed. However this will only
be a problem if the user is repeatedly creating ufuncs with
no documentation, adding documentation via add_newdoc_ufunc,
and then throwing away the ufunc.
arange(...)
arange([start,] stop[, step,], dtype=None)
 
Return evenly spaced values within a given interval.
 
Values are generated within the half-open interval ``[start, stop)``
(in other words, the interval including `start` but excluding `stop`).
For integer arguments the function is equivalent to the Python built-in
`range` function, but returns an ndarray rather than a list.
 
When using a non-integer step, such as 0.1, the results will often not
be consistent.  It is better to use `numpy.linspace` for these cases.
 
Parameters
----------
start : number, optional
    Start of interval.  The interval includes this value.  The default
    start value is 0.
stop : number
    End of interval.  The interval does not include this value, except
    in some cases where `step` is not an integer and floating point
    round-off affects the length of `out`.
step : number, optional
    Spacing between values.  For any output `out`, this is the distance
    between two adjacent values, ``out[i+1] - out[i]``.  The default
    step size is 1.  If `step` is specified as a position argument,
    `start` must also be given.
dtype : dtype
    The type of the output array.  If `dtype` is not given, infer the data
    type from the other input arguments.
 
Returns
-------
arange : ndarray
    Array of evenly spaced values.
 
    For floating point arguments, the length of the result is
    ``ceil((stop - start)/step)``.  Because of floating point overflow,
    this rule may result in the last element of `out` being greater
    than `stop`.
 
See Also
--------
numpy.linspace : Evenly spaced numbers with careful handling of endpoints.
numpy.ogrid: Arrays of evenly spaced numbers in N-dimensions.
numpy.mgrid: Grid-shaped arrays of evenly spaced numbers in N-dimensions.
 
Examples
--------
>>> np.arange(3)
array([0, 1, 2])
>>> np.arange(3.0)
array([ 0.,  1.,  2.])
>>> np.arange(3,7)
array([3, 4, 5, 6])
>>> np.arange(3,7,2)
array([3, 5])
array(...)
array(object, dtype=None, *, copy=True, order='K', subok=False, ndmin=0)
 
Create an array.
 
Parameters
----------
object : array_like
    An array, any object exposing the array interface, an object whose
    __array__ method returns an array, or any (nested) sequence.
dtype : data-type, optional
    The desired data-type for the array.  If not given, then the type will
    be determined as the minimum type required to hold the objects in the
    sequence.
copy : bool, optional
    If true (default), then the object is copied.  Otherwise, a copy will
    only be made if __array__ returns a copy, if obj is a nested sequence,
    or if a copy is needed to satisfy any of the other requirements
    (`dtype`, `order`, etc.).
order : {'K', 'A', 'C', 'F'}, optional
    Specify the memory layout of the array. If object is not an array, the
    newly created array will be in C order (row major) unless 'F' is
    specified, in which case it will be in Fortran order (column major).
    If object is an array the following holds.
 
    ===== ========= ===================================================
    order  no copy                     copy=True
    ===== ========= ===================================================
    'K'   unchanged F & C order preserved, otherwise most similar order
    'A'   unchanged F order if input is F and not C, otherwise C order
    'C'   C order   C order
    'F'   F order   F order
    ===== ========= ===================================================
 
    When ``copy=False`` and a copy is made for other reasons, the result is
    the same as if ``copy=True``, with some exceptions for `A`, see the
    Notes section. The default order is 'K'.
subok : bool, optional
    If True, then sub-classes will be passed-through, otherwise
    the returned array will be forced to be a base-class array (default).
ndmin : int, optional
    Specifies the minimum number of dimensions that the resulting
    array should have.  Ones will be pre-pended to the shape as
    needed to meet this requirement.
 
Returns
-------
out : ndarray
    An array object satisfying the specified requirements.
 
See Also
--------
empty_like : Return an empty array with shape and type of input.
ones_like : Return an array of ones with shape and type of input.
zeros_like : Return an array of zeros with shape and type of input.
full_like : Return a new array with shape of input filled with value.
empty : Return a new uninitialized array.
ones : Return a new array setting values to one.
zeros : Return a new array setting values to zero.
full : Return a new array of given shape filled with value.
 
 
Notes
-----
When order is 'A' and `object` is an array in neither 'C' nor 'F' order,
and a copy is forced by a change in dtype, then the order of the result is
not necessarily 'C' as expected. This is likely a bug.
 
Examples
--------
>>> np.array([1, 2, 3])
array([1, 2, 3])
 
Upcasting:
 
>>> np.array([1, 2, 3.0])
array([ 1.,  2.,  3.])
 
More than one dimension:
 
>>> np.array([[1, 2], [3, 4]])
array([[1, 2],
       [3, 4]])
 
Minimum dimensions 2:
 
>>> np.array([1, 2, 3], ndmin=2)
array([[1, 2, 3]])
 
Type provided:
 
>>> np.array([1, 2, 3], dtype=complex)
array([ 1.+0.j,  2.+0.j,  3.+0.j])
 
Data-type consisting of more than one element:
 
>>> x = np.array([(1,2),(3,4)],dtype=[('a','<i4'),('b','<i4')])
>>> x['a']
array([1, 3])
 
Creating an array from sub-classes:
 
>>> np.array(np.mat('1 2; 3 4'))
array([[1, 2],
       [3, 4]])
 
>>> np.array(np.mat('1 2; 3 4'), subok=True)
matrix([[1, 2],
        [3, 4]])
compare_chararrays(...)
compare_chararrays(a, b, cmp_op, rstrip)
 
Performs element-wise comparison of two string arrays using the
comparison operator specified by `cmp_op`.
 
Parameters
----------
a, b : array_like
    Arrays to be compared.
cmp_op : {"<", "<=", "==", ">=", ">", "!="}
    Type of comparison.
rstrip : Boolean
    If True, the spaces at the end of Strings are removed before the comparison.
 
Returns
-------
out : ndarray
    The output array of type Boolean with the same shape as a and b.
 
Raises
------
ValueError
    If `cmp_op` is not valid.
TypeError
    If at least one of `a` or `b` is a non-string array
 
Examples
--------
>>> a = np.array(["a", "b", "cde"])
>>> b = np.array(["a", "a", "dec"])
>>> np.compare_chararrays(a, b, ">", True)
array([False,  True, False])
datetime_data(...)
datetime_data(dtype, /)
 
Get information about the step size of a date or time type.
 
The returned tuple can be passed as the second argument of `numpy.datetime64` and
`numpy.timedelta64`.
 
Parameters
----------
dtype : dtype
    The dtype object, which must be a `datetime64` or `timedelta64` type.
 
Returns
-------
unit : str
    The :ref:`datetime unit <arrays.dtypes.dateunits>` on which this dtype
    is based.
count : int
    The number of base units in a step.
 
Examples
--------
>>> dt_25s = np.dtype('timedelta64[25s]')
>>> np.datetime_data(dt_25s)
('s', 25)
>>> np.array(10, dt_25s).astype('timedelta64[s]')
array(250, dtype='timedelta64[s]')
 
The result can be used to construct a datetime that uses the same units
as a timedelta
 
>>> np.datetime64('2010', np.datetime_data(dt_25s))
numpy.datetime64('2010-01-01T00:00:00','25s')
empty(...)
empty(shape, dtype=float, order='C')
 
Return a new array of given shape and type, without initializing entries.
 
Parameters
----------
shape : int or tuple of int
    Shape of the empty array, e.g., ``(2, 3)`` or ``2``.
dtype : data-type, optional
    Desired output data-type for the array, e.g, `numpy.int8`. Default is
    `numpy.float64`.
order : {'C', 'F'}, optional, default: 'C'
    Whether to store multi-dimensional data in row-major
    (C-style) or column-major (Fortran-style) order in
    memory.
 
Returns
-------
out : ndarray
    Array of uninitialized (arbitrary) data of the given shape, dtype, and
    order.  Object arrays will be initialized to None.
 
See Also
--------
empty_like : Return an empty array with shape and type of input.
ones : Return a new array setting values to one.
zeros : Return a new array setting values to zero.
full : Return a new array of given shape filled with value.
 
 
Notes
-----
`empty`, unlike `zeros`, does not set the array values to zero,
and may therefore be marginally faster.  On the other hand, it requires
the user to manually set all the values in the array, and should be
used with caution.
 
Examples
--------
>>> np.empty([2, 2])
array([[ -9.74499359e+001,   6.69583040e-309],
       [  2.13182611e-314,   3.06959433e-309]])         #uninitialized
 
>>> np.empty([2, 2], dtype=int)
array([[-1073741821, -1067949133],
       [  496041986,    19249760]])                     #uninitialized
fastCopyAndTranspose = _fastCopyAndTranspose(...)
_fastCopyAndTranspose(a)
frombuffer(...)
frombuffer(buffer, dtype=float, count=-1, offset=0)
 
Interpret a buffer as a 1-dimensional array.
 
Parameters
----------
buffer : buffer_like
    An object that exposes the buffer interface.
dtype : data-type, optional
    Data-type of the returned array; default: float.
count : int, optional
    Number of items to read. ``-1`` means all data in the buffer.
offset : int, optional
    Start reading the buffer from this offset (in bytes); default: 0.
 
Notes
-----
If the buffer has data that is not in machine byte-order, this should
be specified as part of the data-type, e.g.::
 
  >>> dt = np.dtype(int)
  >>> dt = dt.newbyteorder('>')
  >>> np.frombuffer(buf, dtype=dt) # doctest: +SKIP
 
The data of the resulting array will not be byteswapped, but will be
interpreted correctly.
 
Examples
--------
>>> s = b'hello world'
>>> np.frombuffer(s, dtype='S1', count=5, offset=6)
array([b'w', b'o', b'r', b'l', b'd'], dtype='|S1')
 
>>> np.frombuffer(b'\x01\x02', dtype=np.uint8)
array([1, 2], dtype=uint8)
>>> np.frombuffer(b'\x01\x02\x03\x04\x05', dtype=np.uint8, count=3)
array([1, 2, 3], dtype=uint8)
fromfile(...)
fromfile(file, dtype=float, count=-1, sep='', offset=0)
 
Construct an array from data in a text or binary file.
 
A highly efficient way of reading binary data with a known data-type,
as well as parsing simply formatted text files.  Data written using the
`tofile` method can be read using this function.
 
Parameters
----------
file : file or str or Path
    Open file object or filename.
 
    .. versionchanged:: 1.17.0
        `pathlib.Path` objects are now accepted.
 
dtype : data-type
    Data type of the returned array.
    For binary files, it is used to determine the size and byte-order
    of the items in the file.
    Most builtin numeric types are supported and extension types may be supported.
 
    .. versionadded:: 1.18.0
        Complex dtypes.
 
count : int
    Number of items to read. ``-1`` means all items (i.e., the complete
    file).
sep : str
    Separator between items if file is a text file.
    Empty ("") separator means the file should be treated as binary.
    Spaces (" ") in the separator match zero or more whitespace characters.
    A separator consisting only of spaces must match at least one
    whitespace.
offset : int
    The offset (in bytes) from the file's current position. Defaults to 0.
    Only permitted for binary files.
 
    .. versionadded:: 1.17.0
 
See also
--------
load, save
ndarray.tofile
loadtxt : More flexible way of loading data from a text file.
 
Notes
-----
Do not rely on the combination of `tofile` and `fromfile` for
data storage, as the binary files generated are not platform
independent.  In particular, no byte-order or data-type information is
saved.  Data can be stored in the platform independent ``.npy`` format
using `save` and `load` instead.
 
Examples
--------
Construct an ndarray:
 
>>> dt = np.dtype([('time', [('min', np.int64), ('sec', np.int64)]),
...                ('temp', float)])
>>> x = np.zeros((1,), dtype=dt)
>>> x['time']['min'] = 10; x['temp'] = 98.25
>>> x
array([((10, 0), 98.25)],
      dtype=[('time', [('min', '<i8'), ('sec', '<i8')]), ('temp', '<f8')])
 
Save the raw data to disk:
 
>>> import tempfile
>>> fname = tempfile.mkstemp()[1]
>>> x.tofile(fname)
 
Read the raw data from disk:
 
>>> np.fromfile(fname, dtype=dt)
array([((10, 0), 98.25)],
      dtype=[('time', [('min', '<i8'), ('sec', '<i8')]), ('temp', '<f8')])
 
The recommended way to store and load data:
 
>>> np.save(fname, x)
>>> np.load(fname + '.npy')
array([((10, 0), 98.25)],
      dtype=[('time', [('min', '<i8'), ('sec', '<i8')]), ('temp', '<f8')])
fromiter(...)
fromiter(iterable, dtype, count=-1)
 
Create a new 1-dimensional array from an iterable object.
 
Parameters
----------
iterable : iterable object
    An iterable object providing data for the array.
dtype : data-type
    The data-type of the returned array.
count : int, optional
    The number of items to read from *iterable*.  The default is -1,
    which means all data is read.
 
Returns
-------
out : ndarray
    The output array.
 
Notes
-----
Specify `count` to improve performance.  It allows ``fromiter`` to
pre-allocate the output array, instead of resizing it on demand.
 
Examples
--------
>>> iterable = (x*x for x in range(5))
>>> np.fromiter(iterable, float)
array([  0.,   1.,   4.,   9.,  16.])
frompyfunc(...)
frompyfunc(func, nin, nout, *[, identity])
 
Takes an arbitrary Python function and returns a NumPy ufunc.
 
Can be used, for example, to add broadcasting to a built-in Python
function (see Examples section).
 
Parameters
----------
func : Python function object
    An arbitrary Python function.
nin : int
    The number of input arguments.
nout : int
    The number of objects returned by `func`.
identity : object, optional
    The value to use for the `~numpy.ufunc.identity` attribute of the resulting
    object. If specified, this is equivalent to setting the underlying
    C ``identity`` field to ``PyUFunc_IdentityValue``.
    If omitted, the identity is set to ``PyUFunc_None``. Note that this is
    _not_ equivalent to setting the identity to ``None``, which implies the
    operation is reorderable.
 
Returns
-------
out : ufunc
    Returns a NumPy universal function (``ufunc``) object.
 
See Also
--------
vectorize : Evaluates pyfunc over input arrays using broadcasting rules of numpy.
 
Notes
-----
The returned ufunc always returns PyObject arrays.
 
Examples
--------
Use frompyfunc to add broadcasting to the Python function ``oct``:
 
>>> oct_array = np.frompyfunc(oct, 1, 1)
>>> oct_array(np.array((10, 30, 100)))
array(['0o12', '0o36', '0o144'], dtype=object)
>>> np.array((oct(10), oct(30), oct(100))) # for comparison
array(['0o12', '0o36', '0o144'], dtype='<U5')
fromstring(...)
fromstring(string, dtype=float, count=-1, sep='')
 
A new 1-D array initialized from text data in a string.
 
Parameters
----------
string : str
    A string containing the data.
dtype : data-type, optional
    The data type of the array; default: float.  For binary input data,
    the data must be in exactly this format. Most builtin numeric types are
    supported and extension types may be supported.
 
    .. versionadded:: 1.18.0
        Complex dtypes.
 
count : int, optional
    Read this number of `dtype` elements from the data.  If this is
    negative (the default), the count will be determined from the
    length of the data.
sep : str, optional
    The string separating numbers in the data; extra whitespace between
    elements is also ignored.
 
    .. deprecated:: 1.14
        Passing ``sep=''``, the default, is deprecated since it will
        trigger the deprecated binary mode of this function. This mode
        interprets `string` as binary bytes, rather than ASCII text with
        decimal numbers, an operation which is better spelt
        ``frombuffer(string, dtype, count)``. If `string` contains unicode
        text, the binary mode of `fromstring` will first encode it into
        bytes using either utf-8 (python 3) or the default encoding
        (python 2), neither of which produce sane results.
 
Returns
-------
arr : ndarray
    The constructed array.
 
Raises
------
ValueError
    If the string is not the correct size to satisfy the requested
    `dtype` and `count`.
 
See Also
--------
frombuffer, fromfile, fromiter
 
Examples
--------
>>> np.fromstring('1 2', dtype=int, sep=' ')
array([1, 2])
>>> np.fromstring('1, 2', dtype=int, sep=',')
array([1, 2])
geterrobj(...)
geterrobj()
 
Return the current object that defines floating-point error handling.
 
The error object contains all information that defines the error handling
behavior in NumPy. `geterrobj` is used internally by the other
functions that get and set error handling behavior (`geterr`, `seterr`,
`geterrcall`, `seterrcall`).
 
Returns
-------
errobj : list
    The error object, a list containing three elements:
    [internal numpy buffer size, error mask, error callback function].
 
    The error mask is a single integer that holds the treatment information
    on all four floating point errors. The information for each error type
    is contained in three bits of the integer. If we print it in base 8, we
    can see what treatment is set for "invalid", "under", "over", and
    "divide" (in that order). The printed string can be interpreted with
 
    * 0 : 'ignore'
    * 1 : 'warn'
    * 2 : 'raise'
    * 3 : 'call'
    * 4 : 'print'
    * 5 : 'log'
 
See Also
--------
seterrobj, seterr, geterr, seterrcall, geterrcall
getbufsize, setbufsize
 
Notes
-----
For complete documentation of the types of floating-point exceptions and
treatment options, see `seterr`.
 
Examples
--------
>>> np.geterrobj()  # first get the defaults
[8192, 521, None]
 
>>> def err_handler(type, flag):
...     print("Floating point error (%s), with flag %s" % (type, flag))
...
>>> old_bufsize = np.setbufsize(20000)
>>> old_err = np.seterr(divide='raise')
>>> old_handler = np.seterrcall(err_handler)
>>> np.geterrobj()
[8192, 521, <function err_handler at 0x91dcaac>]
 
>>> old_err = np.seterr(all='ignore')
>>> np.base_repr(np.geterrobj()[1], 8)
'0'
>>> old_err = np.seterr(divide='warn', over='log', under='call',
...                     invalid='print')
>>> np.base_repr(np.geterrobj()[1], 8)
'4351'
nested_iters(...)
Create nditers for use in nested loops
 
Create a tuple of `nditer` objects which iterate in nested loops over
different axes of the op argument. The first iterator is used in the
outermost loop, the last in the innermost loop. Advancing one will change
the subsequent iterators to point at its new element.
 
Parameters
----------
op : ndarray or sequence of array_like
    The array(s) to iterate over.
 
axes : list of list of int
    Each item is used as an "op_axes" argument to an nditer
 
flags, op_flags, op_dtypes, order, casting, buffersize (optional)
    See `nditer` parameters of the same name
 
Returns
-------
iters : tuple of nditer
    An nditer for each item in `axes`, outermost first
 
See Also
--------
nditer
 
Examples
--------
 
Basic usage. Note how y is the "flattened" version of
[a[:, 0, :], a[:, 1, 0], a[:, 2, :]] since we specified
the first iter's axes as [1]
 
>>> a = np.arange(12).reshape(2, 3, 2)
>>> i, j = np.nested_iters(a, [[1], [0, 2]], flags=["multi_index"])
>>> for x in i:
...      print(i.multi_index)
...      for y in j:
...          print('', j.multi_index, y)
(0,)
 (0, 0) 0
 (0, 1) 1
 (1, 0) 6
 (1, 1) 7
(1,)
 (0, 0) 2
 (0, 1) 3
 (1, 0) 8
 (1, 1) 9
(2,)
 (0, 0) 4
 (0, 1) 5
 (1, 0) 10
 (1, 1) 11
promote_types(...)
promote_types(type1, type2)
 
Returns the data type with the smallest size and smallest scalar
kind to which both ``type1`` and ``type2`` may be safely cast.
The returned data type is always in native byte order.
 
This function is symmetric, but rarely associative.
 
Parameters
----------
type1 : dtype or dtype specifier
    First data type.
type2 : dtype or dtype specifier
    Second data type.
 
Returns
-------
out : dtype
    The promoted data type.
 
Notes
-----
.. versionadded:: 1.6.0
 
Starting in NumPy 1.9, promote_types function now returns a valid string
length when given an integer or float dtype as one argument and a string
dtype as another argument. Previously it always returned the input string
dtype, even if it wasn't long enough to store the max integer/float value
converted to a string.
 
See Also
--------
result_type, dtype, can_cast
 
Examples
--------
>>> np.promote_types('f4', 'f8')
dtype('float64')
 
>>> np.promote_types('i8', 'f4')
dtype('float64')
 
>>> np.promote_types('>i8', '<c8')
dtype('complex128')
 
>>> np.promote_types('i4', 'S8')
dtype('S11')
 
An example of a non-associative case:
 
>>> p = np.promote_types
>>> p('S', p('i1', 'u1'))
dtype('S6')
>>> p(p('S', 'i1'), 'u1')
dtype('S4')
set_numeric_ops(...)
set_numeric_ops(op1=func1, op2=func2, ...)
 
Set numerical operators for array objects.
 
.. deprecated:: 1.16
 
    For the general case, use :c:func:`PyUFunc_ReplaceLoopBySignature`.
    For ndarray subclasses, define the ``__array_ufunc__`` method and
    override the relevant ufunc.
 
Parameters
----------
op1, op2, ... : callable
    Each ``op = func`` pair describes an operator to be replaced.
    For example, ``add = lambda x, y: np.add(x, y) % 5`` would replace
    addition by modulus 5 addition.
 
Returns
-------
saved_ops : list of callables
    A list of all operators, stored before making replacements.
 
Notes
-----
.. WARNING::
   Use with care!  Incorrect usage may lead to memory errors.
 
A function replacing an operator cannot make use of that operator.
For example, when replacing add, you may not use ``+``.  Instead,
directly call ufuncs.
 
Examples
--------
>>> def add_mod5(x, y):
...     return np.add(x, y) % 5
...
>>> old_funcs = np.set_numeric_ops(add=add_mod5)
 
>>> x = np.arange(12).reshape((3, 4))
>>> x + x
array([[0, 2, 4, 1],
       [3, 0, 2, 4],
       [1, 3, 0, 2]])
 
>>> ignore = np.set_numeric_ops(**old_funcs) # restore operators
seterrobj(...)
seterrobj(errobj)
 
Set the object that defines floating-point error handling.
 
The error object contains all information that defines the error handling
behavior in NumPy. `seterrobj` is used internally by the other
functions that set error handling behavior (`seterr`, `seterrcall`).
 
Parameters
----------
errobj : list
    The error object, a list containing three elements:
    [internal numpy buffer size, error mask, error callback function].
 
    The error mask is a single integer that holds the treatment information
    on all four floating point errors. The information for each error type
    is contained in three bits of the integer. If we print it in base 8, we
    can see what treatment is set for "invalid", "under", "over", and
    "divide" (in that order). The printed string can be interpreted with
 
    * 0 : 'ignore'
    * 1 : 'warn'
    * 2 : 'raise'
    * 3 : 'call'
    * 4 : 'print'
    * 5 : 'log'
 
See Also
--------
geterrobj, seterr, geterr, seterrcall, geterrcall
getbufsize, setbufsize
 
Notes
-----
For complete documentation of the types of floating-point exceptions and
treatment options, see `seterr`.
 
Examples
--------
>>> old_errobj = np.geterrobj()  # first get the defaults
>>> old_errobj
[8192, 521, None]
 
>>> def err_handler(type, flag):
...     print("Floating point error (%s), with flag %s" % (type, flag))
...
>>> new_errobj = [20000, 12, err_handler]
>>> np.seterrobj(new_errobj)
>>> np.base_repr(12, 8)  # int for divide=4 ('print') and over=1 ('warn')
'14'
>>> np.geterr()
{'over': 'warn', 'divide': 'print', 'invalid': 'ignore', 'under': 'ignore'}
>>> np.geterrcall() is err_handler
True
zeros(...)
zeros(shape, dtype=float, order='C')
 
Return a new array of given shape and type, filled with zeros.
 
Parameters
----------
shape : int or tuple of ints
    Shape of the new array, e.g., ``(2, 3)`` or ``2``.
dtype : data-type, optional
    The desired data-type for the array, e.g., `numpy.int8`.  Default is
    `numpy.float64`.
order : {'C', 'F'}, optional, default: 'C'
    Whether to store multi-dimensional data in row-major
    (C-style) or column-major (Fortran-style) order in
    memory.
 
Returns
-------
out : ndarray
    Array of zeros with the given shape, dtype, and order.
 
See Also
--------
zeros_like : Return an array of zeros with shape and type of input.
empty : Return a new uninitialized array.
ones : Return a new array setting values to one.
full : Return a new array of given shape filled with value.
 
Examples
--------
>>> np.zeros(5)
array([ 0.,  0.,  0.,  0.,  0.])
 
>>> np.zeros((5,), dtype=int)
array([0, 0, 0, 0, 0])
 
>>> np.zeros((2, 1))
array([[ 0.],
       [ 0.]])
 
>>> s = (2,2)
>>> np.zeros(s)
array([[ 0.,  0.],
       [ 0.,  0.]])
 
>>> np.zeros((2,), dtype=[('x', 'i4'), ('y', 'i4')]) # custom dtype
array([(0, 0), (0, 0)],
      dtype=[('x', '<i4'), ('y', '<i4')])

 
Data
        ALLOW_THREADS = 1
BUFSIZE = 8192
CLIP = 0
ERR_CALL = 3
ERR_DEFAULT = 521
ERR_IGNORE = 0
ERR_LOG = 5
ERR_PRINT = 4
ERR_RAISE = 2
ERR_WARN = 1
FLOATING_POINT_SUPPORT = 1
FPE_DIVIDEBYZERO = 1
FPE_INVALID = 8
FPE_OVERFLOW = 2
FPE_UNDERFLOW = 4
False_ = False
Inf = inf
Infinity = inf
MAXDIMS = 32
MAY_SHARE_BOUNDS = 0
MAY_SHARE_EXACT = -1
NAN = nan
NINF = -inf
NZERO = -0.0
NaN = nan
PINF = inf
PZERO = 0.0
RAISE = 2
SHIFT_DIVIDEBYZERO = 0
SHIFT_INVALID = 9
SHIFT_OVERFLOW = 3
SHIFT_UNDERFLOW = 6
ScalarType = (<class 'int'>, <class 'float'>, <class 'complex'>, <class 'int'>, <class 'bool'>, <class 'bytes'>, <class 'str'>, <class 'memoryview'>, <class 'numpy.complex256'>, <class 'numpy.float128'>, <class 'numpy.uint64'>, <class 'numpy.int64'>, <class 'numpy.str_'>, <class 'numpy.complex128'>, <class 'numpy.float64'>, <class 'numpy.uint32'>, <class 'numpy.int32'>, <class 'numpy.bytes_'>, <class 'numpy.complex64'>, <class 'numpy.float32'>, ...)
True_ = True
UFUNC_BUFSIZE_DEFAULT = 8192
UFUNC_PYVALS_NAME = 'UFUNC_PYVALS'
WRAP = 1
absolute = <ufunc 'absolute'>
add = <ufunc 'add'>
arccos = <ufunc 'arccos'>
arccosh = <ufunc 'arccosh'>
arcsin = <ufunc 'arcsin'>
arcsinh = <ufunc 'arcsinh'>
arctan = <ufunc 'arctan'>
arctan2 = <ufunc 'arctan2'>
arctanh = <ufunc 'arctanh'>
bitwise_and = <ufunc 'bitwise_and'>
bitwise_not = <ufunc 'invert'>
bitwise_or = <ufunc 'bitwise_or'>
bitwise_xor = <ufunc 'bitwise_xor'>
c_ = <numpy.lib.index_tricks.CClass object>
cast = {<class 'numpy.complex256'>: <function <lambda> ...py.void'>: <function <lambda> at 0x7f2c5490a840>}
cbrt = <ufunc 'cbrt'>
ceil = <ufunc 'ceil'>
conj = <ufunc 'conjugate'>
conjugate = <ufunc 'conjugate'>
copysign = <ufunc 'copysign'>
cos = <ufunc 'cos'>
cosh = <ufunc 'cosh'>
deg2rad = <ufunc 'deg2rad'>
degrees = <ufunc 'degrees'>
divide = <ufunc 'true_divide'>
divmod = <ufunc 'divmod'>
e = 2.718281828459045
equal = <ufunc 'equal'>
euler_gamma = 0.5772156649015329
exp = <ufunc 'exp'>
exp2 = <ufunc 'exp2'>
expm1 = <ufunc 'expm1'>
fabs = <ufunc 'fabs'>
float_power = <ufunc 'float_power'>
floor = <ufunc 'floor'>
floor_divide = <ufunc 'floor_divide'>
fmax = <ufunc 'fmax'>
fmin = <ufunc 'fmin'>
fmod = <ufunc 'fmod'>
frexp = <ufunc 'frexp'>
gcd = <ufunc 'gcd'>
greater = <ufunc 'greater'>
greater_equal = <ufunc 'greater_equal'>
heaviside = <ufunc 'heaviside'>
hypot = <ufunc 'hypot'>
index_exp = <numpy.lib.index_tricks.IndexExpression object>
inf = inf
infty = inf
invert = <ufunc 'invert'>
isfinite = <ufunc 'isfinite'>
isinf = <ufunc 'isinf'>
isnan = <ufunc 'isnan'>
isnat = <ufunc 'isnat'>
lcm = <ufunc 'lcm'>
ldexp = <ufunc 'ldexp'>
left_shift = <ufunc 'left_shift'>
less = <ufunc 'less'>
less_equal = <ufunc 'less_equal'>
little_endian = True
log = <ufunc 'log'>
log10 = <ufunc 'log10'>
log1p = <ufunc 'log1p'>
log2 = <ufunc 'log2'>
logaddexp = <ufunc 'logaddexp'>
logaddexp2 = <ufunc 'logaddexp2'>
logical_and = <ufunc 'logical_and'>
logical_not = <ufunc 'logical_not'>
logical_or = <ufunc 'logical_or'>
logical_xor = <ufunc 'logical_xor'>
matmul = <ufunc 'matmul'>
maximum = <ufunc 'maximum'>
mgrid = <numpy.lib.index_tricks.MGridClass object>
minimum = <ufunc 'minimum'>
mod = <ufunc 'remainder'>
modf = <ufunc 'modf'>
multiply = <ufunc 'multiply'>
nan = nan
nbytes = {<class 'numpy.bool_'>: 1, <class 'numpy.int8'>:....datetime64'>: 8, <class 'numpy.timedelta64'>: 8}
negative = <ufunc 'negative'>
newaxis = None
nextafter = <ufunc 'nextafter'>
not_equal = <ufunc 'not_equal'>
ogrid = <numpy.lib.index_tricks.OGridClass object>
pi = 3.141592653589793
positive = <ufunc 'positive'>
power = <ufunc 'power'>
r_ = <numpy.lib.index_tricks.RClass object>
rad2deg = <ufunc 'rad2deg'>
radians = <ufunc 'radians'>
reciprocal = <ufunc 'reciprocal'>
remainder = <ufunc 'remainder'>
right_shift = <ufunc 'right_shift'>
rint = <ufunc 'rint'>
s_ = <numpy.lib.index_tricks.IndexExpression object>
sctypeDict = {'?': <class 'numpy.bool_'>, 0: <class 'numpy.bool_'>, 'byte': <class 'numpy.int8'>, 'b': <class 'numpy.int8'>, 1: <class 'numpy.int8'>, 'ubyte': <class 'numpy.uint8'>, 'B': <class 'numpy.uint8'>, 2: <class 'numpy.uint8'>, 'short': <class 'numpy.int16'>, 'h': <class 'numpy.int16'>, ...}
sctypeNA = {'Bool': <class 'numpy.bool_'>, <class 'numpy.bo...'>, <class 'numpy.uint8'>: 'UInt8', 'B': 'UInt8'}
sctypes = {'complex': [<class 'numpy.complex64'>, <class 'numpy.complex128'>, <class 'numpy.complex256'>], 'float': [<class 'numpy.float16'>, <class 'numpy.float32'>, <class 'numpy.float64'>, <class 'numpy.float128'>], 'int': [<class 'numpy.int8'>, <class 'numpy.int16'>, <class 'numpy.int32'>, <class 'numpy.int64'>], 'others': [<class 'bool'>, <class 'object'>, <class 'bytes'>, <class 'str'>, <class 'numpy.void'>], 'uint': [<class 'numpy.uint8'>, <class 'numpy.uint16'>, <class 'numpy.uint32'>, <class 'numpy.uint64'>]}
sign = <ufunc 'sign'>
signbit = <ufunc 'signbit'>
sin = <ufunc 'sin'>
sinh = <ufunc 'sinh'>
spacing = <ufunc 'spacing'>
sqrt = <ufunc 'sqrt'>
square = <ufunc 'square'>
subtract = <ufunc 'subtract'>
tan = <ufunc 'tan'>
tanh = <ufunc 'tanh'>
tracemalloc_domain = 389047
true_divide = <ufunc 'true_divide'>
trunc = <ufunc 'trunc'>
typeDict = {'?': <class 'numpy.bool_'>, 0: <class 'numpy.bool_'>, 'byte': <class 'numpy.int8'>, 'b': <class 'numpy.int8'>, 1: <class 'numpy.int8'>, 'ubyte': <class 'numpy.uint8'>, 'B': <class 'numpy.uint8'>, 2: <class 'numpy.uint8'>, 'short': <class 'numpy.int16'>, 'h': <class 'numpy.int16'>, ...}
typeNA = {'Bool': <class 'numpy.bool_'>, <class 'numpy.bo...'>, <class 'numpy.uint8'>: 'UInt8', 'B': 'UInt8'}
typecodes = {'All': '?bhilqpBHILQPefdgFDGSUVOMm', 'AllFloat': 'efdgFDG', 'AllInteger': 'bBhHiIlLqQpP', 'Character': 'c', 'Complex': 'FDG', 'Datetime': 'Mm', 'Float': 'efdg', 'Integer': 'bhilqp', 'UnsignedInteger': 'BHILQP'}