Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Git
.git
.gitignore

# Python
__pycache__
*.pyc
.venv
.env

# Tests
.pytest_cache
.coverage
htmlcov

# IDE
.vscode
.idea

# OA Data (Exclude large datasets, but KEEP la_haute_borne for demo)
examples/data/kelmarsh
examples/data/penmanshiel
examples/data/cleansed
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,6 @@ sphinx/examplesout.ipynb

.ipython
*.nc

# Allow La Haute Borne data for deployment
!examples/data/la_haute_borne/*.csv
35 changes: 35 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Use a slim Python 3.11 image
FROM python:3.11-slim

# Set working directory
WORKDIR /app

# Install system dependencies (some OA libs might need build tools)
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential \
&& rm -rf /var/lib/apt/lists/*

# Copy requirements and install
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt

# Copy the local openoa source
COPY openoa/ ./openoa/
COPY pyproject.toml .

# Install the local package in editable mode (or just ensure it's in path)
RUN pip install -e .

# Copy application files
COPY main.py .
COPY index.html .

# Copy example data (needed for the demo calculation)
# Note: Ensure this directory is populated with at least the La Haute Borne CSVs
COPY examples/data/la_haute_borne/ ./examples/data/la_haute_borne/

# Expose port
EXPOSE 8080

# Run the application
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8080"]
98 changes: 98 additions & 0 deletions debug_oa.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
import pandas as pd
from openoa.plant import PlantData
from openoa.analysis.aep import MonteCarloAEP
import os
import traceback

def debug_oa():
# Define the base data path
data_path = "examples/data/la_haute_borne"

print("Loading data...")
try:
# Load Asset Data
asset = pd.read_csv(os.path.join(data_path, "la-haute-borne_asset_table.csv"))

# Load SCADA Data
scada = pd.read_csv(os.path.join(data_path, "la-haute-borne-data-2014-2015.csv"))
scada["Date_time"] = pd.to_datetime(scada["Date_time"], utc=True).dt.tz_localize(None)

# Load Meter Data (contains energy, availability, curtailment)
meter = pd.read_csv(os.path.join(data_path, "plant_data.csv"))
meter["time_utc"] = pd.to_datetime(meter["time_utc"], utc=True).dt.tz_localize(None)

# Use same file for curtail data as it contains those columns
curtail = meter.copy()

# Load Reanalysis Data - ERA5 and MERRA2 have leading index columns
era5 = pd.read_csv(os.path.join(data_path, "era5_wind_la_haute_borne.csv"), index_col=0)
era5["datetime"] = pd.to_datetime(era5["datetime"], utc=True).dt.tz_localize(None)

merra2 = pd.read_csv(os.path.join(data_path, "merra2_la_haute_borne.csv"), index_col=0)
merra2["datetime"] = pd.to_datetime(merra2["datetime"], utc=True).dt.tz_localize(None)

# Define Metadata
metadata = {
"capacity": 8.2,
"asset": {
"asset_id": "Wind_turbine_name",
"latitude": "Latitude",
"longitude": "Longitude"
},
"meter": {
"time": "time_utc",
"MMTR_SupWh": "net_energy_kwh"
},
"curtail": {
"time": "time_utc",
"IAVL_DnWh": "availability_kwh",
"IAVL_ExtPwrDnWh": "curtailment_kwh"
},
"scada": {
"time": "Date_time",
"asset_id": "Wind_turbine_name",
"WTUR_W": "P_avg",
"WMET_HorWdSpd": "Ws_avg"
},
"reanalysis": {
"era5": {
"time": "datetime",
"WMETR_HorWdSpd": "ws_100m",
"WMETR_HorWdSpdU": "u_100",
"WMETR_HorWdSpdV": "v_100",
"WMETR_AirDen": "dens_100m"
},
"merra2": {
"time": "datetime",
"WMETR_HorWdSpd": "ws_50m",
"WMETR_HorWdSpdU": "u_50",
"WMETR_HorWdSpdV": "v_50",
"WMETR_AirDen": "dens_50m"
}
}
}

print("Initializing PlantData...")
plant = PlantData(
metadata=metadata,
scada=scada,
meter=meter,
curtail=curtail,
asset=asset,
reanalysis={"era5": era5, "merra2": merra2}
)


print("Running AEP Analysis...")
pa = MonteCarloAEP(plant)
pa.run(num_sim=10, progress_bar=False)

print(f"AEP Result: {pa.results.mean()}")
print("Analysis finished successfully!")

except Exception as e:
print(f"Error during execution: {e}")
traceback.print_exc()

if __name__ == "__main__":
debug_oa()
9 changes: 9 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
services:
openoa-api:
build: .
ports:
- "8080:8080"
volumes:
- ./examples/data:/app/examples/data
environment:
- LOG_LEVEL=INFO
10 changes: 10 additions & 0 deletions examples/data/la_haute_borne/SCADA_data_description.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Variable_name;Variable_long_name;Unit_long_name;Comment
Ws;Wind_speed;m/s;Average wind speed
Ot;Outdoor_temperature;deg_C;
Ya;Nacelle_angle;deg;
Rm;Torque;Nm;
Wa;Absolute_wind_direction;deg;
Ba;Pitch_angle;deg;
Ds;Generator_speed;rpm;
Va;Vane_position;deg;
P;Active_power;kW;
Loading