| import streamlit as st |
| import pandas as pd |
| import numpy as np |
| |
| import openai |
|
|
| |
| df = pd.read_csv('https://huggingface.co/spaces/MLDeveloper/AI_based_Solar_Project_Estimation_Tool/resolve/main/solar_data_india_2024.csv') |
|
|
| |
| openai.api_key = 'your_gemini_api_key_here' |
|
|
| |
| def get_state_data(state_name): |
| state_data = df[df['State'].str.contains(state_name, case=False)] |
| if state_data.empty: |
| return None |
| return state_data.iloc[0] |
|
|
| |
| def estimate_system_size(roof_size, ghi): |
| |
| system_size = roof_size / 10 |
| estimated_output = ghi * system_size |
| return system_size, estimated_output |
|
|
| |
| def estimate_cost_and_savings(system_size, state_data, electricity_bill): |
| |
| solar_cost_per_kw = state_data['Solar_Cost_per_kW (₹)'] |
| |
| system_cost = system_size * solar_cost_per_kw |
| |
| savings_per_month = electricity_bill |
| |
| payback_period = system_cost / (savings_per_month * 12) |
| |
| return system_cost, savings_per_month, payback_period |
|
|
| |
| st.title("AI-based Solar Project Estimation Tool") |
|
|
| |
| st.sidebar.header("Enter Your Details") |
| location = st.sidebar.text_input("Enter your city or state", "") |
| roof_size = st.sidebar.number_input("Enter your roof size (in sq meters)", min_value=1) |
| electricity_bill = st.sidebar.number_input("Enter your monthly electricity bill (₹)", min_value=0) |
|
|
| if location and roof_size > 0 and electricity_bill >= 0: |
| |
| state_data = get_state_data(location) |
| if state_data is not None: |
| ghi = state_data['Avg_GHI (kWh/m²/day)'] |
| |
| |
| system_size, estimated_output = estimate_system_size(roof_size, ghi) |
| |
| |
| system_cost, savings_per_month, payback_period = estimate_cost_and_savings(system_size, state_data, electricity_bill) |
| |
| |
| st.subheader("Estimated Solar System Details:") |
| st.write(f"**Location**: {location}") |
| st.write(f"**System Size**: {system_size:.2f} kW") |
| st.write(f"**Estimated Daily Output**: {estimated_output:.2f} kWh/day") |
| st.write(f"**Total System Cost**: ₹{system_cost:,.2f}") |
| st.write(f"**Monthly Savings**: ₹{savings_per_month:,.2f}") |
| st.write(f"**Payback Period**: {payback_period:.2f} years") |
| |
| |
| fig, ax = plt.subplots() |
| ax.bar(['Total System Cost', 'Monthly Savings', 'Payback Period'], |
| [system_cost, savings_per_month, payback_period*12], color=['blue', 'green', 'orange']) |
| ax.set_ylabel("Amount (₹) / Time (years)") |
| ax.set_title("Solar System Estimation Breakdown") |
| st.pyplot(fig) |
| |
| else: |
| st.error("Sorry, the location entered does not match any available data.") |
| else: |
| st.warning("Please fill out all fields to see your solar project estimate.") |
|
|