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