import k3d
import scipy.io as sio
import numpy as np
from k3d import matplotlib_color_maps
j_values = [47, 54, 71, 105, 130]
green_dot_positions = [39, 53, 93, 197, 298]
for j, gdot in zip(j_values, green_dot_positions):
filename = f'eddy_isosurf_stream_j_{j:03d}.mat'
temp1 = sio.loadmat(filename)
a = temp1['streamlineArray1']
n1, n2, n3 = a.shape
indices = temp1['indices1']
vertices = temp1['vertices1']
c = temp1['faceColor1']
plt_mesh = k3d.mesh(vertices, indices,
color_map=matplotlib_color_maps.PiYG_r,
attribute=c,
color_range=[-0.1, 0.1], side='double')
green_dot = k3d.points(positions=np.array([[0, 0, gdot]], dtype=np.float32),
point_size=5.0,
color=0x00FF00)
plot = k3d.plot(grid=(-600, -200, 0, 600, 200, 300),
axes=['z^+', 'x^+', 'y^+'])
plot.camera_auto_fit = True
plot += plt_mesh
plot += green_dot
for i in range(n3):
x = a[:, 0, i]
y = a[:, 1, i]
z = a[:, 2, i]
if len(x) == len(y) == len(z):
streamline = np.column_stack((x, y, z))
plot += k3d.line(streamline, width=2.0, color=0x000000)
else:
print(f"Skipping streamline {i} in j={j} due to inconsistent dimensions: x={len(x)}, y={len(y)}, z={len(z)}")
output_filename = f'eddy_streamline_outflow_yplus_{gdot:03d}.html'
with open(output_filename, 'w') as fp:
fp.write(plot.get_snapshot())
print(f"Saved plot for j={j} with green dot at {gdot} to {output_filename}")