Skip to content

lily1c/SolarProjectSCVfiles2

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

7 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐ŸŒž 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


๐ŸŽฏ 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
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
  1. Create virtual environment
python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate
  1. Install dependencies
pip install -r requirements.txt
  1. Run the application
streamlit run app.py

The app will open at http://localhost:8501


๐Ÿ“ Project Structure

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

๐Ÿงฎ How It Works

1. Panel Temperature Calculation

T_panel = T_ambient + ((NOCT - 20) / 800) ร— Irradiance
  • NOCT (Nominal Operating Cell Temperature) = 45ยฐC
  • Accounts for heat buildup from solar radiation

2. Efficiency Loss Model

efficiency = ฮท_ref ร— (1 - ฮฒ ร— (T_panel - 25ยฐC))
  • ฮท_ref = 18% (reference efficiency at 25ยฐC)
  • ฮฒ = 0.5%/ยฐC (temperature coefficient)

3. Power Output Comparison

  • 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

4. Decision Logic

Cooling is recommended when:

Energy_Gain > Cooling_Cost

๐Ÿค– Machine Learning Model

Training Data

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

Model Performance

  • Algorithm: Decision Tree Classifier
  • Accuracy: >95% on test set
  • Validation: Cross-checked against physics-based calculations

Best Regions for Cooling

  1. Phoenix, AZ - High temperature + High irradiance
  2. Riyadh, Saudi Arabia - Extreme desert heat
  3. Las Vegas, NV - Consistent sun exposure
  4. Palm Springs, CA - Hot, dry conditions

๐Ÿ’ป Usage Guide

Option 1: Real-Time Weather Data

  1. Enter a location (e.g., "Phoenix, AZ")
  2. Select date and time
  3. Click "Fetch Weather Data"
  4. View cooling recommendation and analysis

Option 2: Manual Input

  1. Select "Manual Input" mode
  2. Adjust temperature and irradiance sliders
  3. Results update in real-time

Understanding Results

  • 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

๐ŸŽ“ What I Learned

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.


๐Ÿš€ Deployment

This app is deployed on Streamlit Cloud (free tier):

Live URL: https://solarprojectscvfiles2-5k9mwrsrmm9a2m7da5kuba.streamlit.app

To Deploy Your Own Instance:

  1. Fork this repository
  2. Sign up at share.streamlit.io
  3. Connect your GitHub account
  4. Deploy with one click

๐Ÿ”ฎ Future Enhancements

  • 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

๐Ÿ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.


๐Ÿ‘จโ€๐Ÿ’ป Author

Assolaba Sova


๐Ÿ™ Acknowledgments

  • NASA POWER Project - Free weather data API
  • OpenStreetMap - Geocoding services
  • Streamlit - Amazing web framework for Python
  • MLH Fellowship - Inspiration for building production-ready applications

๐Ÿ“ง Contact

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

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages