| import streamlit as st |
| import pandas as pd |
| import google.generativeai as genai |
| import os |
| from dotenv import load_dotenv |
| import plotly.graph_objects as go |
|
|
|
|
| |
| load_dotenv() |
|
|
| |
| st.set_page_config(page_title="☀️AI-Based Solar Project Estimation Tool", layout="centered") |
|
|
| |
| @st.cache_data |
| def load_data(): |
| df = pd.read_csv('https://huggingface.co/spaces/MLDeveloper/AI_based_Solar_Project_Estimation_Tool/resolve/main/solar_data_india_2024.csv') |
| return df |
|
|
| df = load_data() |
|
|
| |
| TARIFF_RATE = 7 |
| ROOFTOP_CONVERSION_FACTOR = 0.10 |
|
|
| |
| st.title("☀️AI-Based Solar Project Estimation Tool") |
| st.write("### Enter Your Details Below:") |
|
|
| with st.form("solar_form"): |
| state_options = df['State'].dropna().unique() |
| location = st.selectbox("Select your State", options=sorted(state_options)) |
| |
| st.radio( |
| "Select Solar Project Type", |
| options=["Rooftop Solar"], |
| index=0, |
| disabled=True |
| ) |
|
|
| roof_size = st.number_input("Enter your roof size (in sq meters)", min_value=1) |
| electricity_bill = st.number_input("Enter your monthly electricity bill (₹)", min_value=0) |
|
|
| submitted = st.form_submit_button("Get Estimate") |
|
|
| |
| if submitted and location: |
| state_data = df[df['State'].str.contains(location, case=False)].iloc[0] |
|
|
| if state_data is not None: |
| ghi = state_data['Avg_GHI (kWh/m²/day)'] |
| solar_cost_per_kw = state_data['Solar_Cost_per_kW (₹)'] |
|
|
| system_size_kw = round(roof_size * ROOFTOP_CONVERSION_FACTOR, 2) |
| estimated_daily_output = round(system_size_kw * ghi, 2) |
|
|
| total_system_cost = round(system_size_kw * solar_cost_per_kw, 2) |
| monthly_savings = round(estimated_daily_output * 30 * TARIFF_RATE, 2) |
| payback_period = round(total_system_cost / (monthly_savings * 12), 2) |
|
|
| |
| st.subheader("🔹 Solar Project Estimate") |
| st.write(f"**Estimated solar system size in kW**: {system_size_kw}") |
| st.write(f"**Estimated daily solar output in kWh**: {estimated_daily_output}") |
| st.write(f"**Total system cost in ₹**: {total_system_cost}") |
| st.write(f"**Monthly savings in ₹**: {monthly_savings}") |
| st.write(f"**Payback period in years**: {payback_period}") |
|
|
| |
| st.subheader("📊 Visual Summary") |
| fig = go.Figure(data=[ |
| go.Bar( |
| name="System Parameters", |
| x=["System Size (kW)", "Daily Output (kWh)", "Total Cost (₹)", "Monthly Savings (₹)", "Payback (Years)"], |
| y=[system_size_kw, estimated_daily_output, total_system_cost, monthly_savings, payback_period], |
| marker_color='#636EFA' |
| ) |
| ]) |
| fig.update_layout( |
| title="Solar System Estimation Overview", |
| yaxis_title="Values", |
| xaxis_title="Parameters" |
| ) |
| st.plotly_chart(fig, use_container_width=True) |
|
|
| st.info("Note: Tariff assumed ₹7/kWh. Actual payback may vary based on location, grid policy, and maintenance.") |
|
|
| else: |
| st.error("State data not found. Please try a valid state.") |
| else: |
| st.warning("Please complete all fields to get your estimate.") |
|
|