FDM: salva risultati in results/fdm/<timestamp>/ invece di animations/fdm/
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
+7
-14
@@ -1,5 +1,6 @@
|
||||
import sys
|
||||
import os
|
||||
from datetime import datetime
|
||||
import numpy as np
|
||||
import plotly.graph_objects as go
|
||||
|
||||
@@ -7,16 +8,6 @@ sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
||||
import config
|
||||
|
||||
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||
FDM_ANIM_DIR = os.path.join(BASE_DIR, 'animations', 'fdm')
|
||||
|
||||
|
||||
def _next_path(base_dir, prefix, ext):
|
||||
i = 1
|
||||
while True:
|
||||
path = os.path.join(base_dir, f'{prefix}_{i:03d}{ext}')
|
||||
if not os.path.exists(path):
|
||||
return path
|
||||
i += 1
|
||||
|
||||
|
||||
def visualize_fdm(T_matrix, x_vals, t_vals):
|
||||
@@ -31,7 +22,9 @@ def visualize_fdm(T_matrix, x_vals, t_vals):
|
||||
t_vals : np.ndarray, shape (NT,)
|
||||
Time values.
|
||||
"""
|
||||
os.makedirs(FDM_ANIM_DIR, exist_ok=True)
|
||||
timestamp = datetime.now().strftime('%Y%m%d_%H%M%S')
|
||||
out_dir = os.path.join(BASE_DIR, 'results', 'fdm', timestamp)
|
||||
os.makedirs(out_dir, exist_ok=True)
|
||||
|
||||
# ------------------------------------------------------------------
|
||||
# 1. Heatmap
|
||||
@@ -66,7 +59,7 @@ def visualize_fdm(T_matrix, x_vals, t_vals):
|
||||
height=500,
|
||||
)
|
||||
|
||||
heatmap_path = _next_path(FDM_ANIM_DIR, 'heatmap', '.html')
|
||||
heatmap_path = os.path.join(out_dir, 'heatmap.html')
|
||||
fig_heatmap.write_html(heatmap_path)
|
||||
print(f"Heatmap saved → {heatmap_path}")
|
||||
|
||||
@@ -168,7 +161,7 @@ def visualize_fdm(T_matrix, x_vals, t_vals):
|
||||
frames=frames,
|
||||
)
|
||||
|
||||
anim_path = _next_path(FDM_ANIM_DIR, 'animation', '.html')
|
||||
anim_path = os.path.join(out_dir, 'animation.html')
|
||||
fig_anim.write_html(anim_path)
|
||||
print(f"Animation saved → {anim_path}")
|
||||
|
||||
@@ -222,6 +215,6 @@ def visualize_fdm(T_matrix, x_vals, t_vals):
|
||||
height=480,
|
||||
)
|
||||
|
||||
ts_path = _next_path(FDM_ANIM_DIR, 'time_series', '.html')
|
||||
ts_path = os.path.join(out_dir, 'time_series.html')
|
||||
fig_ts.write_html(ts_path)
|
||||
print(f"Time-series saved → {ts_path}")
|
||||
|
||||
Reference in New Issue
Block a user