| | |
- GaGrid
- numpy.ma.core.MaskedArray(numpy.ndarray)
-
- GaField
class GaField(numpy.ma.core.MaskedArray) |
| |
This is GraDS version of a n-dimensional array: a masked array with
a *grid* containing coordinate/dimension information attached to it.
As a MaskedArray, GaField objects may possibly have masked values.
Masked values of 1 exclude the corresponding element from any
computation.
Construction:
x = GaField (data, name=None, Grid=None,
dtype=None, copy=True, order=False,
mask = nomask, fill_value=None)
If copy=False, every effort is made not to copy the data:
If data is a MaskedArray, and argument mask=nomask,
then the candidate data is data.data and the
mask used is data.mask. If data is a numeric array,
it is used as the candidate raw data.
If dtype is not None and
is != data.dtype.char then a data copy is required.
Otherwise, the candidate is used.
If a data copy is required, raw data stored is the result of:
numeric.array(data, dtype=dtype.char, copy=copy)
If mask is nomask there are no masked values. Otherwise mask must
be convertible to an array of booleans with the same shape as x.
fill_value is used to fill in masked values when necessary,
such as when printing and in method/function filled().
The fill_value is not used for computation within this module. |
| |
- Method resolution order:
- GaField
- numpy.ma.core.MaskedArray
- numpy.ndarray
- __builtin__.object
Methods defined here:
- __abs__ = wrapper(self, *args, **kwargs)
- __add__ = wrapper(self, *args, **kwargs)
- __and__ = wrapper(self, *args, **kwargs)
- __array__ = wrapper(self, *args, **kwargs)
- __div__ = wrapper(self, *args, **kwargs)
- __eq__ = wrapper(self, *args, **kwargs)
- __float__ = wrapper(self, *args, **kwargs)
- __floordiv__ = wrapper(self, *args, **kwargs)
- __ge__ = wrapper(self, *args, **kwargs)
- __gt__ = wrapper(self, *args, **kwargs)
- __iadd__ = wrapper(self, *args, **kwargs)
- __idiv__ = wrapper(self, *args, **kwargs)
- __imul__ = wrapper(self, *args, **kwargs)
- __init__(self, data, name=None, grid=None, **kwargs)
- __int__ = wrapper(self, *args, **kwargs)
- __isub__ = wrapper(self, *args, **kwargs)
- __le__ = wrapper(self, *args, **kwargs)
- __lshift__ = wrapper(self, *args, **kwargs)
- __lt__ = wrapper(self, *args, **kwargs)
- __mod__ = wrapper(self, *args, **kwargs)
- __mul__ = wrapper(self, *args, **kwargs)
- __ne__ = wrapper(self, *args, **kwargs)
- __neg__ = wrapper(self, *args, **kwargs)
- __or__ = wrapper(self, *args, **kwargs)
- __pow__ = wrapper(self, *args, **kwargs)
- __radd__ = wrapper(self, *args, **kwargs)
- __rand__ = wrapper(self, *args, **kwargs)
- __rdiv__ = wrapper(self, *args, **kwargs)
- __rfloordiv__ = wrapper(self, *args, **kwargs)
- __rmod__ = wrapper(self, *args, **kwargs)
- __rmul__ = wrapper(self, *args, **kwargs)
- __ror__ = wrapper(self, *args, **kwargs)
- __rshift__ = wrapper(self, *args, **kwargs)
- __rsub__ = wrapper(self, *args, **kwargs)
- __rtruediv__ = wrapper(self, *args, **kwargs)
- __rxor__ = wrapper(self, *args, **kwargs)
- __sub__ = wrapper(self, *args, **kwargs)
- __truediv__ = wrapper(self, *args, **kwargs)
- __xor__ = wrapper(self, *args, **kwargs)
- copy(self)
- Returns a (partial) copy of a GaField.
BUG: a reference to the grid is returned, not a deep copy.
- ga_ops(op)
- ravel = wrapper(self, *args, **kwargs)
Static methods defined here:
- __new__(self, data, name=None, grid=None, **kwargs)
Methods inherited from numpy.ma.core.MaskedArray:
- __array_finalize__(self, obj)
- Finalizes the masked array.
- __array_wrap__(self, obj, context=None)
- Special hook for ufuncs.
Wraps the numpy array and sets the mask according to context.
- __getitem__(self, indx)
- x.__getitem__(y) <==> x[y]
Return the item described by i, as a masked array.
- __getslice__(self, i, j)
- x.__getslice__(i, j) <==> x[i:j]
Return the slice described by (i, j). The use of negative
indices is not supported.
- __getstate__(self)
- Return the internal state of the masked array, for pickling
purposes.
- __ipow__(self, other)
- Raise self to the power other, in place
- __reduce__(self)
- Return a 3-tuple for pickling a MaskedArray.
- __repr__(self)
- Literal string representation.
- __setitem__(self, indx, value)
- x.__setitem__(i, y) <==> x[i]=y
Set item described by index. If value is masked, masks those
locations.
- __setmask__(self, mask, copy=False)
- Set the mask.
- __setslice__(self, i, j, value)
- x.__setslice__(i, j, value) <==> x[i:j]=value
Set the slice (i,j) of a to value. If value is masked, mask
those locations.
- __setstate__(self, state)
- Restore the internal state of the masked array, for
pickling purposes. ``state`` is typically the output of the
``__getstate__`` output, and is a 5-tuple:
- class name
- a tuple giving the shape of the data
- a typecode for the data
- a binary string for the data
- a binary string for the mask.
- __str__(self)
- String representation.
- all(self, axis=None, out=None)
- Return True if all entries along the given axis are True,
False otherwise. Masked values are considered as True during
computation.
Parameter
----------
axis : int, optional
Axis along which the operation is performed. If None,
the operation is performed on a flatten array
out : {MaskedArray}, optional
Alternate optional output. If not None, out should be
a valid MaskedArray of the same shape as the output of
self._data.all(axis).
Returns A masked array, where the mask is True if all data along
-------
the axis are masked.
Notes
-----
An exception is raised if ``out`` is not None and not of the
same type as self.
- anom(self, axis=None, dtype=None)
- Return the anomalies (deviations from the average) along
the given axis.
Parameters
----------
axis : int, optional
Axis along which to perform the operation.
If None, applies to a flattened version of the array.
dtype : {dtype}, optional
Datatype for the intermediary computation. If not
given, the current dtype is used instead.
- any(self, axis=None, out=None)
- Returns True if at least one entry along the given axis is
True.
Returns False if all entries are False.
Masked values are considered as True during computation.
Parameter
----------
axis : int, optional
Axis along which the operation is performed.
If None, the operation is performed on a flatten array
out : {MaskedArray}, optional
Alternate optional output. If not None, out should be
a valid MaskedArray of the same shape as the output of
self._data.all(axis).
Returns A masked array, where the mask is True if all data along
-------
the axis are masked.
Notes
-----
An exception is raised if ``out`` is not None and not of the
same type as self.
- argmax(self, axis=None, fill_value=None)
- Returns the array of indices for the maximum values of `a`
along the specified axis.
Masked values are treated as if they had the value fill_value.
Parameters
----------
axis : int, optional
Axis along which to perform the operation.
If None, applies to a flattened version of the array.
fill_value : {var}, optional
Value used to fill in the masked values. If None, the
output of maximum_fill_value(self._data) is used.
- argmin(self, axis=None, fill_value=None)
- Return an ndarray of indices for the minimum values of a
along the specified axis.
Masked values are treated as if they had the value fill_value.
Parameters
----------
axis : int, optional
Axis along which to perform the operation.
If None, applies to a flattened version of the array.
fill_value : {var}, optional
Value used to fill in the masked values. If None, the
output of minimum_fill_value(self._data) is used.
- argsort(self, axis=None, fill_value=None, kind='quicksort', order=None)
- Return an ndarray of indices that sort the array along the
specified axis. Masked values are filled beforehand to
fill_value.
Parameters
----------
axis : int, optional
Axis to be indirectly sorted.
If not given, uses a flatten version of the array.
fill_value : {var}
Value used to fill in the masked values.
If not given, self.fill_value is used instead.
kind : {string}
Sorting algorithm (default 'quicksort')
Possible values: 'quicksort', 'mergesort', or 'heapsort'
Notes
-----
This method executes an indirect sort along the given axis
using the algorithm specified by the kind keyword. It returns
an array of indices of the same shape as 'a' that index data
along the given axis in sorted order.
The various sorts are characterized by average speed, worst
case performance need for work space, and whether they are
stable. A stable sort keeps items with the same key in the
same relative order. The three available algorithms have the
following properties:
|------------------------------------------------------|
| kind | speed | worst case | work space | stable|
|------------------------------------------------------|
|'quicksort'| 1 | O(n^2) | 0 | no |
|'mergesort'| 2 | O(n*log(n)) | ~n/2 | yes |
|'heapsort' | 3 | O(n*log(n)) | 0 | no |
|------------------------------------------------------|
All the sort algorithms make temporary copies of the data when
the sort is not along the last axis. Consequently, sorts along
the last axis are faster and use less space than sorts along
other axis.
- astype(self, newtype)
- Returns a copy of the array cast to newtype.
clip = <numpy.ma.core._arraymethod object at 0x101c030>
- compress(self, condition, axis=None, out=None)
- Return a where condition is True.
If condition is a MaskedArray, missing values are considered as False.
Returns
-------
A MaskedArray object.
Notes
-----
Please note the difference with compressed() !
The output of compress has a mask, the output of compressed does not.
- compressed(self)
- Return a 1-D array of all the non-masked data.
- count(self, axis=None)
- Count the non-masked elements of the array along the given
axis.
Parameters
----------
axis : int, optional
Axis along which to count the non-masked elements. If
not given, all the non masked elements are counted.
Returns
-------
A masked array where the mask is True where all data are
masked. If axis is None, returns either a scalar ot the
masked singleton if all values are masked.
- cumprod(self, axis=None, dtype=None)
- Return the cumulative product of the elements of the array
along the given axis.
Masked values are set to 1 internally.
Parameters
----------
axis : int, optional
Axis along which to perform the operation.
If None, applies to a flattened version of the array.
dtype : {dtype}, optional
Datatype for the intermediary computation. If not
given, the current dtype is used instead.
- cumsum(self, axis=None, dtype=None)
- Return the cumulative sum of the elements of the array
along the given axis.
Masked values are set to 0 internally.
Parameters
----------
axis : int, optional
Axis along which to perform the operation.
If None, applies to a flattened version of the array.
dtype : {dtype}, optional
Datatype for the intermediary computation. If not
given, the current dtype is used instead.
diagonal = <numpy.ma.core._arraymethod object at 0x100cf90>
- filled(self, fill_value=None)
- Return a copy of self._data, where masked values are filled
with fill_value.
If fill_value is None, self.fill_value is used instead.
Notes
-----
+ Subclassing is preserved
+ The result is NOT a MaskedArray !
Examples
--------
>>> x = array([1,2,3,4,5], mask=[0,0,1,0,1], fill_value=-999)
>>> x.filled()
array([1,2,-999,4,-999])
>>> type(x.filled())
<type 'numpy.ndarray'>
flatten = <numpy.ma.core._arraymethod object at 0x100cef0>
- get_fill_value(self)
- Return the filling value.
- get_imag(self)
- #............................................
- get_real(self)
- harden_mask(self)
- Force the mask to hard.
- ids(self)
- Return the addresses of the data and mask areas.
- max(self, axis=None, fill_value=None)
- Return the maximum/a along the given axis.
Masked values are filled with fill_value.
Parameters
----------
axis : int, optional
Axis along which to perform the operation.
If None, applies to a flattened version of the array.
fill_value : {var}, optional
Value used to fill in the masked values.
If None, use the the output of maximum_fill_value().
- mean(self, axis=None, dtype=None, out=None)
- Average the array over the given axis. Equivalent to
a.sum(axis, dtype) / a.size(axis).
Parameters
----------
axis : int, optional
Axis along which to perform the operation.
If None, applies to a flattened version of the array.
dtype : {dtype}, optional
Datatype for the intermediary computation. If not
given, the current dtype is used instead.
- min(self, axis=None, fill_value=None)
- Return the minimum of a along the given axis.
Masked values are filled with fill_value.
Parameters
----------
axis : int, optional
Axis along which to perform the operation.
If None, applies to a flattened version of the array.
fill_value : {var}, optional
Value used to fill in the masked values.
If None, use the the output of minimum_fill_value().
- mini(self, axis=None)
- nonzero(self)
- Return the indices of the elements of a that are not zero
nor masked, as a tuple of arrays.
There are as many tuples as dimensions of a, each tuple
contains the indices of the non-zero elements in that
dimension. The corresponding non-zero values can be obtained
with ``a[a.nonzero()]``.
To group the indices by element, rather than dimension, use
instead: ``transpose(a.nonzero())``.
The result of this is always a 2d array, with a row for each
non-zero element.
- prod(self, axis=None, dtype=None)
- Return the product of the elements of the array along the
given axis.
Masked elements are set to 1 internally.
Parameters
----------
axis : int, optional
Axis along which to perform the operation.
If None, applies to a flattened version of the array.
dtype : {dtype}, optional
Datatype for the intermediary computation. If not
given, the current dtype is used instead.
- product = prod(self, axis=None, dtype=None)
- Return the product of the elements of the array along the
given axis.
Masked elements are set to 1 internally.
Parameters
----------
axis : int, optional
Axis along which to perform the operation.
If None, applies to a flattened version of the array.
dtype : {dtype}, optional
Datatype for the intermediary computation. If not
given, the current dtype is used instead.
- ptp(self, axis=None, fill_value=None)
- Return the visible data range (max-min) along the given axis.
Parameters
----------
axis : int, optional
Axis along which to perform the operation.
If None, applies to a flattened version of the array.
fill_value : {var}, optional
Value used to fill in the masked values. If None, the
maximum uses the maximum default, the minimum uses the
minimum default.
- put(self, indices, values, mode='raise')
- Set storage-indexed locations to corresponding values.
a.put(values, indices, mode) sets a.flat[n] = values[n] for
each n in indices. If ``values`` is shorter than ``indices``
then it will repeat. If ``values`` has some masked values, the
initial mask is updated in consequence, else the corresponding
values are unmasked.
- raw_data(self)
- Return the _data part of the MaskedArray.
DEPRECATED: You should really use ``.data`` instead...
repeat = <numpy.ma.core._arraymethod object at 0x100cf10>
- reshape(self, *s)
- Reshape the array to shape s.
Returns
-------
A new masked array.
Notes
-----
If you want to modify the shape in place, please use
``a.shape = s``
- resize(self, newshape, refcheck=True, order=False)
- Attempt to modify the size and the shape of the array in place.
The array must own its own memory and not be referenced by
other arrays.
Returns
-------
None.
- round(self, decimals=0, out=None)
- a.round(decimals=0, out=None)
Return an array rounded a to the given number of decimals.
The real and imaginary parts of complex numbers are rounded separately. The
result of rounding a float is a float so the type must be cast if integers
are desired. Nothing is done if the input is an integer array and the
decimals parameter has a value >= 0.
Parameters
----------
decimals : {0, integer}, optional
Number of decimal places to round to. When decimals is negative it
specifies the number of positions to the left of the decimal point.
out : {None, array}, optional
Alternative output array in which to place the result. It must have
the same shape as the expected output but the type will be cast if
necessary.
Returns
-------
rounded_array : {array}
If out=None, returns a new array of the same type as a containing
the rounded values, otherwise a reference to the output array is
returned.
See Also
--------
around : equivalent function
Notes
-----
Numpy rounds to even. Thus 1.5 and 2.5 round to 2.0, -0.5 and 0.5 round
to 0.0, etc. Results may also be surprising due to the inexact
representation of decimal fractions in IEEE floating point and the
errors introduced when scaling by powers of ten.
Examples
--------
>>> x = array([.5, 1.5, 2.5, 3.5, 4.5])
>>> x.round()
array([ 0., 2., 2., 4., 4.])
>>> x = array([1,2,3,11])
>>> x.round(decimals=1)
array([ 1, 2, 3, 11])
>>> x.round(decimals=-1)
array([ 0, 0, 0, 10])
- set_fill_value(self, value=None)
- Set the filling value to value.
If value is None, use a default based on the data type.
- shrink_mask(self)
- Reduce a mask to nomask when possible.
- soften_mask(self)
- Force the mask to soft.
- sort(self, axis=-1, kind='quicksort', order=None, endwith=True, fill_value=None)
- Sort along the given axis.
Parameters
----------
axis : int
Axis to be indirectly sorted.
kind : {string}
Sorting algorithm (default 'quicksort')
Possible values: 'quicksort', 'mergesort', or 'heapsort'.
order : {var}
If a has fields defined, then the order keyword can be
the field name to sort on or a list (or tuple) of
field names to indicate the order that fields should
be used to define the sort.
fill_value : {var}
Value used to fill in the masked values. If None, use
the the output of minimum_fill_value().
endwith : bool
Whether missing values (if any) should be forced in
the upper indices (at the end of the array) (True) or
lower indices (at the beginning).
Returns
-------
When used as method, returns None.
When used as a function, returns an array.
Notes
-----
This method sorts 'a' in place along the given axis using
the algorithm specified by the kind keyword.
The various sorts may characterized by average speed,
worst case performance need for work space, and whether
they are stable. A stable sort keeps items with the same
key in the same relative order and is most useful when
used w/ argsort where the key might differ from the items
being sorted. The three available algorithms have the
following properties:
|------------------------------------------------------|
| kind | speed | worst case | work space | stable|
|------------------------------------------------------|
|'quicksort'| 1 | O(n^2) | 0 | no |
|'mergesort'| 2 | O(n*log(n)) | ~n/2 | yes |
|'heapsort' | 3 | O(n*log(n)) | 0 | no |
|------------------------------------------------------|
squeeze = <numpy.ma.core._arraymethod object at 0x100cf70>
- std(self, axis=None, dtype=None, ddof=0)
- Return the standard deviation, a measure of the spread of a
distribution.
The standard deviation is the square root of the average of
the squared deviations from the mean, i.e.
std = sqrt(mean(abs(x - x.mean())**2)).
Parameters
----------
axis : int, optional
Axis along which to perform the operation.
If None, applies to a flattened version of the array.
dtype : {dtype}, optional
Datatype for the intermediary computation.
If not given, the current dtype is used instead.
Notes
-----
The value returned is by default a biased estimate of the
true standard deviation, since the mean is computed by dividing
by N-ddof. For the more standard unbiased estimate, use ddof=1.
Note that for complex numbers the absolute value is taken before
squaring, so that the result is always real and nonnegative.
- sum(self, axis=None, dtype=None)
- Sum the array over the given axis.
Masked elements are set to 0 internally.
Parameters
----------
axis : int, optional
Axis along which to perform the operation.
If None, applies to a flattened version of the array.
dtype : dtype, optional
Datatype for the intermediary computation. If not given,
the current dtype is used instead.
swapaxes = <numpy.ma.core._arraymethod object at 0x100cff0>
take = <numpy.ma.core._arraymethod object at 0x100cfb0>
- tofile(self, fid, sep='', format='%s')
- #........................
- tolist(self, fill_value=None)
- Copy the data portion of the array to a hierarchical python
list and returns that list.
Data items are converted to the nearest compatible Python
type. Masked values are converted to fill_value. If
fill_value is None, the corresponding entries in the output
list will be ``None``.
- tostring(self, fill_value=None, order='C')
- Return a copy of array data as a Python string containing the raw
bytes in the array.
Parameters
----------
fill_value : {var}, optional
Value used to fill in the masked values.
If None, uses self.fill_value instead.
order : {string}
Order of the data item in the copy {"C","F","A"}.
"C" -- C order (row major)
"Fortran" -- Fortran order (column major)
"Any" -- Current order of array.
None -- Same as "Any"
- trace(self, offset=0, axis1=0, axis2=1, dtype=None, out=None)
- a.trace(offset=0, axis1=0, axis2=1, dtype=None, out=None)
Return the sum along the offset diagonal of the array's
indicated `axis1` and `axis2`.
transpose = <numpy.ma.core._arraymethod object at 0x100cfd0>
- unshare_mask(self)
- Copy the mask and set the sharedmask flag to False.
- var(self, axis=None, dtype=None, ddof=0)
- Return the variance, a measure of the spread of a distribution.
The variance is the average of the squared deviations from the
mean, i.e. var = mean(abs(x - x.mean())**2).
Parameters
----------
axis : int, optional
Axis along which to perform the operation.
If None, applies to a flattened version of the array.
dtype : {dtype}, optional
Datatype for the intermediary computation. If not
given, the current dtype is used instead.
Notes
-----
The value returned is by default a biased estimate of the
true variance, since the mean is computed by dividing by N-ddof.
For the (more standard) unbiased estimate, use ddof=1 or.
Note that for complex numbers the absolute value is taken before
squaring, so that the result is always real and nonnegative.
Data descriptors inherited from numpy.ma.core.MaskedArray:
- T
- __dict__
- dictionary for instance variables (if defined)
- data
- Return the current data, as a view of the original
underlying data.
- fill_value
- Filling value.
- flat
- Flat version of the array.
- imag
- Imaginary part
- mask
- Mask
- real
- Real part
Data and other attributes inherited from numpy.ma.core.MaskedArray:
- __array_priority__ = 15
Methods inherited from numpy.ndarray:
- __contains__(...)
- x.__contains__(y) <==> y in x
- __copy__(...)
- a.__copy__([order])
Return a copy of the array.
Parameters
----------
order : {'C', 'F', 'A'}, optional
If order is 'C' (False) then the result is contiguous (default).
If order is 'Fortran' (True) then the result has fortran order.
If order is 'Any' (None) then the result has fortran order
only if the array already is in fortran order.
- __deepcopy__(...)
- a.__deepcopy__() -> Deep copy of array.
Used if copy.deepcopy is called on an array.
- __delitem__(...)
- x.__delitem__(y) <==> del x[y]
- __delslice__(...)
- x.__delslice__(i, j) <==> del x[i:j]
Use of negative indices is not supported.
- __divmod__(...)
- x.__divmod__(y) <==> divmod(x, y)
- __hex__(...)
- x.__hex__() <==> hex(x)
- __iand__(...)
- x.__iand__(y) <==> x&y
- __ifloordiv__(...)
- x.__ifloordiv__(y) <==> x//y
- __ilshift__(...)
- x.__ilshift__(y) <==> x<<y
- __imod__(...)
- x.__imod__(y) <==> x%y
- __index__(...)
- x[y:z] <==> x[y.__index__():z.__index__()]
- __invert__(...)
- x.__invert__() <==> ~x
- __ior__(...)
- x.__ior__(y) <==> x|y
- __irshift__(...)
- x.__irshift__(y) <==> x>>y
- __iter__(...)
- x.__iter__() <==> iter(x)
- __itruediv__(...)
- x.__itruediv__(y) <==> x/y
- __ixor__(...)
- x.__ixor__(y) <==> x^y
- __len__(...)
- x.__len__() <==> len(x)
- __long__(...)
- x.__long__() <==> long(x)
- __nonzero__(...)
- x.__nonzero__() <==> x != 0
- __oct__(...)
- x.__oct__() <==> oct(x)
- __pos__(...)
- x.__pos__() <==> +x
- __rdivmod__(...)
- x.__rdivmod__(y) <==> divmod(y, x)
- __rlshift__(...)
- x.__rlshift__(y) <==> y<<x
- __rpow__(...)
- y.__rpow__(x[, z]) <==> pow(x, y[, z])
- __rrshift__(...)
- x.__rrshift__(y) <==> y>>x
- byteswap(...)
- a.byteswap(False) -> View or copy. Swap the bytes in the array.
Swap the bytes in the array. Return the byteswapped array. If the first
argument is True, byteswap in-place and return a reference to self.
- choose(...)
- a.choose(choices, out=None, mode='raise')
Use an index array to construct a new array from a set of choices.
Given an array of integers and a set of n choice arrays, this method
will create a new array that merges each of the choice arrays. Where a
value in `a` is i, the new array will have the value that choices[i]
contains in the same place.
Parameters
----------
choices : sequence of arrays
Choice arrays. The index array and all of the choices should be
broadcastable to the same shape.
out : array, optional
If provided, the result will be inserted into this array. It should
be of the appropriate shape and dtype
mode : {'raise', 'wrap', 'clip'}, optional
Specifies how out-of-bounds indices will behave.
'raise' : raise an error
'wrap' : wrap around
'clip' : clip to the range
Returns
-------
merged_array : array
See Also
--------
choose : equivalent function
Examples
--------
>>> choices = [[0, 1, 2, 3], [10, 11, 12, 13],
... [20, 21, 22, 23], [30, 31, 32, 33]]
>>> a = array([2, 3, 1, 0], dtype=int)
>>> a.choose(choices)
array([20, 31, 12, 3])
>>> a = array([2, 4, 1, 0], dtype=int)
>>> a.choose(choices, mode='clip')
array([20, 31, 12, 3])
>>> a.choose(choices, mode='wrap')
array([20, 1, 12, 3])
- conj(...)
- a.conj()
Return an array with all complex-valued elements conjugated.
- conjugate(...)
- a.conjugate()
Return an array with all complex-valued elements conjugated.
- dump(...)
- a.dump(file)
Dump a pickle of the array to the specified file.
The array can be read back with pickle.load or numpy.load.
Parameters
----------
file : str
A string naming the dump file.
- dumps(...)
- a.dumps()
Returns the pickle of the array as a string.
pickle.loads or numpy.loads will convert the string back to an array.
- fill(...)
- a.fill(value)
Fill the array with a scalar value.
- getfield(...)
- a.getfield(dtype, offset)
Returns a field of the given array as a certain type. A field is a view of
the array data with each itemsize determined by the given type and the
offset into the current array.
- item(...)
- a.item()
Copy the first element of array to a standard Python scalar and return
it. The array must be of size one.
- itemset(...)
- newbyteorder(...)
- a.newbyteorder(byteorder)
Equivalent to a.view(a.dtype.newbytorder(byteorder))
- searchsorted(...)
- a.searchsorted(v, side='left')
Find the indices into a sorted array such that if the corresponding keys in
v were inserted before the indices the order of a would be preserved. If
side='left', then the first such index is returned. If side='right', then
the last such index is returned. If there is no such index because the key
is out of bounds, then the length of a is returned, i.e., the key would
need to be appended. The returned index array has the same shape as v.
Parameters
----------
v : array or list type
Array of keys to be searched for in a.
side : string
Possible values are : 'left', 'right'. Default is 'left'. Return
the first or last index where the key could be inserted.
Returns
-------
indices : integer array
The returned array has the same shape as v.
See also
--------
sort
histogram
Notes
-----
The array a must be 1-d and is assumed to be sorted in ascending order.
Searchsorted uses binary search to find the required insertion points.
- setfield(...)
- m.setfield(value, dtype, offset) -> None.
places val into field of the given array defined by the data type and offset.
- setflags(...)
- a.setflags(write=None, align=None, uic=None)
- view(...)
- a.view(dtype=None, type=None)
New view of array with the same data.
Parameters
----------
dtype : data-type
Data-type descriptor of the returned view, e.g. float32 or int16.
type : python type
Type of the returned view, e.g. ndarray or matrix.
Examples
--------
>>> x = np.array([(1,2)],dtype=[('a',np.int8),('b',np.int8)])
>>> y = x.view(dtype=np.int16, type=np.matrix)
>>> print y.dtype
int16
>>> print type(y)
<class 'numpy.core.defmatrix.matrix'>
Data descriptors inherited from numpy.ndarray:
- __array_interface__
- Array protocol: Python side.
- __array_struct__
- Array protocol: C-struct side.
- base
- Base object if memory is from some other object.
- ctypes
- A ctypes interface object.
- dtype
- Data-type for the array.
- flags
- Special object providing array flags.
- itemsize
- Length of one element in bytes.
- nbytes
- Number of bytes in the array.
- ndim
- Number of array dimensions.
- shape
- Tuple of array dimensions.
- size
- Number of elements in the array.
- strides
- Tuple of bytes to step in each dimension.
|
class GaGrid |
| |
A simple class for holding GrADS coordinate variables as well as
dimension environment information and other necessary metadata for
exchanging information with GrADS. A GaGrid object is usually
attached to a GaField object. |
| |
Methods defined here:
- __init__(self, name, coords=None)
- Creates an empty GaGrid object, or builds it from the GaHandle
object *coords* usually obtained from the dimension environment
with the GaCore method coords(), e.g.,
coords = ga.coords()
| |