cf.DomainAncillary.set_data

DomainAncillary.set_data(data, copy=True, inplace=True)[source]

Set the data.

The units, calendar and fill value of the incoming Data instance are removed prior to insertion.

New in version 3.0.0.

Parameters
data: Data

The data to be inserted.

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

copy: bool, optional

If False then do not copy the data prior to insertion. By default the data are copied.

inplace: bool, optional:

If True (the default) then do the operation in-place and return None. If False a new, modified DomainAncillary instance is returned.

New in version 3.7.0.

Returns
None or DomainAncillary

If the operation was in-place then None is returned, otherwise return a new DomainAncillary instance containing the new data.

Examples

>>> f = cf.DomainAncillary()
>>> f.set_data([1, 2, 3])
>>> f.has_data()
True
>>> f.get_data()
<CF Data(3): [1, 2, 3]>
>>> f.data
<CF Data(3): [1, 2, 3]>
>>> f.del_data()
<CF Data(3): [1, 2, 3]>
>>> g = f.set_data([4, 5, 6], inplace=False)
>>> g.data
<CF Data(3): [4, 5, 6]>
>>> f.has_data()
False
>>> print(f.get_data(None))
None
>>> print(f.del_data(None))
None