@lassoan, thanks for prompt answer!
First I don’t know if my limited Python may lead to some result on the xarray integration in a reasonable time. If others would like to contribute, we can think about it!
Then, I try to explain my goals…
I’m developing a Python 3D geological modelling application, heavily based on VTK, that allows visualising, editing, digitising, interpolating, etc. different types of object, mainly polyline, point-cloud, and triangulated surface polydata, but also unstructured and regular grids are used (e.g. for digital elevation models), and images (geophysical data), tetrahedral meshes (for output and as a support for interpolation), etc.
All these objects are collected in a vtkCollection. This, as far as I understand, leads to better performances than storing them in a simple Python list. BTW, is this correct?
All the objects in the collection should have metadata, such as a unique_id (used trace the object even if the collection is changed), name, type, and other properties related to the geological and/or topological meaning of each object. For each kind of object I use a class derived form the relevant VTK class (e.g. PolyData for triangulated surfaces).
To maximise re-using VTK functions, all the objects in the collection are saved to and read from disk as standard VTK files. This is one reason to store the metadata as FieldData, so that they will be read/saved automatically.
Then, some method to search the collection for particular metadata, select objects according to metadata values, etc., would be very useful. At the moment I am doing this with Pandas dataframes where I store all metadata and a string pointing to each vtk object, so I see that using xarray might be logical.
Quite obviously, being able to access the underlying VTK arrays a Numpy arrays is fundamental in my application, e.g. to facilitate using interpolation or geostatistics libraries etc.
So… do you still think that xarray would be a reasonable answer?
The other option would be to simply use VTK FieldData to store the metadata. This is their original goal, if I understand what you write here. However the documentation on FieldData is very limited and I do not know if I will able to re-implement the basic methods in my classes (e.g. add a field, remove a field, set and get values in the fields, either strings or numerical, etc.). Any help or Python example on this would be very useful!