Open davidcortesortuno opened 3 years ago
You can try:
mesh["my_vector_name"] = np.column_stack((mesh.get_array('Mx'),
mesh.get_array('My'),
mesh.get_array('Mz'))
mesh.set_active_vectors("my_vector_name") # not strictly neccessary, but it will replicate the mesh.vectors usage.
See here:
Thanks, I just realised I can also do
mesh.point_arrays.update(dict(M_vec=np.column_stack((mesh.get_array('Mx'),
mesh.get_array('My'),
mesh.get_array('Mz')))))
Your method is basically the same as mine above, when doing mesh["M_vec"] = vector_data
, but your usage will only work for point_data, whereas this usage will work for both point and cell data.
To summarize, you can add data with:
mesh.point_arrays.update(dict(name=point_data))
mesh.cell_arrays.update(dict(name=cell_data))
mesh["name"] = point_data
mesh["name"] = cell_data
mesh.vectors = point_data
mesh.vectors = cell_data
I tend to use the mesh["name"] = data
method as it is the most flexible. I find the mesh.vectors
usage to be confusing. There should be a limited number of ways to add data.
I was incorrect, mesh.vectors = cell_data
will not work since it adds to mesh.point_arrays
. This is a bug, although I'd prefer this whole functionality to be removed.
Description
Hi, I'm loading data from a
tecplot
file which is read successfully. This data is shown asIs there a way to add a new Data Array as Point data? I tried using
add_field
but this creates a
Fields
and not aPoints
field:I finally tried
which produces what I was expecting,
However I cannot set a name to the data with this method. Is this the way to do it or is there a better function/method to do this?