A collection of Python scripts used to parse OCHRE heat pump water heater data, run Monte Carlo sampling, compute confidence intervals, and generate plots + Word documents.
- Get_marginal_load_final.py
- P95percent_confidence_data_by_time.py
- parse_OCHRE_data_final.py
- Plot_3D_surfaces_final.py
- plot_aggregate_load.py
- png_to_word.py
This folder contains several standalone Python scripts used in an HPWH (heat pump water heater) workflow:
- parse_OCHRE_data_final.py converts raw OCHRE exports into a “ready” pivoted dataset (Homes × 15-minute time columns).
- Get_marginal_load_final.py runs Monte Carlo sampling for increasing fleet size (1…N units), aggregates sampled loads, and outputs time-series statistics (mean, quantiles, variance, etc.) for each fleet size.
- P95percent_confidence_data_by_time.py reads the Monte Carlo output files and, for each 15-minute time step, visualizes the mean and percentile bands vs number of units; it also writes a compact per-time summary CSV (P_mean_*) containing mean/95th/5th values.
- Plot_3D_surfaces_final.py creates 3D surfaces for the 97.5th percentile, mean, and 2.5th percentile across (time, units), including highlighted slices.
- plot_aggregate_load.py compares baseline vs controlled aggregate profiles for a chosen fleet size, computes energy metrics (kWh), and generates multiple plots (baseline, controlled, and differences).
- png_to_word.py interleaves baseline/control PNG figures into a formatted Word document grid for reporting.
Purpose: Monte Carlo sampling of HPWH load profiles for fleet sizes 1…unit_runs, computing time-series statistics per fleet size. Inputs: A “ready” CSV with a Home column and 15-minute time columns (e.g., 00:00, 00:15, …). Outputs: CSV files for: 0.975 quantile, mean, 0.025 quantile variance, standard deviation, skew Notes: Uses a scaling to per-unit / per-fleet normalization (MCS_table.div(0.5 * N)), where 0.5 is a domain-specific scaling constant (HPWH case).
Purpose: For each 15-minute time step, plot mean + percentile bands vs number of units, compute a linear fit, and export a compact CSV summary. Inputs: The Monte Carlo stats CSVs (97.5th, mean, 2.5th) and a ready CSV to determine the number of homes/rows available. Outputs: Appends rows to P_mean_control_1000.csv (or similar) with columns: time, P_mean_kW, 95th, 5th Notes: Produces per-time plots and a “CI width / mean (%)” curve on a secondary y-axis.
Purpose: Convert raw OCHRE export data into a clean pivot table format for downstream Monte Carlo sampling. Inputs: Raw OCHRE CSV containing a Time column, Home, and Water Heating Electric Power (kW) (plus other columns). Outputs: A pivoted “ready” CSV where: rows = Home columns = hr_min in HH:MM format values = Water Heating Electric Power (kW) Notes: Creates the output folder if it doesn’t exist.
Purpose: Visualize 3D surfaces for percentile/mean load vs time and vs number of units. Inputs: Three CSVs (97.5th, mean, 2.5th) produced by the Monte Carlo pipeline. Outputs: Interactive 3D plot window (matplotlib). Notes: Includes example highlights for a specific N and a specific time slice.
Purpose: Compare baseline vs controlled HPWH aggregate load profiles for a selected fleet size and compute energy metrics. Inputs: P_mean_baseline_.csv and P_mean_control_.csv (generated by the confidence-by-time workflow). Outputs: Multiple plots: Controlled − Baseline Baseline − Controlled Overlay of Baseline vs Controlled Per-segment 15-minute energy bar plot Optional exported CSV for per-interval energy (e.g., segment_energy_baseline.csv) Notes: Includes helper functions for kWh computation and dynamic engineering unit scaling (kW/MW/GW).
Purpose: Build a Word doc that interleaves baseline/control PNG plots in a grid layout, page by page. Inputs: Two folders of PNGs (./baseline_images, ./control_images by default). Outputs: A Word document (default: baseline_control_interleaved.docx). Notes: Uses python-docx, sets 0.5" margins, and paginates after each filled grid.
- Install Python WSL or Ubuntu
- Install Python 3.10+ (recommended)
- Verify installation: python3 --version (WSL) or python --version (Windows)
- Clone this repository
- Open repository in your preferred code builder program. (This was built in VS Code)_
- In the terminal, cd into the Aggregate_Load_Analysis folder Optional:
- Create a virtual environment and install packages
- Create venv: python3 -m venv .venv
Install dependencies (WSL/Ubuntu using sudo + apt):
sudo apt updatesudo apt install -y python3-pandas python3-numpy python3-matplotlib python3-sklearn python3-docx
No known bugs at the this time.
Support and Contact Details Any known issues, please reach out to Jeff Dinsmore by email at hello@jeffdinsmore.com
- Windows 11
- WSL/Ubuntu
- Python 3
- Pandas
- NumPy
- Matplotlib
- scikit-learn
- python-docx
- VS Code
Copyright (c) 2025 - Updated Feb 2026, Jeff Dinsmore
This software is licensed under the GNU General Public License.