The problem
Weather maps are re-contoured every model cycle: GFS four times a day, HRRR every hour, for dozens of parameters, levels, forecast hours and ensemble members, and increasingly delivered as vector isolines (GeoJSON or vector tiles) rather than images. Most of that work runs on the scientific Python stack. matplotlib (via cartopy, MetPy and ECMWF’s new earthkit-plots, the successor to Magics) calls ContourPy underneath. Contouring is often the slowest step of the chart pipeline, and isoline APIs pay for it on every request.
Head-to-head on real NOAA model output
All four fields come from one 00z NOAA cycle of November 2026, decoded from GRIB2 with GDAL, contoured at the intervals forecasters actually use.
| Dataset | Grid · levels | isosweep1 thread | isosweep16 threads | ContourPy1 thread | GDAL 3.14-dev1 thread | VTK Flying Edges1 thread | ContourPy64 threads | VTK Flying Edges16 threads | Speed-upvs fastest 1-thread | Speed-upvs fastest overall |
|---|---|---|---|---|---|---|---|---|---|---|
| GFS 0.25° global sea-level pressure (isobars) real data | 1,440 × 721 · every 4 hPa | 11.0 ms | 3.60 ms | 135 ms | 54.2 ms | 107 ms | 31.1 ms | 48.2 ms | 4.9× | 8.6× |
| GFS 0.25° global 2 m temperature (isotherms) real data | 1,440 × 721 · every 1 °C | 62.4 ms | 18.1 ms | 383 ms | 240 ms | 2.06 s | 85.8 ms | 1.87 s | 3.8× | 4.7× |
| HRRR 3 km CONUS sea-level pressure (isobars) real data | 1,799 × 1,059 · every 2 hPa | 8.18 ms | 2.21 ms | 164 ms | 57.2 ms | 94.5 ms | 28.3 ms | 23.0 ms▲ | 7.0× | 10× |
| HRRR 3 km CONUS 2 m temperature (isotherms) real data | 1,799 × 1,059 · every 1 °C | 127 ms | 35.5 ms | 423 ms | 450 ms | 9.80 s | 71.5 ms | 9.55 s | 3.3× | 2.0× |
| HRRR temperature frontal analysis | 1,799 × 1,799 · 26 levels (interval 2.5) | 6.34 ms | 1.70 ms | 302 ms | 78.3 ms | 155 ms | 43.5 ms | 24.0 ms▲ | 12× | 14× |
Median wall-clock time per full extraction, in-process, identical in-memory grid and iso-levels for every tool, each in its fastest documented configuration; lower is better. All line tools return assembled polylines. "Fastest overall" compares our best (1 or 16 threads) with the best result of any other library at any thread count; the shaded cell is that library. Measured November 2026 on Intel(R) Xeon(R) Platinum 8488C (48 cores / 96 threads) — AWS EC2 c7i.metal-24xl (dedicated bare-metal server, no hypervisor); Linux-7.0.0-1018-aws-x86_64-with-glibc2.39; turbo disabled; governor performance; THP never. ▲ marks a time that varied more than 5% from run to run; it is used as measured. Methodology.
Exact configuration of each library
- ContourPy (serial) — variant serial_reused {"name": "serial", "line_type": "LineType.ChunkCombinedOffset", "reuse_generator": true}
- GDAL 3.14-dev (master) — Both versions built from source with identical options. callback = pure computation, points copied into a result buffer (as any caller must); generate_ex = native API into an in-memory layer (native result type), the layer reset before each call outside the clock. Published value = faster of the two. variant generate_ex {"api": "GDALContourGenerateEx (in-memory layer)"}
- VTK Flying Edges (1 thread) — vtkImageData + filter pipeline built in prepare (zero-copy wrap, O(1)). vtkStripper joins segments into polylines (required for like-for-like output; MaximumLength unlimited so lines are fully joined) and is timed. variant sequential {"backend": "Sequential", "threads": 1}
- ContourPy (threaded, best threads × chunks) — variant threaded_reused {"name": "threaded", "line_type": "LineType.ChunkCombinedOffset", "thread_count": 8, "chunk_count": [4, 4], "reuse_generator": true}
- VTK Flying Edges (best SMP backend × threads) — vtkImageData + filter pipeline built in prepare (zero-copy wrap, O(1)). vtkStripper joins segments into polylines (required for like-for-like output; MaximumLength unlimited so lines are fully joined) and is timed. variant smp {"backend": "STDThread", "threads": 4}
What changes in an operational pipeline
- Per-cycle cost collapses. Members × parameters × lead times multiply into thousands of contour jobs per cycle. At these speeds they fit on a fraction of one server instead of a cluster.
- On-request isolines. Contour intervals, regions and units become API parameters, computed when asked instead of pre-generated.
- Closed contours that know their high and low. Each closed isobar is tagged by the field as enclosing higher or lower pressure, which is the first step to H/L labels and pressure-centre tracking without re-sampling.
- Fits the existing stack. numpy in, numpy out, so the result plots with matplotlib or serialises to GeoJSON with a few lines of code.