cf.Data.creation_commands¶
-
Data.creation_commands(name='data', namespace='cf', indent=0, string=True)[source]¶ Return the commands that would create the data object.
New in version 3.0.4.
- Parameters
- name:
stror None, optional Set the variable name of
Dataobject that the commands create.- namespace:
str, optional The namespace containing classes of the
cfpackage. This is prefixed to the class name in commands that instantiate instances ofcfobjects. By default, namespace is'cf', i.e. it is assumed thatcfwas imported asimport cf.- Parameter example:
If
cfwas imported asimport cf as cfpthen setnamespace='cfp'- Parameter example:
If
cfwas imported asfrom cf import *then setnamespace=''
- indent:
int, optional Indent each line by this many spaces. By default no indentation is applied. Ignored if string is False.
- string:
bool, optional If False then return each command as an element of a
list. By default the commands are concatenated into a string, with a new line inserted between each command.
- name:
- Returns
Examples:
>>> d <CF Data(3, 2): [[0.0, ..., 135.0]]] 'degrees_east'> >>> print(d.array) [[ 0. 45.] [ 45. 90.] [ 90. 135.]] >>> print(d.creation_commands()) data = cf.Data([[0.0, 45.0], [45.0, 90.0], [90.0, 135.0]], units='degrees_east', dtype='f8')
>>> print(d.array) [-- 'beta' 'gamma' 'delta' 'epsilon'] >>> d.creation_commands(name='d', namespace='', string=False) ["d_mask = Data([True, False, False, False, False], dtype='b1')", "d = Data([b'', b'beta', b'gamma', b'delta', b'epsilon'], dtype='S7', mask=d_mask)"]