Saving velocity solution into .tiff file

Hello everyone. I’m working on a machine learning application that uses .tiff images of velocity data, and I need to train the model on more simulation data, so I would like to convert the fenics object into a .tiff image. I would like to know suggestions to approach this task. Currently I’m copying the solution vector data into Numpy arrays and then will try to convert it into a .tiff file next (currently working on it). Is there an already known method to do so?

@marcomusy might know if vedo is suitable for this task.

1 Like

Hi, yes - it should work like this e.g.:

import numpy as np

data_matrix = np.zeros([75, 75, 75], dtype=np.uint8)
data_matrix[0:35,   0:35,  0:35] = 1
data_matrix[35:55, 35:55, 35:55] = 2
data_matrix[55:74, 55:74, 55:74] = 3

from vedo import Volume, show
vol = Volume(data_matrix, c=['white','b','g','r'])
vol.addScalarBar3D()
vol.write('vol.tif')
show(vol, axes=1)

image

more examples here.

2 Likes