cf.Data

class cf.Data(data=None)

Bases: cf.utils.CfList

Store CF data array. An ordered list of arrays may be stored which, when concatenated form the desired array.

Parameters:data – Initialize the data from this object, which may be a Data object or a numpy.ndarray or None. Any other type of object returns an empty Data instance.

Special attributes:

Attribute Description
_list  
shape  
order  
direction  
Units  
adim  
elements  

Methods and attributes defined here:

array

Create a numpy array copy of the concatenated data.

concatenate(*elements)

Concatenate element into a single numpy array

conform(elements=None)

Conform data according to its metadata.

copy(data=True)

Return a deep copy.

Parameters:data (bool) – Optional. If False then assign the output variable’s data arrays to None, with the expectation that the data will be replaced subsequently. The data object’s metadata are deep copied in any case.
Returns:A deep copy.
count(value)

CFL.count(value) -> integer – return number of occurrences of value

Uses numerically tolerant equality.

dtype

Data-type of the data’s elements.

Returns:A numpy dtype object.
equals(other, rtol=None, atol=None)

Return True if the data instance is congruent to another one in that

  1. They have identical data array. Pointers to data on disk may be converted to numpy arrays in memory if required.

Equality of numbers is to within a tolerance. Refer to cf for details.

Parameters:
  • other (object) – The variable to compare against for equality.
  • atol (None or float) – Optional. If None then use the default method for setting the absolute tolerance for numerical equality (refer to cf for details). If a number then set the absolute tolerance to this value for all such comparisons.
  • rtol (None or float) – Optional. If None then use the default method for setting the relative tolerance for numerical equality (refer to cf for details). If a number then set the relative tolerance to this value for all such comparisons.
Returns:

True if the two objects are congruent, False otherwise.

Examples:

>>> y = x
>>> x.equals(y)
True
index(value, start=0, stop=None)

CFL.index(value, [start, [stop]]) -> integer – return first index of value

Uses numerically tolerant equality.

insert(index, other)

D.insert(index, object) – insert Data object before index

ndim

Number of dimensions of the data.

Equivalent to the number of elements in shape tuple.

Returns:A non-negative integer
remove_dimension(index)

Remove a size 1 dimension fromt the data IN PLACE.

size

Number of elements in the data

Returns:A positive integer
slice

Return an object which, when indexed, returns a slice of the data.

varray

Create a numpy array view of the concatenated data.

Previous topic

cf.Units

Next topic

cf.VariableList

This Page