spacepy.datamodel.fromRecArray

spacepy.datamodel.fromRecArray(recarr)[source]

Takes a numpy recarray and returns each field as a dmarray in a SpaceData container

Parameters
recarrnumpy record array

object to parse into SpaceData container

Returns
sd: spacepy.datamodel.SpaceData

dict-like containing arrays of named records in recarr

Examples

>>> import numpy as np
>>> import spacepy.datamodel as dm
>>> x = np.array([(1.0, 2), (3.0, 4)], dtype=[('x', float), ('y', int)])
>>> print(x, x.dtype)
array([(1.0, 2), (3.0, 4)], dtype=[('x', '<f8'), ('y', '<i4')])
>>> sd = dm.fromRecArray(x)
>>> sd.tree(verbose=1)
+
|____x (spacepy.datamodel.dmarray (2,))
|____y (spacepy.datamodel.dmarray (2,))