I have an array which contains point clouds (about 100 ladar points). I need to create a set of numpy arrays as quickly as possible.
sweep = np.empty(
shape=(len(sweep.points),),
dtype=[
('point', np.float64, 3),
('intensity', np.float32),
## ..... more fields ....
]
)
for index, point in enumerate(sweep.points):
sweep[index]['point'] = (point.x, point.y, point.z)
sweep[index]['intensity'] = point.intensity
## ....more fields...
Writing an explicit loop is very inefficient and slow. Is there a better way to go about this?
sweepis a list ofpointsobjects, where eachpointhas attributes that you want to place fields of the array, right? Wait this won't work. After defining theemptyarray,sweepis now an array, not the list of objects!