cf.Data.creation_commands

Data.creation_commands(name='data', namespace='cf', string=True)[source]

Return the commands that would create the data object.

Parameters:
name: str, optional

Set the name of Data object that the commands create.

namespace: str, optional

The namespace containing the cf package classes. By default it is assumed that cf was imported as import cf.

Parameter example:

If cf was imported as import cf as cfp then set namespace='cfp'

Parameter example:

If cf was imported as from cf import * then set namespace=''

string: bool, optional

Return each command an element of a list. By default the the commands are concatenated into a string.

Returns:
str or list

The commands in a string, with a new line inserted between each command. If string is False then the commands are returned in a list.

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', package='', string=0)
["d = Data(['', 'beta', 'gamma', 'delta', 'epsilon'], dtype='S7')",
 "d_mask = Data([True, False, False, False, False], dtype='b1')",
 'd.where(d_mask, masked, inplace=True)']