MLDeveloper commited on
Commit
70d18af
·
verified ·
1 Parent(s): 233f1db

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +29 -37
app.py CHANGED
@@ -10,7 +10,7 @@ import plotly.graph_objects as go
10
  load_dotenv()
11
 
12
  # Set page configuration
13
- st.set_page_config(page_title="☀️AI-based Solar Project Estimation Tool", layout="centered")
14
 
15
  # Initialize Gemini with the API key
16
  api_key = os.getenv("GOOGLE_API_KEY")
@@ -67,7 +67,7 @@ Payback period in years: <value>
67
  return prompt
68
 
69
  # UI - Form for user input
70
- st.title("☀️ AI-based Solar Project Estimation Tool")
71
  st.write("### Enter Your Details Below:")
72
 
73
  with st.form("solar_form"):
@@ -137,45 +137,37 @@ if submitted and location:
137
  st.warning("There was an issue processing the response. Please try again.")
138
 
139
  # Show Graph if values are available
140
- if total_system_cost is not None and monthly_savings_rs is not None and payback_period_years is not None:
 
141
  st.subheader("📊 Visual Summary")
142
-
143
- # Prepare data for Area Chart
144
- months = int(payback_period_years * 12)
145
- savings_cumulative = [monthly_savings_rs * month for month in range(1, months + 1)]
146
-
147
- fig = go.Figure()
148
-
149
- # Area plot
150
- fig.add_trace(go.Scatter(
151
- x=list(range(1, months + 1)),
152
- y=savings_cumulative,
153
- mode='lines',
154
- fill='tozeroy',
155
- name='Cumulative Savings (₹)',
156
- line=dict(color='#00CC96')
157
- ))
158
-
159
- # Line for Total Cost
160
- fig.add_trace(go.Scatter(
161
- x=[1, months],
162
- y=[total_system_cost, total_system_cost],
163
- mode='lines',
164
- name='Total System Cost (₹)',
165
- line=dict(color='red', dash='dash')
166
- ))
167
-
168
  fig.update_layout(
169
- title="Cumulative Savings vs Total System Cost Over Time",
170
- xaxis_title="Months",
171
- yaxis_title="Amount (₹)",
172
- legend_title="Legend",
173
- template="plotly_white"
174
  )
175
-
176
- st.plotly_chart(fig, use_container_width=True, key="solar_graph")
177
 
178
  else:
179
  st.error("Sorry, the location entered does not match any available data.")
180
  else:
181
- st.info("Please fill out all fields to get your solar project estimate.")
 
 
10
  load_dotenv()
11
 
12
  # Set page configuration
13
+ st.set_page_config(page_title="☀️AI-Based Solar Project Estimation Tool", layout="centered")
14
 
15
  # Initialize Gemini with the API key
16
  api_key = os.getenv("GOOGLE_API_KEY")
 
67
  return prompt
68
 
69
  # UI - Form for user input
70
+ st.title("☀️ AI-Based Solar Project Estimation Tool")
71
  st.write("### Enter Your Details Below:")
72
 
73
  with st.form("solar_form"):
 
137
  st.warning("There was an issue processing the response. Please try again.")
138
 
139
  # Show Graph if values are available
140
+ # Visual Summary - Grouped Bar Chart
141
+ if system_size_kw is not None and total_system_cost is not None:
142
  st.subheader("📊 Visual Summary")
143
+
144
+ # Grouped Bar chart for all the values
145
+ fig = go.Figure(data=[
146
+ go.Bar(
147
+ name="System Size (kW)",
148
+ x=["Solar System Size", "Daily Output", "Total Cost", "Monthly Savings", "Payback Period"],
149
+ y=[system_size_kw, daily_output_kwh, total_system_cost, monthly_savings_rs, payback_period_years],
150
+ marker_color='#636EFA'
151
+ ),
152
+ go.Bar(
153
+ name="Financials",
154
+ x=["Solar System Size", "Daily Output", "Total Cost", "Monthly Savings", "Payback Period"],
155
+ y=[0, 0, total_system_cost, monthly_savings_rs, payback_period_years],
156
+ marker_color='#00CC96'
157
+ )
158
+ ])
159
+
160
+ # Update layout
 
 
 
 
 
 
 
 
161
  fig.update_layout(
162
+ barmode='group',
163
+ title="Comparison of Solar System Parameters",
164
+ yaxis_title="Values",
165
+ xaxis_title="Parameters"
 
166
  )
167
+ st.plotly_chart(fig, use_container_width=True)
 
168
 
169
  else:
170
  st.error("Sorry, the location entered does not match any available data.")
171
  else:
172
+ st.warning("Please fill out all fields to see your solar project estimate.")
173
+