ESA.util.bpch2_rw_smp (version 1.5.1)
index
/home/lfeng/otool/ESA/util/bpch2_rw_smp.py

class for reading and writing binary punch files
This is class is stand-alone version for otool_gcfile_io
 
Authors: L. Feng, Edinburgh University
History: v0.9, 2012.06.28
History: v0.95, 2012.09.30
 
Classes:
=========================================
1. bpgrid : grid for bpch2 data 
2. bpch2_data : container for bpch2 data
3. tracer_info: class for tracerinfo file 
4.  diag_info:  class for diaginfo file 
5. bpch2_file_rw: class for functions to read and write BPCH2 data

 
Modules
       
numpy.add_newdocs
ESA.util.bpch2_rw_py
numpy.core.defchararray
ESA.atmosphere.compute_gc_grid
numpy.ctypeslib
numpy.lib.scimath
numpy.fft
ESA.util.gp_axis_m
ESA.util.geo_constant
numpy.linalg
numpy.ma
math
numpy.random
numpy.core.records
ESA.util.time_module

 
Classes
       
bpch2_data
bpch2_file_rw
bpgrid
diag_info
tracer_info

 
class bpch2_data
    container for bpch2 data set 
 
Members:
------------------------------------------------
1. ntracer:<integer>: the order number of the tracer in GEOS-CHEM 
2. category:  <str>: category of the tracer 
3. unit:      <str>: unit of the data 
4. bpgrid:  <bpgrid>:class for data grid 
5  attr: <dict>: attributes
 
Functions
----------------------------------------------------------
1. __init__: initialization 
2. write_to_bpch2_file_window: write window data set into one bpch2 file
3. write_to_bpch2_file: write data set into one bpch2 file
4. regrid: regrid data 
5. def set_attr: set one attribute to the data set 
6. get_attr: get attributes of the data set  
7. update_data: update data
 
  Methods defined here:
__init__(self, ntracer, category, unit, bpgrid, data, **keywords)
Initialization 
 
Inputs:
------------------------------------------------------
1. ntracer:<integer>: the order number of the tracer in GEOS-CHEM 
2. category:  <str>: category of the tracer 
3. unit:      <str>: unit of the data 
4. bpgrid:  <bpgrid>:class for data grid 
5  keyword: <dict>: additional information
which given in form of  tau0=a, tau1=b, modelname='md', reserved='a'
get_attr(self, attr_names)
get attributes of the data set  
Inputs:
--------------------------------------------
1. attr_names:<str/list>: name of the attributes to be fetched.
regrid_data(self, new_lon, new_lat)
regrid data 
 
Inputs:
------------------------------------------------------
1. new_lon:<array>: new longitude grid 
2. new_lat:<array>: new latitude grid
set_attr(self, attr_name, value)
set one attribute to the data set 
 
Inputs:
----------------------------------
1. attr_name:<str>:name of the attribute
2. value: <obj>: value of the attribute
update_data(self, data)
update the data set 
 
Inputs:
-------------------------------------
1. data:<array>: data
write_to_bpch2_file(self, funit)
write data into one open bpch2 file 
 
Inputs:
=============================================
 
1. funit: <int>: unit number of the bpch2 file 
 
Returns:
-----------------------------------------------
1. stat:<int>: IO status
write_to_bpch2_file_window(self, funit, ist, jst, nx, ny)
write window data set into one bpch2 file 
 
Inputs:
==============================================
1. funit: <int>: the unit number of the bpch2 file 
to be consistent with  GEOS-Chem Fortran index,
2) ist:<int>: starting poistion of longitude
3) jst:<int: starting poistion of latitude 
4. nx: <int>: size of longitude 
5. ny: <int>: size of latitude
 
Returns:
-------------------------------------------
1. stats:<int>: IO status

 
class bpch2_file_rw
    the class for functions read and write BPCH2 data 
 
Members:
---------------------------------------------------
1.flnm:<str>: name of bpch2 flnm
2. cur_tracer:<int>: index for current tracer
3. maxtracer:<int>: maximal tracer number 
4. self.title:<str>: title of the bpch2 file 
5. modelname:<str>: name of GEOS-Chem simulation 
6. data:<list>: list of bpch2 data set read from file 
7. stat:<int>: IO status
8. ntracers:<int>: number of tracers read in 
9. read_mode:<int>: modes (-1, 0,1) for file access 
10. tracerinfo:<tracer_info>: class for information on tracers 
11. diaginfo:<diag_info>: class for diaginfo 
 
 
Functions:
-------------------------------------------------------
1. __init__: initialize
2. open_bpch2_w: open bpch2 file for outputs
3. close_bpch2_file: close bpch2 file
4. write_bpch2_data: write selected data to  bpch2 file
5. add_bpch2_data: add a bpdata into self.data list    
6. get_data: fetch bpch2 data according specifications
7. read_bpch2_data: read in single pch2 data record
8. print_datainfo: print out info on selected bpch2 data
9. write_bpch2_head: write head to one bpch2
10. open_bpch2_for_write: one wrapper for open_bpch2_w
11. read_mode_0: Read tracer information and head from bpch2 file only
12. read_mode_1: Read all tracer data from bpch2 file
13. read_mode_2: read only selected data from bpch2 file
 
  Methods defined here:
__init__(self, flnm, mode, maxtracer=300, tmpflnm=None, do_read=0, ftracerinfo='tracerinfo.dat', fdiaginfo='diaginfo.dat', sel_categorys=None, sel_tracers=None, sel_taus=None)
initialize
Inputs:
-------------------------------------------------------
1. flnm:<str>: bpch file name
2. mode:<str>: read and write bpch2 data
3. maxtracer:<int>: the max number of tracers
4. tmpflnm: <string>: file name for  temperary saving 
5. do_read: <int>: if do_read=1, data itself will be read in instead of just its information 
6. ftracerinfo:<str>: name of tracer info file 
7. fdiagfo:<str>: name of diag info file 
8. sel_categorys:<list, t:str>: selected category 
9. sel_tracers: <list, t:int>: selected tracer
10. sel_taus: <list, t:float>: selected tau (time)
add_bpch2_data(self, bpdata, data_id=None)
add a bpdata into self.data list 
 
Inputs:
-------------------------------------
1. bpdata:<bpch2_data>: bpch2 data class to be added to the list 
2. data_id:<int>: data ID
close_bpch2_file(self)
close bpch2 file
get_data(self, categorys=None, tracers=None, taus=None, tranames=None)
fetch bpch2 data according specifications
 
Inputs:
--------------------------------------------------------------
1. categorys:<list, t:str>: list of category 
2. taus:<list, t:float>: list of time 
2. tracers:<list, t:int>: list of tracer ID 
3. tranames:<list, t:str>: list of tracer names
 
Returns:
-------------------------------------------------------------------
1. found_data:<list, t:bpch2_data>: list of bpch2_data meeting criteria sets (see Note 1)
2. founded:<list, t:int>: number of bpch2 data meeting each  criteria sets (see Note 1
 
Notes: 
--------------------------------------------------------------------
1. One criteria set [category, tracer,tau, traname]  is formed by one element 
from each lof categorys, tracers, taus, and tranames lists.
open_bpch2_for_write(self, title, funit)
open bpch2 file for outputs
It is a wrapper for old name open_bpch2_w
 
Inputs:
---------------------------------------
1. titie:<str>: title of the data set 
2. iunit:<int>: ID for file IO 
 
Returns:
----------------------------------------
1. stat:<int>: status of the file
open_bpch2_w(self, funit, title='')
open bpch2 file for outputs
 
Inputs:
---------------------------------------
1. funit:<int>: ID for file IO 
2. titel:<str>: title of the data set 
 
Returns:
----------------------------------------
1. status:<int>: status of the file
print_datainfo(self, data_id=None)
print out data info 
 
Inputs:
-----------------------------------------]
1. data_id:<int>: index of data (not tracer ID) to be printed out
read_bpch2_data(self, data_id, save_data=False)
read in single pch2 data record
 
Inputs:
-----------------------------
1. data_id:<int>: data index to be read
2. save_data:<T/F>: if true, bpchdata will be updated 
 
Returns:
---------------------------------------
1. data:<obj>:  if save_data==True, class bpch2_data will be return. Otherwise data (array) will be return
read_mode_0(self, flnm, flnm_tmp, maxtracer)
Read tracer information and head from bpch2 file only
 
Inputs:
-------------------------------------------------------------------
1. flnm:<str>: name of bpch2 file 
2. flnm_tmp:<str>: file name for temporary file 
3. maxtracer:<int>: maximal tracer 
 
 
Returns:
-------------------------------------------
1. ios:<int>: IO status
read_mode_1(self, flnm)
Read all tracer data from bpch2 file
 
Inputs:
-------------------------------------------------------------------
1. flnm:<str>: name of bpch2 file 
 
 
Returns:
-------------------------------------------
1. stat:<int>: IO status
read_mode_2(self, flnm, categorys, tracers, taus)
Read only selected tracer data from bpch2 file
 
Inputs:
-------------------------------------------------------------------
1. flnm:<str>: name of bpch2 file 
2. categorys:<list, t:str>: list of category 
3. tracers:<list, t:int>: list of tracer ID 
4. taus:<list, t:float>: list of time 
 
 
Returns:
-------------------------------------------
1. stat:<int>: IO status
write_bpch2_data(self, data_id)
write selected data to  a bpch2 file
 
Inputs:
-------------------------------------
1. data_id:<int>: index for data to be written
write_bpch2_head(self, funit, title)
write head to one bpch2
 
Inputs:
---------------------------------------
1. funit:<int>: ID for file IO 
2. titie:<str>: title of the data set 
 
Returns:
----------------------------------------
1. stat: status of the file

 
class bpgrid
    the class for the grid used to store GEO-CHEM binary punch data
 
Members:
--------------------------------------------------
1. ix:<int>: size of longitude
2. jx:<int>: size of latitude
3. lx:<int>: size of model level
4. mod_res:<str>:model resolution  ('4x5', '2x2.5' etc)
5. ifirst:<int>: starting longitude
6. jfirst:<int>: starting latitude
7. lfirst:<int>: starting vertical level
8. halfpolar:<int>:  flag for half polar data set
9. centre180:<int>: location of longitude centre
10. glb_ix:<int>: global longitude size
11. glb_jx:<int>: global latitude size
12. glb_lx:<int>: global vertical size
13. lonres:<float>: longitude resolution
14. latres:<float>: latitude resolution
15. lons:<array>: longitude grid
16. lats:<array>: latitude grid 
 
Functions:
-----------------------------------------------------------
1. __init__: initialization
2. get_lat: Get the latitude grid 
3. get_lon:  Get the longitude grid 
4. get: Get vertical level
 
  Methods defined here:
__init__(self, ix, jx, lx, ifirst=1, jfirst=1, lfirst=1, halfpolar=0, centre180=0, lonres=None, latres=None)
Initialize the class 
Inputs:
============================================================
1. ix, jx, lx:  <int>:  the sizes of lon, lat, z 
2. ifirst, jfirst, lfirst:<int>:  the start point for the data to store 
3. halfpolar, centre180:<int>: 0 or 1 the type of the longitude grid
4. lonres, latres: <float>: the resolution of the lat and lon 
 
Notes:
=============================================================
1. The user can include the details on the vertical grid as well.
get_lat(self)
Get the latitude grid 
 
Return:
================================
1. sel_lat:<array>: latitude grid
get_lon(self)
Get the longitude grid 
 
Return:
================================
1. sel_lon:<array>: longitude grid
get_z(self)
Get vertical level 
 
Return:
================================
1. level:<array>: vertical level

 
class diag_info
    class for diag info file 
 
see otool_gcfile_io.py for more information
 
  Methods defined here:
__init__(self, flnm)
Initialization  
 
Inputs:
----------------------------------------
1. flnm:<str>: name of the file 
 
2.
get_offset(self, category)
get offset for given  category
 
Inputs:
------------------------------------
1. category:<str>: tracer category 
 
Returns:
--------------------------------------
1. offset:<int>: offset of the category
load_diag_info(self, flnm)
Read diag info from file

 
class tracer_info
    class for tracer info file 
see otool_gcfile_io.py for more information
 
  Methods defined here:
__init__(self, flnm)
Initialization 
Inputs:
------------------------------
1. flnm:<str>: name of the tracerinfo file
get_tracer_info(self, tracer_in)
Get information for tracer
 
Inputs:
----------------------------------------------
1. tracer_in:<int>: tracer ID
 
Returns:
------------------------------------------------
1. name:<str>: tracer name
2. fullname:<str>: tracer full name
3. molew: <float>: moleculr mass
4. unit: <str>: unit of the tracer
load_tracer_info(self, flnm)
read tracer infor from tracerinfo file 
 
Inputs
--------------------------------------
1. flnm:<str>: file name

 
Functions
       
add_docstring(...)
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
alterdot(...)
Change `dot`, `vdot`, and `innerproduct` to use accelerated BLAS functions.
 
Typically, as a user of Numpy, you do not explicitly call this function. If
Numpy is built with an accelerated BLAS, this function is automatically
called when Numpy is imported.
 
When Numpy is built with an accelerated BLAS like ATLAS, these functions
are replaced to make use of the faster implementations.  The faster
implementations only affect float32, float64, complex64, and complex128
arrays. Furthermore, the BLAS API only includes matrix-matrix,
matrix-vector, and vector-vector products. Products of arrays with larger
dimensionalities use the built in functions and are not accelerated.
 
See Also
--------
restoredot : `restoredot` undoes the effects of `alterdot`.
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 <http://docs.python.org/lib/built-in-funcs.html>`_ function,
but returns a ndarray rather than a list.
 
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.
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, `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
-------
out : 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
--------
linspace : Evenly spaced numbers with careful handling of endpoints.
ogrid: Arrays of evenly spaced numbers in N-dimensions
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=None, 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.  This argument can only
    be used to 'upcast' the array.  For downcasting, use the
    .astype(t) method.
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 : {'C', 'F', 'A'}, optional
    Specify the order of the array.  If order is 'C' (default), then the
    array will be in C-contiguous order (last-index varies the
    fastest).  If order is 'F', then the returned array
    will be in Fortran-contiguous order (first-index varies the
    fastest).  If order is 'A', then the returned array may
    be in any order (either C-, Fortran-contiguous, or even
    discontiguous).
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.
 
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]])
bincount(...)
bincount(x, weights=None)
 
Count number of occurrences of each value in array of non-negative ints.
 
The number of bins (of size 1) is one larger than the largest value in
`x`. Each bin gives the number of occurrences of its index value in `x`.
If `weights` is specified the input array is weighted by it, i.e. if a
value ``n`` is found at position ``i``, ``out[n] += weight[i]`` instead
of ``out[n] += 1``.
 
Parameters
----------
x : array_like, 1 dimension, nonnegative ints
    Input array.
weights : array_like, optional
    Weights, array of the same shape as `x`.
 
Returns
-------
out : ndarray of ints
    The result of binning the input array.
    The length of `out` is equal to ``np.amax(x)+1``.
 
Raises
------
ValueError
    If the input is not 1-dimensional, or contains elements with negative
    values.
TypeError
    If the type of the input is float or complex.
 
See Also
--------
histogram, digitize, unique
 
Examples
--------
>>> np.bincount(np.arange(5))
array([1, 1, 1, 1, 1])
>>> np.bincount(np.array([0, 1, 1, 3, 2, 1, 7]))
array([1, 3, 1, 1, 0, 0, 0, 1])
 
>>> x = np.array([0, 1, 1, 3, 2, 1, 7, 23])
>>> np.bincount(x).size == np.amax(x)+1
True
 
>>> np.bincount(np.arange(5, dtype=np.float))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: array cannot be safely cast to required type
 
A possible use of ``bincount`` is to perform sums over
variable-size chunks of an array, using the ``weights`` keyword.
 
>>> w = np.array([0.3, 0.5, 0.2, 0.7, 1., -0.6]) # weights
>>> x = np.array([0, 1, 1, 2, 2, 2])
>>> np.bincount(x,  weights=w)
array([ 0.3,  0.7,  1.1])
can_cast(...)
can_cast(fromtype, totype)
 
Returns True if cast between data types can occur without losing precision.
 
Parameters
----------
fromtype : dtype or dtype specifier
    Data type to cast from.
totype : dtype or dtype specifier
    Data type to cast to.
 
Returns
-------
out : bool
    True if cast can occur without losing precision.
 
Examples
--------
>>> np.can_cast(np.int32, np.int64)
True
>>> np.can_cast(np.float64, np.complex)
True
>>> np.can_cast(np.complex, np.float)
False
 
>>> np.can_cast('i8', 'f8')
True
>>> np.can_cast('i8', 'f4')
False
>>> np.can_cast('i4', 'S4')
True
compare_chararrays(...)
concatenate(...)
concatenate((a1, a2, ...), axis=0)
 
Join a sequence of arrays together.
 
Parameters
----------
a1, a2, ... : sequence of array_like
    The arrays must have the same shape, except in the dimension
    corresponding to `axis` (the first, by default).
axis : int, optional
    The axis along which the arrays will be joined.  Default is 0.
 
Returns
-------
res : ndarray
    The concatenated array.
 
See Also
--------
ma.concatenate : Concatenate function that preserves input masks.
array_split : Split an array into multiple sub-arrays of equal or
              near-equal size.
split : Split array into a list of multiple sub-arrays of equal size.
hsplit : Split array into multiple sub-arrays horizontally (column wise)
vsplit : Split array into multiple sub-arrays vertically (row wise)
dsplit : Split array into multiple sub-arrays along the 3rd axis (depth).
hstack : Stack arrays in sequence horizontally (column wise)
vstack : Stack arrays in sequence vertically (row wise)
dstack : Stack arrays in sequence depth wise (along third dimension)
 
Notes
-----
When one or more of the arrays to be concatenated is a MaskedArray,
this function will return a MaskedArray object instead of an ndarray,
but the input masks are *not* preserved. In cases where a MaskedArray
is expected as input, use the ma.concatenate function from the masked
array module instead.
 
Examples
--------
>>> a = np.array([[1, 2], [3, 4]])
>>> b = np.array([[5, 6]])
>>> np.concatenate((a, b), axis=0)
array([[1, 2],
       [3, 4],
       [5, 6]])
>>> np.concatenate((a, b.T), axis=1)
array([[1, 2, 5],
       [3, 4, 6]])
 
This function will not preserve masking of MaskedArray inputs.
 
>>> a = np.ma.arange(3)
>>> a[1] = np.ma.masked
>>> b = np.arange(2, 5)
>>> a
masked_array(data = [0 -- 2],
             mask = [False  True False],
       fill_value = 999999)
>>> b
array([2, 3, 4])
>>> np.concatenate([a, b])
masked_array(data = [0 1 2 2 3 4],
             mask = False,
       fill_value = 999999)
>>> np.ma.concatenate([a, b])
masked_array(data = [0 -- 2 2 3 4],
             mask = [False  True False False False False],
       fill_value = 999999)
digitize(...)
digitize(x, bins)
 
Return the indices of the bins to which each value in input array belongs.
 
Each index ``i`` returned is such that ``bins[i-1] <= x < bins[i]`` if
`bins` is monotonically increasing, or ``bins[i-1] > x >= bins[i]`` if
`bins` is monotonically decreasing. If values in `x` are beyond the
bounds of `bins`, 0 or ``len(bins)`` is returned as appropriate.
 
Parameters
----------
x : array_like
    Input array to be binned. It has to be 1-dimensional.
bins : array_like
    Array of bins. It has to be 1-dimensional and monotonic.
 
Returns
-------
out : ndarray of ints
    Output array of indices, of same shape as `x`.
 
Raises
------
ValueError
    If the input is not 1-dimensional, or if `bins` is not monotonic.
TypeError
    If the type of the input is complex.
 
See Also
--------
bincount, histogram, unique
 
Notes
-----
If values in `x` are such that they fall outside the bin range,
attempting to index `bins` with the indices that `digitize` returns
will result in an IndexError.
 
Examples
--------
>>> x = np.array([0.2, 6.4, 3.0, 1.6])
>>> bins = np.array([0.0, 1.0, 2.5, 4.0, 10.0])
>>> inds = np.digitize(x, bins)
>>> inds
array([1, 4, 3, 2])
>>> for n in range(x.size):
...   print bins[inds[n]-1], "<=", x[n], "<", bins[inds[n]]
...
0.0 <= 0.2 < 1.0
4.0 <= 6.4 < 10.0
2.5 <= 3.0 < 4.0
1.0 <= 1.6 < 2.5
dot(...)
dot(a, b)
 
Dot product of two arrays.
 
For 2-D arrays it is equivalent to matrix multiplication, and for 1-D
arrays to inner product of vectors (without complex conjugation). For
N dimensions it is a sum product over the last axis of `a` and
the second-to-last of `b`::
 
    dot(a, b)[i,j,k,m] = sum(a[i,j,:] * b[k,:,m])
 
Parameters
----------
a : array_like
    First argument.
b : array_like
    Second argument.
 
Returns
-------
output : ndarray
    Returns the dot product of `a` and `b`.  If `a` and `b` are both
    scalars or both 1-D arrays then a scalar is returned; otherwise
    an array is returned.
 
Raises
------
ValueError
    If the last dimension of `a` is not the same size as
    the second-to-last dimension of `b`.
 
See Also
--------
vdot : Complex-conjugating dot product.
tensordot : Sum products over arbitrary axes.
 
Examples
--------
>>> np.dot(3, 4)
12
 
Neither argument is complex-conjugated:
 
>>> np.dot([2j, 3j], [2j, 3j])
(-13+0j)
 
For 2-D arrays it's the matrix product:
 
>>> a = [[1, 0], [0, 1]]
>>> b = [[4, 1], [2, 2]]
>>> np.dot(a, b)
array([[4, 1],
       [2, 2]])
 
>>> a = np.arange(3*4*5*6).reshape((3,4,5,6))
>>> b = np.arange(3*4*5*6)[::-1].reshape((5,4,6,3))
>>> np.dot(a, b)[2,3,2,1,2,2]
499128
>>> sum(a[2,3,2,:] * b[1,2,:,2])
499128
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
dtype : data-type, optional
    Desired output data-type.
order : {'C', 'F'}, optional
    Whether to store multi-dimensional data in C (row-major) or
    Fortran (column-major) order in memory.
 
See Also
--------
empty_like, zeros, ones
 
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]])         #random
 
>>> np.empty([2, 2], dtype=int)
array([[-1073741821, -1067949133],
       [  496041986,    19249760]])                     #random
fastCopyAndTranspose = _fastCopyAndTranspose(...)
_fastCopyAndTranspose(a)
frombuffer(...)
frombuffer(buffer, dtype=float, count=-1, offset=0)
 
Interpret a buffer as a 1-dimensional array.
 
Parameters
----------
buffer
    An object that exposes the buffer interface.
dtype : data-type, optional
    Data type of the returned array.
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.
 
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)
 
The data of the resulting array will not be byteswapped,
but will be interpreted correctly.
 
Examples
--------
>>> s = 'hello world'
>>> np.frombuffer(s, dtype='S1', count=5, offset=6)
array(['w', 'o', 'r', 'l', 'd'],
      dtype='|S1')
fromfile(...)
fromfile(file, dtype=float, count=-1, sep='')
 
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
    Open file object or filename.
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.
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.
 
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 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', int), ('sec', int)]),
...                ('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', '<i4'), ('sec', '<i4')]), ('temp', '<f8')])
 
Save the raw data to disk:
 
>>> import os
>>> fname = os.tmpnam()
>>> x.tofile(fname)
 
Read the raw data from disk:
 
>>> np.fromfile(fname, dtype=dt)
array([((10, 0), 98.25)],
      dtype=[('time', [('min', '<i4'), ('sec', '<i4')]), ('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', '<i4'), ('sec', '<i4')]), ('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, np.float)
array([  0.,   1.,   4.,   9.,  16.])
frompyfunc(...)
frompyfunc(func, nin, nout)
 
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`.
 
Returns
-------
out : ufunc
    Returns a Numpy universal function (``ufunc``) object.
 
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([012, 036, 0144], dtype=object)
>>> np.array((oct(10), oct(30), oct(100))) # for comparison
array(['012', '036', '0144'],
      dtype='|S4')
fromstring(...)
fromstring(string, dtype=float, count=-1, sep='')
 
Return a new 1-D array initialized from raw binary or text data in string.
 
Parameters
----------
string : str
    A string containing the data.
dtype : dtype, optional
    The data type of the array. For binary input data, the data must be
    in exactly this format.
count : int, optional
    Read this number of `dtype` elements from the data. If this is
    negative, then the size will be determined from the length of the
    data.
sep : str, optional
    If provided and not empty, then the data will be interpreted as
    ASCII text with decimal numbers. This argument is interpreted as the
    string separating numbers in the data. Extra whitespace between
    elements is also ignored.
 
Returns
-------
arr : array
    The constructed array.
 
Raises
------
ValueError
    If the string is not the correct size to satisfy the requested
    `dtype` and `count`.
 
Examples
--------
>>> np.fromstring('\x01\x02', dtype=np.uint8)
array([1, 2], dtype=uint8)
>>> np.fromstring('1 2', dtype=int, sep=' ')
array([1, 2])
>>> np.fromstring('1, 2', dtype=int, sep=',')
array([1, 2])
>>> np.fromstring('\x01\x02\x03\x04\x05', dtype=np.uint8, count=3)
array([1, 2, 3], dtype=uint8)
 
Invalid inputs:
 
>>> np.fromstring('\x01\x02\x03\x04\x05', dtype=np.int32)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ValueError: string size must be a multiple of element size
>>> np.fromstring('\x01\x02', dtype=np.uint8, count=3)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ValueError: string is smaller than requested size
getbuffer(...)
getbuffer(obj [,offset[, size]])
 
Create a buffer object from the given object referencing a slice of
length size starting at offset.
 
Default is the entire buffer. A read-write buffer is attempted followed
by a read-only buffer.
 
Parameters
----------
obj : object
 
offset : int, optional
 
size : int, optional
 
Returns
-------
buffer_obj : buffer
 
Examples
--------
>>> buf = np.getbuffer(np.ones(5), 1, 3)
>>> len(buf)
3
>>> buf[0]
'\x00'
>>> buf
<read-write buffer for 0x8af1e70, size 3, offset 1 at 0x8ba4ec0>
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
[10000, 0, 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()
[20000, 2, <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'
inner(...)
inner(a, b)
 
Inner product of two arrays.
 
Ordinary inner product of vectors for 1-D arrays (without complex
conjugation), in higher dimensions a sum product over the last axes.
 
Parameters
----------
a, b : array_like
    If `a` and `b` are nonscalar, their last dimensions of must match.
 
Returns
-------
out : ndarray
    `out.shape = a.shape[:-1] + b.shape[:-1]`
 
Raises
------
ValueError
    If the last dimension of `a` and `b` has different size.
 
See Also
--------
tensordot : Sum products over arbitrary axes.
dot : Generalised matrix product, using second last dimension of `b`.
 
Notes
-----
For vectors (1-D arrays) it computes the ordinary inner-product::
 
    np.inner(a, b) = sum(a[:]*b[:])
 
More generally, if `ndim(a) = r > 0` and `ndim(b) = s > 0`::
 
    np.inner(a, b) = np.tensordot(a, b, axes=(-1,-1))
 
or explicitly::
 
    np.inner(a, b)[i0,...,ir-1,j0,...,js-1]
         = sum(a[i0,...,ir-1,:]*b[j0,...,js-1,:])
 
In addition `a` or `b` may be scalars, in which case::
 
   np.inner(a,b) = a*b
 
Examples
--------
Ordinary inner product for vectors:
 
>>> a = np.array([1,2,3])
>>> b = np.array([0,1,0])
>>> np.inner(a, b)
2
 
A multidimensional example:
 
>>> a = np.arange(24).reshape((2,3,4))
>>> b = np.arange(4)
>>> np.inner(a, b)
array([[ 14,  38,  62],
       [ 86, 110, 134]])
 
An example where `b` is a scalar:
 
>>> np.inner(np.eye(2), 7)
array([[ 7.,  0.],
       [ 0.,  7.]])
int_asbuffer(...)
lexsort(...)
lexsort(keys, axis=-1)
 
Perform an indirect sort using a sequence of keys.
 
Given multiple sorting keys, which can be interpreted as columns in a
spreadsheet, lexsort returns an array of integer indices that describes
the sort order by multiple columns. The last key in the sequence is used
for the primary sort order, the second-to-last key for the secondary sort
order, and so on. The keys argument must be a sequence of objects that
can be converted to arrays of the same shape. If a 2D array is provided
for the keys argument, it's rows are interpreted as the sorting keys and
sorting is according to the last row, second last row etc.
 
Parameters
----------
keys : (k,N) array or tuple containing k (N,)-shaped sequences
    The `k` different "columns" to be sorted.  The last column (or row if
    `keys` is a 2D array) is the primary sort key.
axis : int, optional
    Axis to be indirectly sorted.  By default, sort over the last axis.
 
Returns
-------
indices : (N,) ndarray of ints
    Array of indices that sort the keys along the specified axis.
 
See Also
--------
argsort : Indirect sort.
ndarray.sort : In-place sort.
sort : Return a sorted copy of an array.
 
Examples
--------
Sort names: first by surname, then by name.
 
>>> surnames =    ('Hertz',    'Galilei', 'Hertz')
>>> first_names = ('Heinrich', 'Galileo', 'Gustav')
>>> ind = np.lexsort((first_names, surnames))
>>> ind
array([1, 2, 0])
 
>>> [surnames[i] + ", " + first_names[i] for i in ind]
['Galilei, Galileo', 'Hertz, Gustav', 'Hertz, Heinrich']
 
Sort two columns of numbers:
 
>>> a = [1,5,1,4,3,4,4] # First column
>>> b = [9,4,0,4,0,2,1] # Second column
>>> ind = np.lexsort((b,a)) # Sort by a, then by b
>>> print ind
[2 0 4 6 5 3 1]
 
>>> [(a[i],b[i]) for i in ind]
[(1, 0), (1, 9), (3, 0), (4, 1), (4, 2), (4, 4), (5, 4)]
 
Note that sorting is first according to the elements of ``a``.
Secondary sorting is according to the elements of ``b``.
 
A normal ``argsort`` would have yielded:
 
>>> [(a[i],b[i]) for i in np.argsort(a)]
[(1, 9), (1, 0), (3, 0), (4, 4), (4, 2), (4, 1), (5, 4)]
 
Structured arrays are sorted lexically by ``argsort``:
 
>>> x = np.array([(1,9), (5,4), (1,0), (4,4), (3,0), (4,2), (4,1)],
...              dtype=np.dtype([('x', int), ('y', int)]))
 
>>> np.argsort(x) # or np.argsort(x, order=('x', 'y'))
array([2, 0, 4, 6, 5, 3, 1])
loads(...)
loads(string) -- Load a pickle from the given string
newbuffer(...)
newbuffer(size)
 
Return a new uninitialized buffer object of size bytes
packbits(...)
packbits(myarray, axis=None)
 
Packs the elements of a binary-valued array into bits in a uint8 array.
 
The result is padded to full bytes by inserting zero bits at the end.
 
Parameters
----------
myarray : array_like
    An integer type array whose elements should be packed to bits.
axis : int, optional
    The dimension over which bit-packing is done.
    ``None`` implies packing the flattened array.
 
Returns
-------
packed : ndarray
    Array of type uint8 whose elements represent bits corresponding to the
    logical (0 or nonzero) value of the input elements. The shape of
    `packed` has the same number of dimensions as the input (unless `axis`
    is None, in which case the output is 1-D).
 
See Also
--------
unpackbits: Unpacks elements of a uint8 array into a binary-valued output
            array.
 
Examples
--------
>>> a = np.array([[[1,0,1],
...                [0,1,0]],
...               [[1,1,0],
...                [0,0,1]]])
>>> b = np.packbits(a, axis=-1)
>>> b
array([[[160],[64]],[[192],[32]]], dtype=uint8)
 
Note that in binary 160 = 1010 0000, 64 = 0100 0000, 192 = 1100 0000,
and 32 = 0010 0000.
putmask(...)
putmask(a, mask, values)
 
Changes elements of an array based on conditional and input values.
 
Sets ``a.flat[n] = values[n]`` for each n where ``mask.flat[n]==True``.
 
If `values` is not the same size as `a` and `mask` then it will repeat.
This gives behavior different from ``a[mask] = values``.
 
Parameters
----------
a : array_like
    Target array.
mask : array_like
    Boolean mask array. It has to be the same shape as `a`.
values : array_like
    Values to put into `a` where `mask` is True. If `values` is smaller
    than `a` it will be repeated.
 
See Also
--------
place, put, take
 
Examples
--------
>>> x = np.arange(6).reshape(2, 3)
>>> np.putmask(x, x>2, x**2)
>>> x
array([[ 0,  1,  2],
       [ 9, 16, 25]])
 
If `values` is smaller than `a` it is repeated:
 
>>> x = np.arange(5)
>>> np.putmask(x, x>1, [-33, -44])
>>> x
array([  0,   1, -33, -44, -33])
restoredot(...)
Restore `dot`, `vdot`, and `innerproduct` to the default non-BLAS
implementations.
 
Typically, the user will only need to call this when troubleshooting and
installation problem, reproducing the conditions of a build without an
accelerated BLAS, or when being very careful about benchmarking linear
algebra operations.
 
See Also
--------
alterdot : `restoredot` undoes the effects of `alterdot`.
set_numeric_ops(...)
set_numeric_ops(op1=func1, op2=func2, ...)
 
Set numerical operators for array objects.
 
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
[10000, 0, 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
unpackbits(...)
unpackbits(myarray, axis=None)
 
Unpacks elements of a uint8 array into a binary-valued output array.
 
Each element of `myarray` represents a bit-field that should be unpacked
into a binary-valued output array. The shape of the output array is either
1-D (if `axis` is None) or the same shape as the input array with unpacking
done along the axis specified.
 
Parameters
----------
myarray : ndarray, uint8 type
   Input array.
axis : int, optional
   Unpacks along this axis.
 
Returns
-------
unpacked : ndarray, uint8 type
   The elements are binary-valued (0 or 1).
 
See Also
--------
packbits : Packs the elements of a binary-valued array into bits in a uint8
           array.
 
Examples
--------
>>> a = np.array([[2], [7], [23]], dtype=np.uint8)
>>> a
array([[ 2],
       [ 7],
       [23]], dtype=uint8)
>>> b = np.unpackbits(a, axis=1)
>>> b
array([[0, 0, 0, 0, 0, 0, 1, 0],
       [0, 0, 0, 0, 0, 1, 1, 1],
       [0, 0, 0, 1, 0, 1, 1, 1]], dtype=uint8)
vdot(...)
Return the dot product of two vectors.
 
The vdot(`a`, `b`) function handles complex numbers differently than
dot(`a`, `b`).  If the first argument is complex the complex conjugate
of the first argument is used for the calculation of the dot product.
 
Note that `vdot` handles multidimensional arrays differently than `dot`:
it does *not* perform a matrix product, but flattens input arguments
to 1-D vectors first. Consequently, it should only be used for vectors.
 
Parameters
----------
a : array_like
    If `a` is complex the complex conjugate is taken before calculation
    of the dot product.
b : array_like
    Second argument to the dot product.
 
Returns
-------
output : ndarray
    Dot product of `a` and `b`.  Can be an int, float, or
    complex depending on the types of `a` and `b`.
 
See Also
--------
dot : Return the dot product without using the complex conjugate of the
      first argument.
 
Examples
--------
>>> a = np.array([1+2j,3+4j])
>>> b = np.array([5+6j,7+8j])
>>> np.vdot(a, b)
(70-8j)
>>> np.vdot(b, a)
(70+8j)
 
Note that higher-dimensional arrays are flattened!
 
>>> a = np.array([[1, 4], [5, 6]])
>>> b = np.array([[4, 1], [2, 2]])
>>> np.vdot(a, b)
30
>>> np.vdot(b, a)
30
>>> 1*4 + 4*1 + 5*2 + 6*2
30
where(...)
where(condition, [x, y])
 
Return elements, either from `x` or `y`, depending on `condition`.
 
If only `condition` is given, return ``condition.nonzero()``.
 
Parameters
----------
condition : array_like, bool
    When True, yield `x`, otherwise yield `y`.
x, y : array_like, optional
    Values from which to choose. `x` and `y` need to have the same
    shape as `condition`.
 
Returns
-------
out : ndarray or tuple of ndarrays
    If both `x` and `y` are specified, the output array contains
    elements of `x` where `condition` is True, and elements from
    `y` elsewhere.
 
    If only `condition` is given, return the tuple
    ``condition.nonzero()``, the indices where `condition` is True.
 
See Also
--------
nonzero, choose
 
Notes
-----
If `x` and `y` are given and input arrays are 1-D, `where` is
equivalent to::
 
    [xv if c else yv for (c,xv,yv) in zip(condition,x,y)]
 
Examples
--------
>>> np.where([[True, False], [True, True]],
...          [[1, 2], [3, 4]],
...          [[9, 8], [7, 6]])
array([[1, 8],
       [3, 4]])
 
>>> np.where([[0, 1], [1, 0]])
(array([0, 1]), array([1, 0]))
 
>>> x = np.arange(9.).reshape(3, 3)
>>> np.where( x > 5 )
(array([2, 2, 2]), array([0, 1, 2]))
>>> x[np.where( x > 3.0 )]               # Note: result is 1D.
array([ 4.,  5.,  6.,  7.,  8.])
>>> np.where(x < 5, x, -1)               # Note: broadcasting.
array([[ 0.,  1.,  2.],
       [ 3.,  4., -1.],
       [-1., -1., -1.]])
zeros(...)
zeros(shape, dtype=float, order='C')
 
Return a new array of given shape and type, filled with zeros.
 
Parameters
----------
shape : int or sequence 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
    Whether to store multidimensional data in C- or Fortran-contiguous
    (row- or column-wise) 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.
ones_like : Return an array of ones with shape and type of input.
empty_like : Return an empty array with shape and type of input.
ones : Return a new array setting values to one.
empty : Return a new uninitialized array.
 
Examples
--------
>>> np.zeros(5)
array([ 0.,  0.,  0.,  0.,  0.])
 
>>> np.zeros((5,), dtype=numpy.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 = 10000
CLIP = 0
ERR_CALL = 3
ERR_DEFAULT = 0
ERR_DEFAULT2 = 2084
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
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 = (<type 'int'>, <type 'float'>, <type 'complex'>, <type 'long'>, <type 'bool'>, <type 'str'>, <type 'unicode'>, <type 'buffer'>, <type 'numpy.complex128'>, <type 'numpy.void'>, <type 'numpy.uint64'>, <type 'numpy.complex64'>, <type 'numpy.unicode_'>, <type 'numpy.bool_'>, <type 'numpy.uint32'>, <type 'numpy.float128'>, <type 'numpy.int64'>, <type 'numpy.int16'>, <type 'numpy.uint16'>, <type 'numpy.int32'>, ...)
True_ = True
UFUNC_BUFSIZE_DEFAULT = 10000
UFUNC_PYVALS_NAME = 'UFUNC_PYVALS'
WRAP = 1
__version__ = '1.5.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'>
bpch2_fill_flt_val = -999.0
bpch2_fill_str_val = '???'
bpch2_fill_val = -999
c_ = <numpy.lib.index_tricks.CClass object>
cast = {<type 'numpy.complex128'>: <function <lambda> a...numpy.uint64'>: <function <lambda> at 0x1710aa0>}
ceil = <ufunc 'ceil'>
conj = <ufunc 'conjugate'>
conjugate = <ufunc 'conjugate'>
copysign = <ufunc 'copysign'>
cos = <ufunc 'cos'>
cosh = <ufunc 'cosh'>
def_diaginfo_file = 'diaginfo.dat'
def_tracerinfo_file = 'tracerinfo.dat'
deg2rad = <ufunc 'deg2rad'>
degrees = <ufunc 'degrees'>
divide = <ufunc 'divide'>
e = 2.718281828459045
equal = <ufunc 'equal'>
exp = <ufunc 'exp'>
exp2 = <ufunc 'exp2'>
expm1 = <ufunc 'expm1'>
fabs = <ufunc 'fabs'>
floor = <ufunc 'floor'>
floor_divide = <ufunc 'floor_divide'>
fmax = <ufunc 'fmax'>
fmin = <ufunc 'fmin'>
fmod = <ufunc 'fmod'>
frexp = <ufunc 'frexp'>
greater = <ufunc 'greater'>
greater_equal = <ufunc 'greater_equal'>
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'>
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'>
maximum = <ufunc 'maximum'>
mgrid = <numpy.lib.index_tricks.nd_grid object>
minimum = <ufunc 'minimum'>
mod = <ufunc 'remainder'>
modf = <ufunc 'modf'>
multiply = <ufunc 'multiply'>
nan = nan
nbytes = {<type 'numpy.complex128'>: 16, <type 'numpy.voi...type 'numpy.int64'>: 8, <type 'numpy.uint64'>: 8}
negative = <ufunc 'negative'>
newaxis = None
nextafter = <ufunc 'nextafter'>
not_equal = <ufunc 'not_equal'>
ogrid = <numpy.lib.index_tricks.nd_grid object>
ones_like = <ufunc 'ones_like'>
pi = 3.141592653589793
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 = {0: <type 'numpy.bool_'>, 1: <type 'numpy.int8'>, 2: <type 'numpy.uint8'>, 3: <type 'numpy.int16'>, 4: <type 'numpy.uint16'>, 5: <type 'numpy.int32'>, 6: <type 'numpy.uint32'>, 7: <type 'numpy.int64'>, 8: <type 'numpy.uint64'>, 9: <type 'numpy.int64'>, ...}
sctypeNA = {'?': 'Bool', 'B': 'UInt8', 'Bool': <type 'numpy.bool_'>, 'Complex128': <type 'numpy.complex256'>, 'Complex32': <type 'numpy.complex64'>, 'Complex64': <type 'numpy.complex128'>, 'D': 'Complex64', 'F': 'Complex32', 'Float128': <type 'numpy.float128'>, 'Float32': <type 'numpy.float32'>, ...}
sctypes = {'complex': [<type 'numpy.complex64'>, <type 'numpy.complex128'>, <type 'numpy.complex256'>], 'float': [<type 'numpy.float32'>, <type 'numpy.float64'>, <type 'numpy.float128'>], 'int': [<type 'numpy.int8'>, <type 'numpy.int16'>, <type 'numpy.int32'>, <type 'numpy.int64'>], 'others': [<type 'bool'>, <type 'object'>, <type 'str'>, <type 'unicode'>, <type 'numpy.void'>], 'uint': [<type 'numpy.uint8'>, <type 'numpy.uint16'>, <type 'numpy.uint32'>, <type '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'>
true_divide = <ufunc 'true_divide'>
trunc = <ufunc 'trunc'>
typeDict = {0: <type 'numpy.bool_'>, 1: <type 'numpy.int8'>, 2: <type 'numpy.uint8'>, 3: <type 'numpy.int16'>, 4: <type 'numpy.uint16'>, 5: <type 'numpy.int32'>, 6: <type 'numpy.uint32'>, 7: <type 'numpy.int64'>, 8: <type 'numpy.uint64'>, 9: <type 'numpy.int64'>, ...}
typeNA = {'?': 'Bool', 'B': 'UInt8', 'Bool': <type 'numpy.bool_'>, 'Complex128': <type 'numpy.complex256'>, 'Complex32': <type 'numpy.complex64'>, 'Complex64': <type 'numpy.complex128'>, 'D': 'Complex64', 'F': 'Complex32', 'Float128': <type 'numpy.float128'>, 'Float32': <type 'numpy.float32'>, ...}
typecodes = {'All': '?bhilqpBHILQPfdgFDGSUVO', 'AllFloat': 'fdgFDG', 'AllInteger': 'bBhHiIlLqQpP', 'Character': 'c', 'Complex': 'FDG', 'Float': 'fdg', 'Integer': 'bhilqp', 'UnsignedInteger': 'BHILQP'}