An interactive web application that optimizes solar panel performance by determining when active cooling is cost-effective using real-time weather data and machine learning.
๐ Live Demo: https://solarprojectscvfiles2-5k9mwrsrmm9a2m7da5kuba.streamlit.app
Solar panels lose efficiency as they heat up - approximately 0.5% per degree Celsius above 25ยฐC. While active cooling systems can reduce panel temperature and increase power output, the cooling pump itself consumes energy.
The Challenge: When does the energy gained from cooling outweigh the cost of running the cooling system?
This application solves that optimization problem in real-time for any location worldwide.
- ๐ Real-Time Weather Data - Fetches live temperature and solar irradiance from NASA POWER API
- ๐ฌ Physics-Based Calculations - Computes panel temperature using NOCT equations and efficiency models
- ๐ค Machine Learning Validation - Decision tree model trained on 131k+ samples validates recommendations
- ๐ Interactive Visualizations - Dynamic gauge charts and energy breakdown graphs using Plotly
- ๐ Global Coverage - Works for any location via OpenStreetMap geocoding
- โก Dual Input Modes - Real-time API data or manual parameter entry
- Backend: Python 3.13
- Web Framework: Streamlit
- Machine Learning: Scikit-learn (Decision Tree Classifier)
- Data Processing: Pandas, NumPy
- Visualization: Plotly
- APIs:
- NASA POWER API (weather data)
- OpenStreetMap Nominatim (geocoding)
- Python 3.8+
- pip
- Clone the repository
cat > README.md << 'EOF'
# ๐ Solar Panel Cooling Optimizer
An interactive web application that optimizes solar panel performance by determining when active cooling is cost-effective using real-time weather data and machine learning.
**๐ Live Demo:** [https://solarprojectscvfiles2-5k9mwrsrmm9a2m7da5kuba.streamlit.app](https://solarprojectscvfiles2-5k9mwrsrmm9a2m7da5kuba.streamlit.app)
---
## ๐ฏ Problem Statement
Solar panels lose efficiency as they heat up - approximately 0.5% per degree Celsius above 25ยฐC. While active cooling systems can reduce panel temperature and increase power output, the cooling pump itself consumes energy.
**The Challenge:** When does the energy gained from cooling outweigh the cost of running the cooling system?
This application solves that optimization problem in real-time for any location worldwide.
---
## โจ Features
- **๐ Real-Time Weather Data** - Fetches live temperature and solar irradiance from NASA POWER API
- **๐ฌ Physics-Based Calculations** - Computes panel temperature using NOCT equations and efficiency models
- **๐ค Machine Learning Validation** - Decision tree model trained on 131k+ samples validates recommendations
- **๐ Interactive Visualizations** - Dynamic gauge charts and energy breakdown graphs using Plotly
- **๐ Global Coverage** - Works for any location via OpenStreetMap geocoding
- **โก Dual Input Modes** - Real-time API data or manual parameter entry
---
## ๐ ๏ธ Technology Stack
- **Backend:** Python 3.13
- **Web Framework:** Streamlit
- **Machine Learning:** Scikit-learn (Decision Tree Classifier)
- **Data Processing:** Pandas, NumPy
- **Visualization:** Plotly
- **APIs:**
- NASA POWER API (weather data)
- OpenStreetMap Nominatim (geocoding)
---
## ๐ฆ Installation & Local Setup
### Prerequisites
- Python 3.8+
- pip
### Setup Steps
1. **Clone the repository**
```bash
git clone https://github.com/lily1c/SolarProjectSCVfiles2.git
cd SolarProjectSCVfiles2- Create virtual environment
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate- Install dependencies
pip install -r requirements.txt- Run the application
streamlit run app.pyThe app will open at http://localhost:8501
SolarProjectSCVfiles2/
โโโ ๐ฏ PRODUCTION CODE
โ โโโ app.py # Streamlit web interface
โ โโโ src/
โ โ โโโ solar_cooling.py # Core optimization logic
โ โโโ models/
โ โ โโโ cooling_decision_model.pkl # Trained ML model
โ โโโ requirements.txt # Dependencies
โ โโโ .streamlit/
โ โโโ config.toml # Streamlit configuration
โ
โโโ ๐ DEVELOPMENT CODE
โโโ dev/
โ โโโ data_generation/ # NASA API data fetching scripts
โ โโโ training/ # ML model training
โ โโโ visualization/ # Analysis and plotting scripts
โ โโโ data_raw/ # Raw weather data (15 cities)
โ โโโ analysis_outputs/ # Generated charts and diagrams
โโโ data/
โโโ processed/
โโโ full_training_data.csv # Complete training dataset
T_panel = T_ambient + ((NOCT - 20) / 800) ร Irradiance- NOCT (Nominal Operating Cell Temperature) = 45ยฐC
- Accounts for heat buildup from solar radiation
efficiency = ฮท_ref ร (1 - ฮฒ ร (T_panel - 25ยฐC))- ฮท_ref = 18% (reference efficiency at 25ยฐC)
- ฮฒ = 0.5%/ยฐC (temperature coefficient)
- Uncooled Power:
P_uncooled = efficiency_uncooled ร Irradiance ร Panel_Area - Cooled Power:
P_cooled = efficiency_cooled ร Irradiance ร Panel_Area - Net Gain:
P_cooled - P_uncooled - Pump_Power
Cooling is recommended when:
Energy_Gain > Cooling_Cost
- 15 geographic locations (Phoenix, Riyadh, Seattle, Las Vegas, etc.)
- 131,400+ samples (8,760 hours ร 15 regions)
- Realistic sensor noise (ยฑ15 W/mยฒ irradiance, ยฑ2ยฐC temperature)
- Features: Ambient temperature, solar irradiance, hour of day, panel temperature
- Target: Binary classification (cool or don't cool)
- Algorithm: Decision Tree Classifier
- Accuracy: >95% on test set
- Validation: Cross-checked against physics-based calculations
- Phoenix, AZ - High temperature + High irradiance
- Riyadh, Saudi Arabia - Extreme desert heat
- Las Vegas, NV - Consistent sun exposure
- Palm Springs, CA - Hot, dry conditions
- Enter a location (e.g., "Phoenix, AZ")
- Select date and time
- Click "Fetch Weather Data"
- View cooling recommendation and analysis
- Select "Manual Input" mode
- Adjust temperature and irradiance sliders
- Results update in real-time
- Green Alert: Cooling recommended (net energy gain)
- Orange Alert: Cooling not recommended (net energy loss)
- Gauge Charts: Panel temperature, uncooled power, cooled power
- Energy Breakdown: Visual comparison of all energy factors
- ML Prediction: Model's recommendation and agreement with physics
Building this project taught me how to implement a complete machine learning pipeline and deploy it in a real application. I created a data generation script that fetches weather data from NASA POWER API for 15 geographic regions, generating 131,000+ training samples with realistic sensor noise to simulate real-world conditions. Training a decision tree classifier was straightforward, but I learned that deploying ML models requires careful attention to feature alignment - I had to use model.feature_names_in_ to ensure my production inputs match the exact column order from training.
I built a modular architecture by extracting core logic into solar_cooling.py that both my CLI and web app import from, following DRY principles. Integrating the trained model into a Streamlit web interface taught me about state management, API integration with OpenStreetMap for geocoding, and creating responsive UIs with Plotly visualizations. The deployment process showed me how to structure projects with proper dependency management and relative paths for easy deployment to production environments.
This app is deployed on Streamlit Cloud (free tier):
Live URL: https://solarprojectscvfiles2-5k9mwrsrmm9a2m7da5kuba.streamlit.app
- Fork this repository
- Sign up at share.streamlit.io
- Connect your GitHub account
- Deploy with one click
- Wind speed integration for convective cooling effects
- Historical data analysis and trend visualization
- Cost-benefit analysis with electricity pricing
- Support for different panel types and specifications
- Mobile-responsive design improvements
- User accounts for saving favorite locations
- Email/SMS alerts for optimal cooling times
This project is licensed under the MIT License - see the LICENSE file for details.
Assolaba Sova
- GitHub: @lily1c
- NASA POWER Project - Free weather data API
- OpenStreetMap - Geocoding services
- Streamlit - Amazing web framework for Python
- MLH Fellowship - Inspiration for building production-ready applications
For questions, feedback, or collaboration opportunities, please open an issue on GitHub.
Built for MLH Fellowship 2025 | Demonstrating Python, ML, and Full-Stack Development Skills