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 variable name of
Data
object that the commands create.- namespace:
str
, optional The namespace containing classes of the
cf
package. This is prefixed to the class name in commands that instantiate instances ofcf
objects. By default, namespace is'cf'
, i.e. it is assumed thatcf
was imported asimport cf
.- Parameter example:
If
cf
was imported asimport cf as cfp
then setnamespace='cfp'
- Parameter example:
If
cf
was imported asfrom cf import *
then setnamespace=''
- string:
bool
, optional If False then return each command as an element of a
list
. By default the the commands are concatenated into a string, with a new line inserted between each command.
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)"]
- name: