-
Notifications
You must be signed in to change notification settings - Fork 0
/
mayavi.py
49 lines (40 loc) · 1.15 KB
/
mayavi.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
'''
Author: CSuperlei
Date: 2024-02-15 16:37:13
LastEditTime: 2024-02-15 17:00:37
Description:
'''
import numpy as np
import random
import os
import time
from mayavi import mlab
from scipy.spatial import Delaunay
from tvtk.api import tvtk
from io import StringIO
def point_cloud(HIFT_res):
'''
show the ocean rendered point cloud of the data
x, y, z: the coordinate of the point cloud of HIFT
'''
for idx, data in enumerate(HIFT_res):
mlab.clf()
x = data[:, 0]
y = data[:, 1]
z = data[:, 2]
mlab.points3d(x, y, z, color=(0.47, 0.62, 0.74), mode='sphere', colormap='jet', scale_factor=0.7)
mlab.show()
def surface_cloud(HIFT_res):
'''
show the ocean rendered surface of the data
x, y, z: the coordinate of the point cloud of HIFT
'''
for idx, data in enumerate(HIFT_res):
mlab.clf()
tri = Delaunay(data[:, :2])
triangles = tri.simplices
x = data[:, 0]
y = data[:, 1]
z = data[:, 2]
colors = z
mlab.triangular_mesh(x, y, z, triangles, scalars=colors, colormap='Blues')