spacepy.datamodel.dmarray¶
- class spacepy.datamodel.dmarray(input_array, attrs=None, dtype=None)[source]¶
Container for data within a SpaceData object
Although the format of attributes is not enforced, using ISTP metadata enables the use of methods from
ISTPArray
.- Raises:
- NameError
raised is the request name was not added to the allowed attributes list
Examples
>>> import spacepy.datamodel as datamodel >>> position = datamodel.dmarray([1,2,3], attrs={'coord_system':'GSM'}) >>> position dmarray([1, 2, 3]) >>> position.attrs {'coord_system': 'GSM'}a
The dmarray, like a numpy ndarray, is versatile and can store any datatype; dmarrays are not just for arrays.
>>> name = datamodel.dmarray('TestName') dmarray('TestName')
To extract the string (or scalar quantity), use the tolist method
>>> name.tolist() 'TestName'
See methods of
ISTPArray
if attributes are ISTP-compliant.addAttribute
(name[, value])Method to add an attribute to a dmarray equivalent to a = datamodel.dmarray([1,2,3]) a.Allowed_Attributes = a.Allowed_Attributes + ['blabla']