CDFpp

Read and write NASA CDF files, fast, from Python, C++ or your browser.

CDF (Common Data Format) is the file format most space physics missions use to distribute their data. CDFpp is a modern implementation of it, written from scratch in C++20. Its Python package is called pycdfpp.

import urllib.request
import pycdfpp

url = ("https://spdf.gsfc.nasa.gov/pub/data/ace/mag/level_2_cdaweb/"
       "mfi_h0/2020/ac_h0_mfi_20200101_v07.cdf")
cdf = pycdfpp.load(urllib.request.urlopen(url).read())

field = cdf["BGSEc"].values                  # a numpy array, shape (5401, 3)
time = pycdfpp.to_datetime64(cdf["Epoch"])   # numpy datetime64
$ pip install pycdfpp

What do you want to do?

🔭 Read CDF files

You are a scientist. You have CDF files from a mission archive and want the data in numpy, xarray or pandas.

Start with the Quickstart, then Reading files.

Reading files
🛰️ Produce CDF files

You work on a ground segment or instrument team. You need to write clean, ISTP-compliant CDF files that other people and tools can read.

Read CDF in plain words, then Writing files and Producing ISTP-compliant files. Have a master CDF? See Starting from a master CDF.

Writing files
⚙️ Use CDFpp from C++

CDFpp is a C++20 library, made mostly of headers. No global state, so it is safe to use from many threads.

Go to the C++ guide.

C++ guide
🌐 No install: use your browser

Open, plot, validate and compare CDF files in the CDFpp Explorer. Your files never leave your machine.

See CDFpp Explorer.

CDFpp Explorer

Why CDFpp?

  • Fast. Files open instantly: data is only read when you ask for it. Reading runs at up to ~4 GB/s, and time conversions use SIMD instructions. On everyday tasks it is 2.8× to several hundred times faster than spacepy and cdflib: see Performance.

  • Complete. Reads and writes CDF versions 2.2 to 3.x, row and column major files, gzip and RLE compressed files and variables, and all CDF data types, including the three time types.

  • Thread-safe. NASA’s C library keeps global state, so it cannot safely be used from several threads. CDFpp can.

  • Easy to install. pip install pycdfpp ships ready-made packages for Linux, Windows and macOS (Intel and ARM). No compiler, no NASA library needed.

  • Permissive license. MIT, so it fits in any project and any Linux distribution.