I have a variable named mesh of type object extracted from a MATLAB .mat file. (EDIT: Reproducible example below)
In [1]: mesh
Out[1]:
array([[ array([[ (array([[ 89, 108]], dtype=uint8),
array([[-131.659809],
[-131.659809],
[-131.659809],
...,
[ 52.022239],
[ 52.022239],
[ 52.022239]]),
array([[ 189.358345],
[ 187.271049],
[ 185.183753],
...,
[ -29.807736],
[ -31.895032],
[ -33.982328]]))]],
dtype=[('dim', 'O'), ('x', 'O'), ('y', 'O')])]], dtype=object)
How can I access the individual arrays dim, x and y?
Reproducible example:
I am unable to assign dtype=uint8 to an array as in the imported object.
Also, the imported object has object size (1,1) while this example has object size (1,1,1,1).
import numpy as np
mesh = np.array([[ np.array([[ (np.array([[ 6, 6]], dtype=float),
np.array([[-131.659809],
[-131.659809],
[-131.659809],
[ 52.022239],
[ 52.022239],
[ 52.022239]]),
np.array([[ 189.358345],
[ 187.271049],
[ 185.183753],
[ -29.807736],
[ -31.895032],
[ -33.982328]]))]],
dtype=[('dim', 'O'), ('x', 'O'), ('y', 'O')])]], dtype=object)
mesh['dim']andmesh['x']... there seems to be a needless wrapping of anobjecttype array, i.e., and array of other arrays. so to really dig down, you need to index into that, so for examplemesh['dim'][0]should return your actual array of dimensions, e.g.array([[7, 6]])scipy.io.loadmat.dataSRChaving following content:dataSRC.mesh1x1 struct;dataSRC.field1x1 struct;dataSRC.pod1x1 struct. ` The structuremeshhas following content:dataSRC.mesh.dim[89,108];dataSRC.mesh.x9612x1 double;dataSRC.mesh.y9612x1 double