Skip to content
Merged
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.DS_Store
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
.venv/
examples/heatmaps/
__pycache__/
*.pyc
.venv/
__pycache__/
*.pyc
examples/heatmaps/
.venv/
__pycache__/
*.pyc
examples/heatmaps/
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# AFL Workload & Heatmap Pipeline

This repo provides **workload metrics** and **heatmap visualisations** from AFL player tracking data.
It processes coordinate-based tracking files (`tracking2.0.csv`) and delivers outputs consumable by the frontend.

---

## Project structure

afl-workload-pipeline/
├─ config.yaml # thresholds & settings (edit here, no code changes needed)
├─ examples/
│ ├─ tracking2.0.csv # sample input (~200 frames)
│ ├─ out_workload.json # sample workload output
│ ├─ out_workload.csv # same data in CSV format
│ └─ heatmaps/ # sample generated PNGs
├─ scripts/
│ ├─ compute_workload.py # workload metrics CLI
│ └─ generate_heatmaps.py # heatmap generation CLI
├─ workload/ # workload metric logic (distance, speed, HSR, ratios)
├─ heatmaps/ # heatmap logic (grid, blur, render)
└─ tests/ # unit tests

## Setup

Clone and set up environment:

```bash
git clone https://github.com/<USERNAME>/afl-workload-pipeline.git
cd afl-workload-pipeline

python3 -m venv .venv
source .venv/bin/activate

pip install -r requirements.txt # or: pip install pandas numpy pyyaml scipy matplotlib imageio

python scripts/compute_workload.py \
--tracking examples/tracking2.0.csv \
--config config.yaml \
--out-json examples/out_workload.json \
--out-csv examples/out_workload.csv

Outputs:
• JSON: per-player workload indicators (distance, speed, HSR, work/rest, workload score, fatigue risk).
• CSV: tidy table for spreadsheets / BI tools.

python scripts/generate_heatmaps.py \
--tracking examples/tracking2.0.csv \
--config config.yaml \
--out-dir examples/heatmaps \
--group-by player_id

Outputs:
• PNG heatmaps in examples/heatmaps/
• Configurable grid size (nx, ny), blur (sigma), and weighting mode (conf).

Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# === AFL Workload & Heatmap Config ===

# Tracking video parameters
fps: 25.0 # frames per second of the dataset

field:
length_m: 165.0 # AFL oval length (metres)
width_m: 135.0 # AFL oval width (metres)

# Data smoothing
speed_smoothing_window: 3
accel_smoothing_window: 3

# Thresholds for workload metrics
thresholds:
hsr_kmh: 18.0 # high-speed running (HSR) threshold in km/h
sprint_kmh: 24.0 # sprint threshold (optional future use)
accel_ms2: 3.0 # high acceleration threshold (m/s²)
decel_ms2: -3.0 # high deceleration threshold (m/s²)
min_sprint_dur_s: 1.0 # sprint must last at lease this long
repeat_sprint_window_s: 60 # time window for repeated sprints (seconds)

# Weights for workload score calculation
weights:
distance: 0.25
hsr: 0.25
repeat_sprints: 0.20
accels_decels: 0.20
work_rest: 0.10

# Risk bands for fatigue risk classification
risk_bands:
- {max: 40, label: "Low"}
- {max: 70, label: "Moderate"}
- {max: 100, label: "High"}

# Quarter segmentation (seconds from game start)
quarters:
# Default: standard 20-min quarters → edges at 1200s, 2400s, 3600s
edges_s: [1200, 2400, 3600]

# Heatmap rendering parameters
heatmap:
nx: 200 # grid cells in x-direction
ny: 150 # grid cells in y-direction
sigma: 2.0 # Gaussian blur (controls smoothing)
weight_mode: conf # "conf" = confidence-weighted, or None for uniform
vmax_percentile: 99 # scaling for consistent colour intensity

Large diffs are not rendered by default.

Loading