cf.Partition

class cf.Partition(subarray=None, _directions=None, location=None, shape=None, Units=None, part=None, _dimensions=None)[source]

Bases: object

A partition of a master data array.

The partition spans all or part of exactly one sub-array of the master data array

Initialization

Parameters :
subarray : numpy array-like, optional

The sub-array for the partition. Must be a numpy array or any array storing object with a similar interface. DO NOT UPDATE INPLACE.

_directions : dict or bool, optional

The direction of each dimension of the partition’s sub-array. It is a boolean if the partition’s sub-array is a scalar array, otherwise it is a dictionary keyed by the dimensions’ identities as found in _dimensions. DO NOT UPDATE INPLACE.

location : list, optional

The location of the partition’s data array in the master array. DO NOT UPDATE INPLACE.

_dimensions : list, optional

The identities of the dimensions of the partition’s sub-array. If the partition’s sub-array a scalar array then it is an empty list. DO NOT UPDATE INPLACE.

part : list, optional

The part of the partition’s sub-array which comprises its data array. If the partition’s data array is to the whole sub-array then part may be an empty list. DO NOT UPDATE INPLACE.

shape : list, optional

The shape of the partition’s data array as a subspace of the master array. If the master array is a scalar array then shape is an empty list. By default the shape is inferred from location. DO NOT UPDATE INPLACE.

Units : Units, optional

The units of the partition’s sub-array. DO NOT UPDATE INPLACE.

Examples

>>> p = Partition(subarray   = numpy.arange(20).reshape(2,5,1),
...               _directions = {'dim0', True, 'dim1': False, 'dim2': True},
...               location   = [(0, 6), (1, 3), (4, 5)],
...               _dimensions = ['dim1', 'dim0', 'dim2'],
...               part       = [],
...               Units      = cf.Units('K'))
>>> p = Partition(subarray       = numpy.arange(20).reshape(2,5,1),
...               _directions = {'dim0', True, 'dim1': False, 'dim2': True},
...               location   = [(0, 6), (1, 3), (4, 5)],
...               _dimensions = ['dim1', 'dim0', 'dim2'],
...               shape      = [5, 2, 1],
...               part       = [slice(None, None, -1), [0,1,3,4], slice(None)],
...               Units      = cf.Units('K'))
>>> p = Partition(subarray   = numpy.array(4),
...               _directions = True,
...               location   = [(4, 5)],
...               _dimensions = ['dim1'],
...               part       = [],
...               Units      = cf.Units('K'))

Partition attributes

in_memory True if and only if the partition’s sub-array is in memory as opposed to on disk.
indices The indices of the master array which correspond to this partition’s data array.
isscalar True if and only if the partition’s data array and sub-array are both a scalar arrays.
on_disk True if and only if the partition’s sub-array is on disk as opposed to in memory.

Partition methods

change_axis_names Change the axis names.
close Close the partition after it has been conformed.
copy Return a deep copy.
dataarray Returns the partition’s data array.
file_close Close all file containing the sub-array, if there is one.
is_partition Completely update the partition with another partition’s attributes in place.
master_ndindex Return an iterator over indices of the master array which are spanned by the conformed array.
ndindex Return an iterator over the N-dimensional indices of the partition’s
new_part Update the part attribute in-place.
overlaps Return True if the sub-array overlaps a subspace of the master array.
to_disk Store the partition’s sub-array in a temporary file on disk in place.
update_inplace_from Completely update the partition with another partition’s attributes in place.

Table Of Contents

Previous topic

cf.Variable.transpose

Next topic

cf.Partition.in_memory

This Page