Files
pinn/inverse/data.py
T

26 lines
1.0 KiB
Python

import os
import sys
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
import pandas as pd
import torch
from inverse.config_inverse import MEASUREMENTS_PATH
def load_measurements(device: torch.device):
"""Carica measurements.csv e restituisce tensori (x_s, t_s, T_meas) sul device."""
if not os.path.exists(MEASUREMENTS_PATH):
raise FileNotFoundError(
f"File misure non trovato: {MEASUREMENTS_PATH}\n"
"Esegui prima 'python inverse/sample_sensors.py' per generare i dati."
)
df = pd.read_csv(MEASUREMENTS_PATH)
x_s = torch.tensor(df["x"].values, dtype=torch.float32, device=device)
t_s = torch.tensor(df["t"].values, dtype=torch.float32, device=device)
T_meas = torch.tensor(df["T"].values, dtype=torch.float32, device=device)
print(f"Misure caricate: {len(df)} punti da {MEASUREMENTS_PATH}")
print(f" Sensori x: {sorted(df['x'].unique().tolist())}")
print(f" T range: [{df['T'].min():.2f}, {df['T'].max():.2f}] °C")
return x_s, t_s, T_meas