cdms2.tvariable¶
-
createVariable
(*args, **kargs)[source]¶ Creates variable in-memory.
To enabled automatic bounds generation see
setAutoBounds
.- Parameters
- datanumpy.ndarray
NDArray containing variable data.
- typecode(float, int, np.dtype)
Sets the dtype of the underlying masked array.
- copyint
0: Stores reference of data. 1: Stores copy of data.
- savespaceint
Deprecated.
- masknumpy.ndarray
Mask passed to the underlying masked array.
- fill_valuefloat
Sets the value to use when data is missing.
- grid
Sets the grid of the variable.
- axeslist of (cdms2.TransientAxis, cdms2.FileAxis)
Sets the list of axes associated with the variable.
- attributesdict
Mapping of attribute names and values.
- idstr
Identifier for the variable.
- copyaxesint
0: Stores reference to axes. 1: Stores copies of axes.
- dtype(float, int, np.dtype)
Sets the dtype of the underlying masked array.
- orderstr
Sets the order for the underlying masked array (`Masked Array`_).
- no_update_frombool
If
False
andaxes
is None, then axes will be generated fromdata
. IfFalse
andgrid
is None, then an attempt to get a grid from thedata
will be made. Set toTrue
will prevent the above behavior.- *args
Url to JSON file if
fromJSON
is in kwargs.- **kargs
- fromJSONbool
Load variable from JSON.
- .. _Masked Array:
https://numpy.org/doc/stable/reference/generated/numpy.ma.array.html
Examples
>>> v1 = createVariable(np.random.random(size=(200,200)), typecode=float, fill_value=123)
>>> v2 = createVariable('data.json', fromJSON=True)