Update app.py
Browse files
app.py
CHANGED
@@ -4,6 +4,11 @@ import google.generativeai as genai
|
|
4 |
import os
|
5 |
from dotenv import load_dotenv
|
6 |
|
|
|
|
|
|
|
|
|
|
|
7 |
# Load environment variables
|
8 |
load_dotenv()
|
9 |
|
@@ -23,14 +28,13 @@ TARIFF_RATE = 7 # ₹7 per kWh
|
|
23 |
ROOFTOP_CONVERSION_FACTOR = 0.10 # 0.10 kW per sq meter
|
24 |
|
25 |
# UI - Form
|
26 |
-
st.title("☀️AI-Based Solar Project Estimation Tool")
|
27 |
st.write("### Enter Your Details Below:")
|
28 |
|
29 |
with st.form("solar_form"):
|
30 |
state_options = df['State'].dropna().unique()
|
31 |
location = st.selectbox("Select your State", options=sorted(state_options))
|
32 |
|
33 |
-
# Fixed line: showing only bolded "Rooftop Solar" heading
|
34 |
st.markdown("### **Rooftop Solar**")
|
35 |
|
36 |
roof_size = st.number_input("Enter your roof size (in sq meters)", min_value=1)
|
@@ -38,7 +42,7 @@ with st.form("solar_form"):
|
|
38 |
|
39 |
submitted = st.form_submit_button("Get Estimate")
|
40 |
|
41 |
-
# Calculate
|
42 |
if submitted and location:
|
43 |
state_data = df[df['State'].str.contains(location, case=False)].iloc[0]
|
44 |
|
@@ -46,25 +50,37 @@ if submitted and location:
|
|
46 |
ghi = state_data['Avg_GHI (kWh/m²/day)']
|
47 |
solar_cost_per_kw = state_data['Solar_Cost_per_kW (₹)']
|
48 |
|
|
|
49 |
system_size_kw = round(roof_size * ROOFTOP_CONVERSION_FACTOR, 2)
|
50 |
estimated_daily_output = round(system_size_kw * ghi, 2)
|
51 |
|
52 |
total_system_cost = round(system_size_kw * solar_cost_per_kw, 2)
|
53 |
-
|
|
|
54 |
payback_period = round(total_system_cost / (monthly_savings * 12), 2)
|
55 |
|
|
|
|
|
|
|
|
|
|
|
|
|
56 |
# Display Results
|
57 |
st.subheader("🔹 Solar Project Estimate")
|
58 |
-
st.write(f"**Estimated solar system size
|
59 |
-
st.write(f"**Estimated daily solar output
|
60 |
-
st.write(f"**
|
61 |
-
st.write(f"**
|
62 |
-
st.write(f"**
|
|
|
|
|
|
|
|
|
|
|
63 |
|
64 |
-
|
65 |
st.info("Note: Tariff assumed ₹7/kWh. Actual payback may vary based on location, grid policy, and maintenance.")
|
66 |
|
67 |
else:
|
68 |
st.error("State data not found. Please try a valid state.")
|
69 |
else:
|
70 |
-
st.warning("Please complete all fields to get your estimate.")
|
|
|
4 |
import os
|
5 |
from dotenv import load_dotenv
|
6 |
|
7 |
+
import streamlit as st
|
8 |
+
import pandas as pd
|
9 |
+
import os
|
10 |
+
from dotenv import load_dotenv
|
11 |
+
|
12 |
# Load environment variables
|
13 |
load_dotenv()
|
14 |
|
|
|
28 |
ROOFTOP_CONVERSION_FACTOR = 0.10 # 0.10 kW per sq meter
|
29 |
|
30 |
# UI - Form
|
31 |
+
st.title("☀️ AI-Based Solar Project Estimation Tool")
|
32 |
st.write("### Enter Your Details Below:")
|
33 |
|
34 |
with st.form("solar_form"):
|
35 |
state_options = df['State'].dropna().unique()
|
36 |
location = st.selectbox("Select your State", options=sorted(state_options))
|
37 |
|
|
|
38 |
st.markdown("### **Rooftop Solar**")
|
39 |
|
40 |
roof_size = st.number_input("Enter your roof size (in sq meters)", min_value=1)
|
|
|
42 |
|
43 |
submitted = st.form_submit_button("Get Estimate")
|
44 |
|
45 |
+
# Calculate estimates
|
46 |
if submitted and location:
|
47 |
state_data = df[df['State'].str.contains(location, case=False)].iloc[0]
|
48 |
|
|
|
50 |
ghi = state_data['Avg_GHI (kWh/m²/day)']
|
51 |
solar_cost_per_kw = state_data['Solar_Cost_per_kW (₹)']
|
52 |
|
53 |
+
# Calculations
|
54 |
system_size_kw = round(roof_size * ROOFTOP_CONVERSION_FACTOR, 2)
|
55 |
estimated_daily_output = round(system_size_kw * ghi, 2)
|
56 |
|
57 |
total_system_cost = round(system_size_kw * solar_cost_per_kw, 2)
|
58 |
+
monthly_solar_generation = round(estimated_daily_output * 30, 2)
|
59 |
+
monthly_savings = round(monthly_solar_generation * TARIFF_RATE, 2)
|
60 |
payback_period = round(total_system_cost / (monthly_savings * 12), 2)
|
61 |
|
62 |
+
# Calculate Bill Offset
|
63 |
+
if electricity_bill > 0:
|
64 |
+
bill_offset_percentage = round((monthly_savings / electricity_bill) * 100, 2)
|
65 |
+
else:
|
66 |
+
bill_offset_percentage = None
|
67 |
+
|
68 |
# Display Results
|
69 |
st.subheader("🔹 Solar Project Estimate")
|
70 |
+
st.write(f"**Estimated solar system size (kW)**: {system_size_kw}")
|
71 |
+
st.write(f"**Estimated daily solar output (kWh/day)**: {estimated_daily_output}")
|
72 |
+
st.write(f"**Estimated monthly solar generation (kWh/month)**: {monthly_solar_generation}")
|
73 |
+
st.write(f"**Total system cost (₹)**: {total_system_cost}")
|
74 |
+
st.write(f"**Monthly savings from solar (₹)**: {monthly_savings}")
|
75 |
+
st.write(f"**Payback period (years)**: {payback_period}")
|
76 |
+
|
77 |
+
# Display Bill Offset if entered
|
78 |
+
if bill_offset_percentage is not None:
|
79 |
+
st.write(f"**Solar will offset approximately {bill_offset_percentage}% of your monthly electricity bill.**")
|
80 |
|
|
|
81 |
st.info("Note: Tariff assumed ₹7/kWh. Actual payback may vary based on location, grid policy, and maintenance.")
|
82 |
|
83 |
else:
|
84 |
st.error("State data not found. Please try a valid state.")
|
85 |
else:
|
86 |
+
st.warning("Please complete all fields to get your estimate.")
|