Creating an Array

To make it easy to create an Array from existing data sources, biggus provides two adapter classes:

class biggus.NumpyArrayAdapter(concrete, keys=())

Exposes a “concrete” data source which supports NumPy “fancy indexing” as a biggus.Array.

A NumPy ndarray instance is an example suitable data source.

NB. NumPy “fancy indexing” contrasts with orthogonal indexing which treats multiple iterable index keys as independent.

class biggus.OrthoArrayAdapter(concrete, keys=())

Exposes a “concrete” data source which supports orthogonal indexing as a biggus.Array.

Orthogonal indexing treats multiple iterable index keys as independent (which is also the behaviour of a biggus.Array).

For example:

>>> ortho = OrthoArrayAdapter(ConstantArray(shape=[100, 200, 300]))
>>> ortho.shape
(100, 200, 300)
>>> ortho[(0, 3, 4), :, (1, 9)].shape
(3, 200, 2)

A netCDF4.Variable instance is an example orthogonal concrete array.

NB. Orthogonal indexing contrasts with NumPy “fancy indexing” where multiple iterable index keys are zipped together to allow the selection of sparse locations.

Constants

For creating an Array with the same value in every element, biggus provides a simple class and two convenience functions which mimic NumPy.

class biggus.ConstantArray(shape, value=0.0, dtype=None)

An Array which is completely filled with a single value.

Parameters:
  • shape (int or sequence of ints) – The shape for the new Array.
  • value (obj, optional) – The value to fill the Array with. Defaults to 0.0.
  • dtype (obj, optional) – Object to be converted to data type. Default is None which instructs the data type to be determined as the minimum required to hold the given value.
Returns:

An Array entirely filled with ‘value’.

Return type:

Array

biggus.zeros(shape, dtype=<type 'float'>)

Return an Array which is completely filled with zeros.

Parameters:
  • shape (int or sequence of ints) – The shape for the new Array.
  • dtype (obj, optional) – Object to be converted to data type. Default is float.
Returns:

An Array entirely filled with zeros.

Return type:

Array

biggus.ones(shape, dtype=<type 'float'>)

Return an Array which is completely filled with ones.

Parameters:
  • shape (int or sequence of ints) – The shape for the new Array.
  • dtype (obj, optional) – Object to be converted to data type. Default is float.
Returns:

An Array entirely filled with ones.

Return type:

Array

Combining arrays

Multiple arrays can be combined by stacking them along a new dimension, or concatenating along an existing dimension:

class biggus.ArrayStack(stack)

An Array made from a homogeneous array of other Arrays.

Parameters:stack (array-like) – The array of Arrays to be stacked, where each Array must be of the same shape.
class biggus.LinearMosaic(tiles, axis)