I have a process that requires extracting data from a numpy recarray to a ndarray where I then do some vector math. (The recarray comes from a pytables table.read() function.) I want to map the math output (another ndarray) back to the same fields/columns in the original recarray. I found a way to do it column by column. Looking for a better way to go back and forth with the data. my code:
node_eigen_array = eigenvb_table.read_coordinates(node_rows)
node_eigen_array.shape[0]
10
node_eigen_array.dtype
dtype([('ID', '<i8'), ('X', '<f8'), ('Y', '<f8'), ('Z', '<f8'), ('FREQ', '<i8')])
resvec_array[:,0]=node_eigen_array['X']
resvec_array[:,1]=node_eigen_array['Y']
resvec_array[:,2]=node_eigen_array['Z']
# do some stuff that returns ndarray c_dot...
node_eigen_array['X']=cdot[:,0]
node_eigen_array['Y']=cdot[:,1]
node_eigen_array['Z']=cdot[:,2]
I tried this to skip the first recarray to ndarray:
resvec_array=node_eigen_array[['X','Y','Z']].view('float64').reshape((10,3))
numpy complains:
This code may break in numpy 1.13 because this will return a view instead of a copy -- see release notes for details.
Also, looking for something that simplifies ndarray data back to recarray. Thanks.