This repository contains a feasibility study and machine learning forecasting pipeline initiated in late 2023 to model the future rooftop solar photovoltaic (PV) microgrid at the École Centrale Casablanca campus in Bouskoura, Morocco (coordinates: 33.4806° N, -7.6183° W).
The study models the grid's performance for the target operational year of 2025 by establishing a realistic physical system layout through standard flat-roof geometric spacing and thermodynamic thermal-loss constraints. It trains an XGBoost model on real-world PV SCADA telemetry to emulate hardware performance, and transposes those learned physical relationships to Casablanca’s actual weather to generate accurate, loss-adjusted generation forecasts.
- Full Technical Report: Read our comprehensive engineering feasibility study in
report.pdf. - Interactive Notebook: Explore the complete data cleaning, anomaly detection, and machine learning pipeline in
notebooks/campus-energy-optimization.ipynb.
In 2023, it was estimated that the university campus consumes
In order to resolve the physical limitations of rooftop arrays, we implemented standard flat-roof layout constraints:
-
50% Spacing Rule: Flat roofs require tilted panels (fixed at
$30^\circ$ South-facing to optimize winter generation). To prevent tilted rows from casting shadows on one another, a flat-roof utilization factor of$50%$ was applied. -
System Sizing Breakdown:
-
35 Pavilions:
$35 \times 70\text{ m}^2 \text{ roof area} = 2,450\text{ m}^2$ -
Pedagogical Buildings:
$7,000\text{ m}^2 \text{ roof area}$ -
Galilée Building:
$800\text{ m}^2 \text{ roof area}$ -
Total Usable Roof Area:
$10,250\text{ m}^2 \times 0.50 = \mathbf{5,125\text{ m}^2}$
-
35 Pavilions:
-
Module Selection: Tesla Solar Plasma TS545PR (
$545\text{ Wp}$ , Mono PERC,$2.58\text{ m}^2$ per panel) -
Total Physical Capacity:
$$\text{Total Modules} = \frac{5,125\text{ m}^2}{2.58\text{ m}^2} \approx 1,986\text{ panels}$$ $$\text{Total Capacity} = 1,986 \text{ panels} \times 0.545\text{ kWp} = \mathbf{1,082.37\text{ kWp}}$$
Our forecasting model was trained on a real-world PV SCADA database (Rostamipour & Ghayeni 2026) consisting of 90 days of continuous 30-minute inverter telemetry and collocated weather station readings.
-
Temperature Unit Mismatch: logging mismatches were found where one weather station switched outputs from Celsius to Fahrenheit (
$^\circ\text{F}$ ), creating outliers. These were isolated and corrected to Celsius. - Electrical Scaling Glitches: Some inverters logged DC power in Watts instead of Kilowatts, creating impossible power spikes. These were normalized back to Kilowatts.
-
Inverter Efficiency Correlation Audit: A correlation audit proved that logged inverter efficiency was independent of all physical parameters (
$r < 0.02$ ), behaving as a static constant ($96.99% \pm 0.86%$ ). We treated efficiency as a fixed system parameter ($97%$ ) and excluded it from the ML pipeline to prevent overfitting on random sensor noise. -
Temporal Split: To prevent data leakage, we sorted the dataset chronologically and split it: the first
$80%$ of the timeline (spring) for training ($14,332$ rows) and the remaining$20%$ (early summer) for testing ($3,583$ rows). -
Solar Geometry Features: Added solar zenith angles (computed via
pvlib) and direct/diffuse irradiance splits to allow the model to understand the sun's trajectory relative to the tilted panels. -
Inverter One-Hot Encoding: Handled a systematic
$24.8%$ output discrepancy between the 8 physical string inverters across the solar field by one-hot encoding the inverter IDs.
Both machine learning models were evaluated on the chronologically unseen test set:
| Model Architecture | R-squared ( |
MAE (kW) | RMSE (kW) |
|---|---|---|---|
| Random Forest | |||
| XGBoost (Our Model) |
Using the NASA POWER API, we retrieved a complete, hourly weather dataset for Bouskoura for the year 2025 (
-
Cleaning Sentinel Values: We audited the raw NASA dataset, located 24 corrupted hourly irradiance readings logged as the sentinel
-999.0, and resolved them using linear time-series interpolation. -
Zenith Calculations: We used
pvlibto calculate the solar zenith angle for every hour of 2025 based on the campus coordinates. -
Daytime Prediction Constraint: To prevent training errors, we filtered the Bouskoura dataset to isolate the
$4,015$ active daytime hours (GHI > 50 W/m²). We scaled and predicted only on these daytime hours, and then reconstructed the full 8,760-hour calendar year by mapping the predictions back into a timeline of zeros (representing nighttime). -
System Sizing Scaling: Since our XGBoost model was trained on a single
$170\text{ kW}$ SCADA inverter system, we scaled the predictions to match the proposed$1,082.37\text{ kWp}$ campus array:$$\text{Campus Power (kW)} = \frac{\text{Predicted Power (kW)}}{170.0} \times 1,082.37$$
The transposed machine learning model predicts a realistic, thermally degraded annual energy output of
A. Expected Sizing Range (With a $\pm6%$ Margin): $$\text{Expected Annual Generation} = \mathbf{1,327,228\text{ to } 1,496,660\text{ kWh/year}}$$
This corresponds to a realistic system yield of $1,304.51\text{ kWh/kWp/year}$.
-
Current Demand Coverage: This system covers
$91.28%$ of the school's 2023 annual consumption ($1,546,749\text{ kWh}$ ). -
Future Demand Coverage: This system covers
$65.30%$ of the school's projected annual consumption ($2,162,213\text{ kWh}$ ).
Model-Predicted Monthly Generation (2025):
January : 86,790.26 kWh
February : 87,618.63 kWh
March : 111,497.59 kWh
April : 120,230.19 kWh
May : 146,647.90 kWh
June : 149,063.21 kWh
July : 158,681.13 kWh (Summer Solstice Peak)
August : 152,824.90 kWh
September : 130,890.91 kWh
October : 109,158.59 kWh
November : 88,469.24 kWh
December : 70,086.52 kWh (Winter Solstice Trough)
To execute the data pipeline and reproduce the predictions:
- Clone this repository:
git clone https://github.com/ALZ-11/campus-energy-optimization cd campus-energy-optimization - Install all dependencies:
pip install -r requirements.txt
- Place the Raw SCADA Files:
Download the raw files from the Mendeley Data Repository and place them as:
data/raw/Inverter SCADA.csvdata/raw/Meteorological data.csv
- Run the Notebook:
Open and execute all cells in
notebooks/campus-energy-optimization.ipynb. The notebook will automatically clean the SCADA data, train the XGBoost model, query the live NASA POWER API for Bouskoura's 2025 weather, and generate the final monthly yield forecasts.