
import pandas as pd
import pyvista as pv

df = pd.read_csv("../data/spatial_grid.csv")

t0 = 2
df = df[df["time"] == t0].copy()

n = 35

grid = pv.ImageData(
    dimensions=(n, n, n),
    spacing=(10 / (n - 1), 10 / (n - 1), 10 / (n - 1)),
    origin=(-5, -5, -5)
)

grid.point_data["temperature"] = (
    df["temperature"].to_numpy()
    .reshape((n, n, n))
    .ravel(order="F")
)

surfaces = grid.contour(
    isosurfaces=[30, 50, 80],
    scalars="temperature"
)

plotter = pv.Plotter()

plotter.add_mesh(
    surfaces,
    scalars="temperature",
    preference="point",
    cmap="turbo",
    # clim=[47, 70],
    opacity=0.5,
    smooth_shading=True,
    ambient=0.35,
    diffuse=0.8,
    specular=0.1,
    show_scalar_bar=True
)
print(df["temperature"].min(), df["temperature"].max())
plotter.add_axes()
plotter.show_grid()
plotter.show()
