The Python lab section runs entirely in your browser using Pyodide(Python 3.11 compiled to WebAssembly). NumPy, SciPy and Matplotlib are available out of the box; you can modify the code, re-run it, and see plots immediately. The status indicator below shows when the runtime is ready — usually a few seconds on first load, then cached for subsequent visits.
The four labs at a glance
Lab 1 — Spectrogram of a synthesised dawn chorus
Build a multi-species chorus by adding sinusoids of different frequencies and time envelopes, compute its short-time Fourier transform, and visualise the resulting spectrogram. Compare it to a real bird recording (provided as a small embedded WAV). The lab introduces SciPy's scipy.signal.spectrogramand the trade-off between time and frequency resolution governed by the window length.
Lab 2 — Acoustic indices from scratch
Implement the ACI (Acoustic Complexity Index), BI (Bioacoustic Index) and NDSI (Normalised Difference Soundscape Index) directly from their definitions in NumPy. Apply them to a set of test spectrograms with known soundscape composition and verify that the indices respond as expected. This lab is a good entry point to the technical literature on soundscape ecology.
Lab 3 — Niche-partitioning model
Simulate N species as bivariate Gaussian distributions in frequency-time space; compute pairwise acoustic-niche overlaps Oij; and investigate how community-level overlap evolves under a Lotka-Volterra-like competition dynamic where high-overlap pairs penalise each other. Plot the resulting partition and verify Krause's prediction of evolved non-overlap.
Lab 4 — Optimal-transport restoration
Take a degraded soundscape and a healthy reference; compute the W2 Wasserstein distance between their spectral measures; and find the optimal transport plan that maps one onto the other. This is the mathematical content of Module 11 made concrete with the POT (Python Optimal Transport) library. The lab illustrates how acoustic restoration can be quantified, not just described.
What you need
- A modern browser (Chrome, Firefox, Safari, Edge — Pyodide works on all four).
- ~100 MB of free memory for the Pyodide runtime.
- ~30 s of patience for Pyodide's first download — the runtime is cached for subsequent visits.