cfdm.Field.set_data¶
- Field.set_data(data, axes=None, copy=True, inplace=True)[source]¶
Set the data of the field construct.
The units, calendar and fill value properties of the data object are removed prior to insertion.
Added in version (cfdm): 1.7.0
See also
- Parameters:
- data: data_like
The data to be inserted.
A data_like object is any object that can be converted to a
Dataobject, i.e.numpyarray_like objects,Dataobjects, and cfdm instances that containDataobjects.- axes: (sequence of)
str, orNone The identifiers of the domain axes spanned by the data array. If
Nonethen the data axes are not set.The axes may also be set afterwards with the
set_data_axesmethod.- Parameter example:
axes=['domainaxis2']- Parameter example:
axes='domainaxis2'- Parameter example:
axes=['domainaxis2', 'domainaxis1']- Parameter example:
axes=None
- copy:
bool, optional If True (the default) then copy the data prior to insertion, else the data is not copied.
- inplace:
bool, optional: If True (the default) then do the operation in-place and return
None. If False a new, modifiedFieldinstance is returned.Added in version (cfdm): 1.8.7.0
- Returns:
Examples
>>> f = cfdm.Field() >>> f.set_data([1, 2, 3]) >>> f.has_data() True >>> f.get_data() <Data(3): [1, 2, 3]> >>> f.data <Data(3): [1, 2, 3]>
>>> f.del_data() <Data(3): [1, 2, 3]> >>> g = f.set_data([4, 5, 6], inplace=False) >>> g.data <Data(3): [4, 5, 6]> >>> f.has_data() False >>> print(f.get_data(None)) None >>> print(f.del_data(None)) None