Update app.py
Browse files
app.py
CHANGED
@@ -5,6 +5,13 @@ import os
|
|
5 |
from dotenv import load_dotenv
|
6 |
import plotly.graph_objects as go
|
7 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
8 |
# Load environment variables from .env file
|
9 |
load_dotenv()
|
10 |
|
@@ -33,21 +40,13 @@ df = load_data()
|
|
33 |
def build_prompt(location, project_type, roof_size=None, desired_kwh=None, electricity_bill=None, ghi=None, solar_cost_per_kw=None):
|
34 |
if project_type == "Rooftop Solar":
|
35 |
prompt = f"""
|
36 |
-
You are a solar project estimator tool. Based on the following details, calculate and return only the values
|
37 |
Project Type: Rooftop Solar
|
38 |
Location: {location}
|
39 |
Roof size: {roof_size} sq meters
|
40 |
Monthly electricity bill: ₹{electricity_bill}
|
41 |
Average GHI: {ghi} kWh/m²/day
|
42 |
Solar system cost per kW: ₹{solar_cost_per_kw}
|
43 |
-
|
44 |
-
Formulas:
|
45 |
-
1. Estimated solar system size in kW = (Desired monthly production in kWh) / (GHI * Roof Area)
|
46 |
-
2. Estimated daily solar output in kWh = System size (kW) * GHI
|
47 |
-
3. Total system cost in ₹ = System size (kW) * Solar cost per kW (₹)
|
48 |
-
4. Monthly savings in ₹ = Monthly bill * (Solar output in kWh / Monthly consumption)
|
49 |
-
5. Payback period in years = Total system cost / (Monthly savings * 12)
|
50 |
-
|
51 |
Respond strictly in this format (do not add anything extra):
|
52 |
Estimated solar system size in kW: <value>
|
53 |
Estimated daily solar output in kWh: <value>
|
@@ -57,21 +56,13 @@ Payback period in years: <value>
|
|
57 |
"""
|
58 |
else: # Ground Mount Solar
|
59 |
prompt = f"""
|
60 |
-
You are a solar project estimator tool. Based on the following details, calculate and return only the values
|
61 |
Project Type: Ground Mount Solar
|
62 |
Location: {location}
|
63 |
Desired monthly solar production: {desired_kwh} kWh
|
64 |
Monthly electricity bill: ₹{electricity_bill}
|
65 |
Average GHI: {ghi} kWh/m²/day
|
66 |
Solar system cost per kW: ₹{solar_cost_per_kw}
|
67 |
-
|
68 |
-
Formulas:
|
69 |
-
1. Required solar system size in kW = Desired monthly production (kWh) / GHI
|
70 |
-
2. Estimated daily solar output in kWh = System size (kW) * GHI
|
71 |
-
3. Total system cost in ₹ = System size (kW) * Solar cost per kW (₹)
|
72 |
-
4. Monthly savings in ₹ = Monthly bill * (Solar output in kWh / Monthly consumption)
|
73 |
-
5. Payback period in years = Total system cost / (Monthly savings * 12)
|
74 |
-
|
75 |
Respond strictly in this format (do not add anything extra):
|
76 |
Required solar system size in kW: <value>
|
77 |
Estimated daily solar output in kWh: <value>
|
@@ -129,7 +120,7 @@ if submitted and location:
|
|
129 |
monthly_savings_rs = None
|
130 |
total_system_cost = None
|
131 |
payback_period_years = None
|
132 |
-
daily_output_kwh = None
|
133 |
|
134 |
for point in estimated_data:
|
135 |
if ":" in point:
|
@@ -156,11 +147,34 @@ if submitted and location:
|
|
156 |
if system_size_kw is not None and ghi is not None:
|
157 |
daily_output_kwh = system_size_kw * ghi # Estimate daily output in kWh
|
158 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
159 |
# Visual Summary - Grouped Bar Chart
|
160 |
if system_size_kw is not None and total_system_cost is not None:
|
161 |
st.subheader("📊 Visual Summary")
|
162 |
|
163 |
-
# Grouped Bar chart for all the values
|
164 |
fig = go.Figure(data=[
|
165 |
go.Bar(
|
166 |
name="System Size (kW)",
|
@@ -176,7 +190,6 @@ if submitted and location:
|
|
176 |
)
|
177 |
])
|
178 |
|
179 |
-
# Update layout
|
180 |
fig.update_layout(
|
181 |
barmode='group',
|
182 |
title="Comparison of Solar System Parameters",
|
|
|
5 |
from dotenv import load_dotenv
|
6 |
import plotly.graph_objects as go
|
7 |
|
8 |
+
import streamlit as st
|
9 |
+
import pandas as pd
|
10 |
+
import google.generativeai as genai
|
11 |
+
import os
|
12 |
+
from dotenv import load_dotenv
|
13 |
+
import plotly.graph_objects as go
|
14 |
+
|
15 |
# Load environment variables from .env file
|
16 |
load_dotenv()
|
17 |
|
|
|
40 |
def build_prompt(location, project_type, roof_size=None, desired_kwh=None, electricity_bill=None, ghi=None, solar_cost_per_kw=None):
|
41 |
if project_type == "Rooftop Solar":
|
42 |
prompt = f"""
|
43 |
+
You are a solar project estimator tool. Based on the following details, calculate and return only the values without any extra description:
|
44 |
Project Type: Rooftop Solar
|
45 |
Location: {location}
|
46 |
Roof size: {roof_size} sq meters
|
47 |
Monthly electricity bill: ₹{electricity_bill}
|
48 |
Average GHI: {ghi} kWh/m²/day
|
49 |
Solar system cost per kW: ₹{solar_cost_per_kw}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
50 |
Respond strictly in this format (do not add anything extra):
|
51 |
Estimated solar system size in kW: <value>
|
52 |
Estimated daily solar output in kWh: <value>
|
|
|
56 |
"""
|
57 |
else: # Ground Mount Solar
|
58 |
prompt = f"""
|
59 |
+
You are a solar project estimator tool. Based on the following details, calculate and return only the values without any extra description:
|
60 |
Project Type: Ground Mount Solar
|
61 |
Location: {location}
|
62 |
Desired monthly solar production: {desired_kwh} kWh
|
63 |
Monthly electricity bill: ₹{electricity_bill}
|
64 |
Average GHI: {ghi} kWh/m²/day
|
65 |
Solar system cost per kW: ₹{solar_cost_per_kw}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
66 |
Respond strictly in this format (do not add anything extra):
|
67 |
Required solar system size in kW: <value>
|
68 |
Estimated daily solar output in kWh: <value>
|
|
|
120 |
monthly_savings_rs = None
|
121 |
total_system_cost = None
|
122 |
payback_period_years = None
|
123 |
+
daily_output_kwh = None
|
124 |
|
125 |
for point in estimated_data:
|
126 |
if ":" in point:
|
|
|
147 |
if system_size_kw is not None and ghi is not None:
|
148 |
daily_output_kwh = system_size_kw * ghi # Estimate daily output in kWh
|
149 |
|
150 |
+
# Show the formulas
|
151 |
+
st.subheader("🧮 Formulas Used:")
|
152 |
+
|
153 |
+
if project_type == "Rooftop Solar":
|
154 |
+
st.markdown(f"""
|
155 |
+
**For Rooftop Solar:**
|
156 |
+
- Estimated Solar System Size (kW) = Roof Size (m²) × 0.15
|
157 |
+
- Estimated Daily Solar Output (kWh) = System Size (kW) × Average GHI (kWh/m²/day)
|
158 |
+
- Total System Cost (₹) = System Size (kW) × Solar Cost per kW (₹)
|
159 |
+
- Monthly Savings (₹) = (Estimated Daily Output × 30 × Tariff Rate per kWh) [Approximate]
|
160 |
+
- Payback Period (years) = Total System Cost ÷ (Monthly Savings × 12)
|
161 |
+
""")
|
162 |
+
else:
|
163 |
+
st.markdown(f"""
|
164 |
+
**For Ground Mount Solar:**
|
165 |
+
- Required Solar System Size (kW) = Desired Monthly Solar Production ÷ (30 × Average GHI)
|
166 |
+
- Estimated Daily Solar Output (kWh) = System Size (kW) × Average GHI (kWh/m²/day)
|
167 |
+
- Total System Cost (₹) = System Size (kW) × Solar Cost per kW (₹)
|
168 |
+
- Monthly Savings (₹) = (Estimated Daily Output × 30 × Tariff Rate per kWh) [Approximate]
|
169 |
+
- Payback Period (years) = Total System Cost ÷ (Monthly Savings × 12)
|
170 |
+
""")
|
171 |
+
|
172 |
+
st.info("Note: Tariff rate is assumed based on your state electricity average or ₹7/kWh (default).")
|
173 |
+
|
174 |
# Visual Summary - Grouped Bar Chart
|
175 |
if system_size_kw is not None and total_system_cost is not None:
|
176 |
st.subheader("📊 Visual Summary")
|
177 |
|
|
|
178 |
fig = go.Figure(data=[
|
179 |
go.Bar(
|
180 |
name="System Size (kW)",
|
|
|
190 |
)
|
191 |
])
|
192 |
|
|
|
193 |
fig.update_layout(
|
194 |
barmode='group',
|
195 |
title="Comparison of Solar System Parameters",
|