cf.Data.compressed

Data.compressed(inplace=False)[source]

Return all non-masked values in a one dimensional data array.

Not to be confused with compression by convention (see the uncompress method).

New in version 3.2.0.

See also

flatten

Parameters
inplace: bool, optional

If True then do the operation in-place and return None.

Returns
Data or None

The non-masked values, or None if the operation was in-place.

Examples

>>> d = cf.Data(numpy.arange(12).reshape(3, 4))
>>> print(d.array)
[[ 0  1  2  3]
 [ 4  5  6  7]
 [ 8  9 10 11]]
>>> print(d.compressed().array)
[ 0  1  2  3  4  5  6  7  8  9 10 11]
>>> d[1, 1] = cf.masked
>>> d[2, 3] = cf.masked
>>> print(d.array)
[[0  1  2  3]
 [4 --  6  7]
 [8  9 10 --]]
>>> print(d.compressed().array)
[ 0  1  2  3  4  6  7  8  9 10]
>>> d = cf.Data(9)
>>> print(d.array)
9
>>> print(d.compressed().array)
9