cf.PartitionMatrix

class cf.PartitionMatrix(matrix, dimensions)[source]

Bases: object

A hyperrectangular partition matrix of a master data array.

Each of elements (called partitions) span all or part of exactly one sub-array of the master data array.

A partition matrix is indexable in a similar way to numpy array apart from two important extensions to the numpy indexing functionality:

  • Size 1 dimensions are always removed (note that this is different to the behaviour of a cf.Data object).
  • When advanced indexing is used on more than one dimension, the advanced indices work independently.

Initialization

Parameters :
matrix : numpy.ndarray

An array of Partition objects.

dimensions : list

The identities of the partition dimensions of the partition array. If the partition matrix is a scalar array then it is an empty list. The list is not copied.

Examples

>>> pm = PartitionMatrix(
...          numpy.array(Partition(location    = [(0, 1), (2, 4)],
...                                shape       = [1, 2],
...                                _dimensions = ['dim2', 'dim0'],
...                                _directions = {'dim2': True, 'dim0': False},
...                                Units       = cf.Units('m'),
...                                part        = [],
...                                data        = numpy.array([[5, 6], [7, 8]])),
...                      dtype=object),
...          dimensions=[])

PartitionMatrix attributes

ndim The number of partition dimensions in the partition matrix.
shape List of the partition matrix’s dimension sizes.
size The number of partitions in the partition matrix.

PartitionMatrix methods

Undocumented methods behave exactly as their counterparts in a built-in list.

add_partitions Add partition boundaries.
change_axis_names dim_name_map should be a dictionary which maps each dimension names in
copy Return a deep copy.
expand_dims Insert a new size 1 partition dimension in place.
ndenumerate Return an iterator yielding pairs of array indices and values.
partition_boundaries Return the partition boundaries for each dimension.
rollaxis Roll the specified partition dimension backwards,in place until it lies in a given position.
set_location_map Recalculate the location attribute of each partition of the partition matrix in place.
squeeze Remove all size 1 partition dimensions in place.
transpose Permute the partition dimensions of the partition matrix in place.

Table Of Contents

Previous topic

cf.Partition.update_inplace_from

Next topic

cf.PartitionMatrix.ndim

This Page