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.

Changed in version 0.7.0: Operations on a dmarray which return a scalar value return a numpy array scalar. Previously they would return the base Python type. Assignment to dtype and shape are also now supported; previously this raised TypeError.

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.

__init__(*args, **kwargs)

Methods

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']

append(one, other)

append data to an existing dmarray

concatenate(one, other[, axis])

concatenate data to an existing dmarray

count(srchval)

Equivalent to count method on list

dstack(one, other)

dstack data to an existing dmarray

hstack(one, other)

hstack data to an existing dmarray

vstack(one, other)

vstack data to an existing dmarray

Attributes

addAttribute(name, value=None)[source]

Method to add an attribute to a dmarray equivalent to a = datamodel.dmarray([1,2,3]) a.Allowed_Attributes = a.Allowed_Attributes + [‘blabla’]

classmethod append(one, other)[source]

append data to an existing dmarray

classmethod concatenate(one, other, axis=0)[source]

concatenate data to an existing dmarray

count(srchval)[source]

Equivalent to count method on list

classmethod dstack(one, other)[source]

dstack data to an existing dmarray

classmethod hstack(one, other)[source]

hstack data to an existing dmarray

classmethod vstack(one, other)[source]

vstack data to an existing dmarray

Allowed_Attributes = ['attrs']
attrs: Mapping