submarine_forecast / test_fix.py
kawaiipeace's picture
NEW: Major change and analyze the data to forecast and summary
6d2f083
Raw
History Blame Contribute Delete
2.15 kB
import pandas as pd
import numpy as np
from utils.excel_loader import load_submarine_forecast_data
from utils.preprocessing import preprocess_load_data, preprocess_temperature_data, preprocess_measurement_data
from utils.merge_data import aggregate_daily_max, merge_load_temp, merge_with_measurements, calculate_capacity_analysis
print("=" * 80)
print("🧪 TEST: Fixed Data Pipeline")
print("=" * 80)
# Load
print("\n1️⃣ Loading data...")
data = load_submarine_forecast_data('dataset/submarine_forecast.xlsx')
# Preprocess
print("\n2️⃣ Preprocessing...")
df_load = preprocess_load_data(data['load'])
df_temp = preprocess_temperature_data(data['temp'])
print(f"✅ Load preprocessed: {df_load.shape}, mw range: {df_load['mw'].min():.2f}-{df_load['mw'].max():.2f}")
print(f"✅ Temp preprocessed: {df_temp.shape}, MaxTemp range: {df_temp['MaxTemp'].min():.2f}-{df_temp['MaxTemp'].max():.2f}")
# Aggregate & Merge
print("\n3️⃣ Aggregating & merging...")
df_daily = aggregate_daily_max(df_load)
df_merged = merge_load_temp(df_daily, df_temp)
print(f"✅ Merged: {df_merged.shape}, mw_max range: {df_merged['mw_max'].min():.2f}-{df_merged['mw_max'].max():.2f}")
# Merge with measurements (FIXED)
print("\n4️⃣ Merging with TEPR/STRR (NOW FIXED)...")
df_merged_full = merge_with_measurements(df_merged, data['tepr'], data['strr'])
print(f"✅ After measurement merge: {df_merged_full.shape}")
print(f" mw_max range: {df_merged_full['mw_max'].min():.2f}-{df_merged_full['mw_max'].max():.2f} MW ✅")
print(f" tepr_mean: {df_merged_full['tepr_mean'].iloc[0]:.2f}")
print(f" strr_mean: {df_merged_full['strr_mean'].iloc[0]:.2f}")
# Capacity Analysis
print("\n5️⃣ Capacity Analysis...")
df_analysis = calculate_capacity_analysis(df_merged_full)
print(f"✅ Analysis complete: {df_analysis.shape}")
print(f" Load % of 80%: {df_analysis['load_pct_of_80'].mean():.2f}%")
print(f" Available Margin: {df_analysis['mw_available_margin'].mean():.2f} MW")
print(f" Thermal Margin: {df_analysis['temp_margin_available'].mean():.2f}°C")
print("\n" + "=" * 80)
print("✅ TEST PASSED - Data pipeline is now FIXED!")
print("=" * 80)