-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
64 lines (52 loc) · 2.53 KB
/
Copy pathmain.py
File metadata and controls
64 lines (52 loc) · 2.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import sys
import os
# --- PATH FIX ---
current_dir = os.path.dirname(os.path.abspath(__file__))
sys.path.append(current_dir)
# ----------------
from src.data_loader import load_data
from src.spatial_analysis import run_clustering, plot_clusters
from src.econometrics import run_regression, save_summary
# Import all visualization functions
from src.visuals import (
plot_top_counties, plot_scenario_comparison, plot_correlation,
plot_ercot_zones, plot_population_vs_risk, plot_water_share_dist,
plot_count_vs_load, plot_efficiency_savings
)
def main():
print("--- STARTING RESEARCH COMPENDIUM GENERATION ---")
# 1. Setup Directories
fig_dir = os.path.join(current_dir, 'output', 'figures')
tab_dir = os.path.join(current_dir, 'output', 'tables')
os.makedirs(fig_dir, exist_ok=True)
os.makedirs(tab_dir, exist_ok=True)
# 2. Load Data
print("\n[1/4] Loading Data...")
csv_path = os.path.join(current_dir, 'data', 'texas_dc_refined_v2.csv')
df_full, df_baseline = load_data(csv_path)
# 3. Generate Descriptive Figures (1-8)
print("\n[2/4] Generating Figures 1-8...")
plot_top_counties(df_baseline, os.path.join(fig_dir, 'figure1_top_counties.png'))
plot_scenario_comparison(df_full, os.path.join(fig_dir, 'figure2_scenarios.png'))
plot_correlation(df_baseline, os.path.join(fig_dir, 'figure3_correlation.png'))
plot_ercot_zones(df_baseline, os.path.join(fig_dir, 'figure4_ercot_zones.png'))
plot_population_vs_risk(df_baseline, os.path.join(fig_dir, 'figure5_pop_risk.png'))
plot_water_share_dist(df_baseline, os.path.join(fig_dir, 'figure6_water_dist.png'))
plot_count_vs_load(df_baseline, os.path.join(fig_dir, 'figure7_count_load.png'))
plot_efficiency_savings(df_full, os.path.join(fig_dir, 'figure8_efficiency_savings.png'))
print(f" [+] Saved Figures 1-8 to {fig_dir}")
# 4. Spatial Analysis (Figure 9)
print("\n[3/4] Running Clustering Model (Figure 9)...")
df_clusters = run_clustering(df_baseline)
f9_path = os.path.join(fig_dir, 'figure9_risk_clusters.png')
plot_clusters(df_clusters, f9_path)
print(f" [+] Saved Figure 9 to {f9_path}")
# 5. Econometrics
print("\n[4/4] Running Econometric Analysis...")
model = run_regression(df_full)
save_summary(model, os.path.join(tab_dir, 'regression_results.txt'))
print("\n=======================================")
print(" COMPLETE. All 9 Figures Generated. ")
print("=======================================")
if __name__ == "__main__":
main()