cfdm.core.Data

class cfdm.core.Data(array=None, units=None, calendar=None, fill_value=None, source=None, copy=True, _use_array=True, _custom_deep_copy=False)[source]

Bases: cfdm.core.abstract.container.Container

An orthogonal multidimensional array with masking and units.

New in version (cfdm): 1.7.0

Initialisation

Parameters
array: data_like, optional

The array of values.

A data_like object is any object that can be converted to a Data object, i.e. numpy array_like objects, Data objects, and cfdm.core instances that contain Data objects.

Note that for Data objects and cfdm.core objects that contain Data objects, cfdm.core.Data(array) is equivalent to cfdm.core.Data(source=array.__data__()).

array: numpy array_like, optional

The array of values.

Note that if array is another Data instance then cfdm.core.Data(array) is equivalent to cfdm.core.Data(source=array).

units: str, optional

The physical units of the data.

The units may also be set after initialisation with the set_units method.

Parameter example:

units='km hr-1'

Parameter example:

units='days since 2018-12-01'

calendar: str, optional

The calendar for reference time units.

The calendar may also be set after initialisation with the set_calendar method.

Parameter example:

calendar='360_day'

fill_value: optional

The fill value of the data. By default, or if set to None, the numpy fill value appropriate to the array’s data type will be used (see numpy.ma.default_fill_value).

The fill value may also be set after initialisation with the set_fill_value method.

Parameter example:

fill_value=-999.

source: optional

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

All other parameters, apart from copy, are ignored and their values are instead inferred from source by assuming that it has the Data 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 Data instance then cfdm.core.Data(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.

Inspection

Attributes

array

Return an independent numpy array containing the data.

dtype

Data-type of the data elements.

ndim

Number of data dimensions.

shape

Tuple of data dimension sizes.

size

Number of elements in the data.

Units

del_units

Delete the units.

get_units

Return the units.

has_units

Whether units have been set.

set_units

Set the units.

Date-time support

del_calendar

Delete the calendar.

get_calendar

Return the calendar.

has_calendar

Whether a calendar has been set.

set_calendar

Set the calendar.

Data creation routines

From existing data

copy

Return a deep copy of the data.

Mask support

del_fill_value

Delete the fill value.

get_fill_value

Return the missing data value.

has_fill_value

Whether a fill value has been set.

set_fill_value

Set the missing data value.

Miscellaneous

source

Return the underlying array object.

Special

__deepcopy__

Called by the copy.deepcopy function.

__repr__

Return repr(self).

__str__

Return str(self).

Docstring substitutions

Methods

_docstring_special_substitutions

Return the special docstring substitutions.

_docstring_substitutions

Returns the substitutions that apply to methods of the class.

_docstring_package_depth

Returns the class {{package}} substitutions package depth.

_docstring_method_exclusions

Returns method names excluded in the class substitutions.