File size: 3,161 Bytes
b555fe1
 
a851214
372b3f3
0cdc019
ede32d8
ad6586e
0cdc019
618f85b
eaee169
70d18af
27cc353
a851214
 
 
 
 
b555fe1
a851214
27cc353
ad6586e
 
 
 
 
ede32d8
eaee169
 
 
 
 
 
37b1115
eaee169
abd807a
 
eaee169
 
 
ede32d8
eaee169
2d29e28
ad6586e
54c70ee
b555fe1
822b684
eaee169
ede32d8
abd807a
 
ad6586e
 
ede32d8
 
ad6586e
 
ede32d8
 
 
 
 
 
ad6586e
 
ede32d8
 
 
 
 
 
 
 
 
 
ad6586e
 
1854cda
b555fe1
ad6586e
b555fe1
ede32d8
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
import streamlit as st
import pandas as pd
import google.generativeai as genai
import os
from dotenv import load_dotenv

# Load environment variables
load_dotenv()

# Set page configuration
st.set_page_config(page_title="☀️AI-Based Solar Project Estimation Tool", layout="centered")

# Load solar data
@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()

# Constants
TARIFF_RATE = 7  # ₹7 per kWh
ROOFTOP_CONVERSION_FACTOR = 0.10  # 0.10 kW per sq meter

# UI - Form
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.markdown("### **Rooftop Solar**")

    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")

# Calculate estimates
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 (₹)']

        # Calculations
        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_solar_generation = round(estimated_daily_output * 30, 2)
        monthly_savings = round(monthly_solar_generation * TARIFF_RATE, 2)
        payback_period = round(total_system_cost / (monthly_savings * 12), 2)

        # Calculate Bill Offset
        if electricity_bill > 0:
            bill_offset_percentage = round((monthly_savings / electricity_bill) * 100, 2)
        else:
            bill_offset_percentage = None

        # Display Results
        st.subheader("🔹 Solar Project Estimate")
        st.write(f"**Estimated solar system size (kW)**: {system_size_kw}")
        st.write(f"**Estimated daily solar output (kWh/day)**: {estimated_daily_output}")
        st.write(f"**Estimated monthly solar generation (kWh/month)**: {monthly_solar_generation}")
        st.write(f"**Total system cost (₹)**: {total_system_cost}")
        st.write(f"**Monthly savings from solar (₹)**: {monthly_savings}")
        st.write(f"**Payback period (years)**: {payback_period}")

        # Display Bill Offset if entered
        if bill_offset_percentage is not None:
            st.write(f"**Solar will offset approximately {bill_offset_percentage}% of your monthly electricity bill.**")

        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.")