File size: 2,606 Bytes
b555fe1 a851214 372b3f3 0cdc019 23fc541 ad6586e 0cdc019 618f85b eaee169 70d18af 27cc353 a851214 b555fe1 a851214 27cc353 ad6586e 586cb7a eaee169 37b1115 eaee169 abd807a eaee169 ad6586e eaee169 2d29e28 ad6586e 54c70ee b555fe1 822b684 eaee169 abd807a ad6586e 5b84378 ad6586e 1854cda b555fe1 ad6586e b555fe1 ad6586e |
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 |
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))
# Fixed line: showing only bolded "Rooftop Solar" heading
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 directly
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)
# Display Results
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.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.")
|