A modern, from-scratch C++20 implementation of NASA's CDF (Common Data Format) with full Python bindings.
Why another CDF library? NASA's official C implementation has no multi-thread support (global shared state), an aging C89 interface, and a license incompatible with most Linux distribution policies. CDFpp solves all three: it is thread-safe, idiomatic C++20, and MIT-licensed.
- C++20 library, mostly headers
- Complete read/write support — CDF versions 2.2 through 3.x, row and column major, compressed files and variables (GZip, RLE)
- Python bindings (
pycdfpp) via pybind11 — zero-copy NumPy integration, GIL-free I/O
- SIMD-accelerated time conversions — AVX512/AVX2/SSE2 runtime dispatch for TT2000, EPOCH, EPOCH16
- Lazy loading — variable data is read on first access, not at file open
- Read files where they live —
pycdfpp.load("s3://…") reads only the byte ranges it needs, through fsspec or your own byte-range reader, instead of downloading the file
- Drop-in
cdflib replacement — replace import cdflib with import pycdfpp.cdflib as cdflib and your cdflib code runs on pycdfpp, unchanged. For a library you can't edit, such as SunPy, call pycdfpp.cdflib.install() before importing it: its own import cdflib then gets pycdfpp's version too
- Fast — 5.6× to several hundred times faster than spacepy and cdflib at reading, 3.7× to 14× at writing compressed files; SIMD time conversions at up to 8 billion epochs/s (TT2000, AVX-512)
- Runs everywhere — Linux, Windows, macOS (x86_64 + ARM64), and WebAssembly (Pyodide / emscripten-forge)
CDFpp compiles to
WebAssembly, so the whole library runs client-side — no install, no server, and your files never leave your machine.
CDFpp Explorer is a small web app built on it:
- Inspect — browse variables and attributes grouped by ISTP
VAR_TYPE, with live search and a value preview
- Plot — line plots and spectrograms, ISTP-aware (
DEPEND_0 time axis, DISPLAY_TYPE, SCALETYP, fill/valid masking), with CSV / JSON export
- Validate — hand the file to AstraLint for ISTP conformance checking
The WebAssembly wrapper lives in
wacdfpp/ and ships TypeScript declarations (
wacdfpp/cdfpp.d.ts) for embedding CDF read/write — with zero-copy typed arrays — in your own JavaScript app.