Kitware / pan3d

Other
11 stars 3 forks source link

Feature Request: Multicomponent dataset support #97

Closed johnkit closed 1 week ago

johnkit commented 3 months ago

This feature request applies to both pyvista-xarray and pan3d.

Our current software for vtk-numpy interoperability maps one Xarray DataArray -- comprising one variable in an Xarray DataSet (plus coordinates) -- to a corresponding vtkDataSet. It would be useful to also be able to map multiple variables from an Xarray DataSet to a single vtkDataSet with multiple data components.

For example, issue #95 includes a screenshot with the magnitude of velocity computed from 3 component variables. This was done by adding a new variable at the Xarray dataset level using NumPy:

ds['mag'] = np.sqrt(ds['u']**2 + ds['v']**2 + ds['z']**2)

It would be preferable to add a function that maps an Xarray dataset plus list of variable names to a single vtkDataset, and then have a display option to compute the magnitude on demand by vtk.

johnkit commented 3 months ago

A strawman approach for this is to implement a DataArraySet class to encapsulate multiple Xarray.DataArray objects and maintain matching coordinates. It would implement many (most?) of the DataArray methods by applying them to each encapsulated array.

jourdain commented 1 week ago

Supported in 0.10.1 see https://github.com/Kitware/pan3d/blob/main/examples/jupyter/computed_field.ipynb for details