def plot_err_field_vedo(X, Y, Z, scalar_field, fig_name):
    isomin = 1. * scalar_field.min()
    isomax = 1. * scalar_field.max()
    # isomin = 10
    # isomax = 11

    vol = Volume(scalar_field)
    # vol.addScalarBar3D()
    vol.addScalarBar3D(sy=1.5, title='height is the scalar')

    # generate an isosurface the volume for each thresholds
    ts = np.linspace(isomin, isomax, 6)
    # ts = [10.1, 10.25, 10.4]
    # Use c=None to use the default vtk color map. isos is of type Mesh
    isos = Volume(scalar_field).isosurface(threshold=ts).opacity(0.4)
    text1 = Text2D(f'Make a Volume from numpy.mgrid', c='blue')
    text2 = Text2D(f'its isosurface representation\nvmin={isomin:.2e}, vmax={isomax:.2e}', c='dr')

    print('numpy array from Volume:',
          vol.getPointArray().shape,
          vol.getDataArray().shape)

    # show([(vol, text1), (isos, text2)], N=2, azimuth=10, zoom=1.3)
    destination_path = os.path.join(plot_dir, fig_name)
    write(vol, destination_path)
    print(f'zapisano w: {destination_path}')
Exemple #2
0
print('unpack',len(asse.unpack()) , 2)
assert len(asse.unpack()) ==2
print('unpack', asse.unpack(0).name)
assert asse.unpack(0) == cone
print('unpack',asse.unpack(1).name)
assert asse.unpack(1) == sphere
print('unpack',asse.diagonalSize(), 4.15)
assert 4.1 < asse.diagonalSize() < 4.2


############################################################################ Volume
X, Y, Z = np.mgrid[:30, :30, :30]
scalar_field = ((X-15)**2 + (Y-15)**2 + (Z-15)**2)/225
print('Test Volume, scalar min, max =', np.min(scalar_field), np.max(scalar_field))

vol = Volume(scalar_field)
volarr = vol.getPointArray()

print('Volume',volarr.shape[0] , 27000)
assert volarr.shape[0] == 27000
print('Volume',np.max(volarr) , 3)
assert np.max(volarr) == 3
print('Volume',np.min(volarr) , 0)
assert np.min(volarr) == 0

###################################### isosurface
iso = vol.isosurface(threshold=1.0)
print('isosurface', iso.area())
assert 2540 < iso.area() <  3000