cfdm.SparseArray


class cfdm.SparseArray(array=None, source=None, copy=True)[source]

Bases: Array

An underlying sparse array.

The sparse array is assumed to have the same API as scipy sparse arrays.

Added in version (cfdm): 1.11.0.0

Initialisation

Parameters:
array: numpy.ndarray

The numpy array.

source: optional

Convert source, which can be any type of object, to a SparseArray instance.

All other parameters, apart from copy, are ignored and their values are instead inferred from source by assuming that it has the SparseArray API. Any parameters that can not be retrieved from source in this way are assumed to have their default value.

Note that if x is also a SparseArray instance then cfdm.SparseArray(source=x) is equivalent to x.copy().

copy: bool, optional

If True (the default) then deep copy the input parameters prior to initialisation. By default the parameters are not deep copied.

Methods

Methods

Units

The Units object containing the units of the array.

array

Return an independent numpy array containing the data.

astype

Cast the data to a specified type.

copy

Return a deep copy of the array.

dtype

Data-type of the array.

get_attributes

The attributes of the array.

get_calendar

The calendar of the array.

get_compression_type

Returns the array's compression type.

get_units

The units of the array.

ndim

Number of array dimensions.

shape

Shape of the array.

size

Number of elements in the array.

sparse_array

Return an independent scipy sparse array of the data.

to_memory

Bring data on disk into memory.