Skip to main content

No project description provided

Project description

Gitpod Ready-to-Code

License: GPL v3 CPP17 CI Coverage

CDFpp (CDF++)

A NASA's CDF modern C++ library. This is not a C++ wrapper but a full C++ implementation. Why? CDF files are still used for space physics missions but few implementations are available. The main one is NASA's C implementation available here but it lacks multi-threads support, has an old C interface and has a license which isn't compatible with most Linux distributions policy. There are also Java and Python implementations which are not usable in C++.

List of features and roadmap:

  • read uncompressed file headers
  • read uncompressed attributes
  • read uncompressed variables
  • read variable attributes
  • loads cdf files from memory (std::vector or char*)
  • handles both row and column major files
  • read variables with nested VXRs
  • read compressed file (GZip, RLE)
  • read compressed variables (GZip, RLE)
  • write uncompressed headers
  • write uncompressed attributes
  • write uncompressed variables
  • write compressed attributes
  • write compressed file variables
  • handle leap seconds
  • Python wrappers
  • Documentation
  • Examples
  • Benchmarks

If you want to understand how it works, how to use the code or what works, you may have to read tests.

Installing

From PyPi

pip3 install --user pycdfpp

From sources

meson build
cd build
ninja
sudo ninja install

Basic usage

Python

Basic example from a local file:

import pycdfpp
cdf = pycdfpp.load("some_cdf.cdf")
cdf_var_data = cdf["var_name"].values #builds a numpy view or a list of strings
attribute_name_first_value = cdf.attributes['attribute_name'][0]

Note that you can also load in memory files:

import pycdfpp
import requests
import matplotlib.pyplot as plt
tha_l2_fgm = pycdfpp.load(requests.get("https://spdf.gsfc.nasa.gov/pub/data/themis/tha/l2/fgm/2016/tha_l2_fgm_20160101_v01.cdf").content)
plt.plot(tha_l2_fgm["tha_fgl_gsm"])
plt.show()

Datetimes handling:

import pycdfpp
import os
# Due to an issue with pybind11 you have to force your timezone to UTC for 
# datetime conversion (not necessary for numpy datetime64)
os.environ['TZ']='UTC'

mms2_fgm_srvy = pycdfpp.load("mms2_fgm_srvy_l2_20200201_v5.230.0.cdf")

# to convert any CDF variable holding any time type to python datetime:
epoch_dt = pycdfpp.to_datetime(mms2_fgm_srvy["Epoch"])

# same with numpy datetime64:
epoch_dt64 = pycdfpp.to_datetime64(mms2_fgm_srvy["Epoch"])

# note that using datetime64 is ~100x faster than datetime (~2ns/element on an average laptop)

C++

#include "cdf-io/cdf-io.hpp"
#include <iostream>

std::ostream& operator<<(std::ostream& os, const cdf::Variable::shape_t& shape)
{
    os << "(";
    for (auto i = 0; i < static_cast<int>(std::size(shape)) - 1; i++)
        os << shape[i] << ',';
    if (std::size(shape) >= 1)
        os << shape[std::size(shape) - 1];
    os << ")";
    return os;
}

int main(int argc, char** argv)
{
    auto path = std::string(DATA_PATH) + "/a_cdf.cdf";
    // cdf::io::load returns a optional<CDF>
    if (const auto my_cdf = cdf::io::load(path); my_cdf)
    {
        std::cout << "Attribute list:" << std::endl;
        for (const auto& [name, attribute] : my_cdf->attributes)
        {
            std::cout << "\t" << name << std::endl;
        }
        std::cout << "Variable list:" << std::endl;
        for (const auto& [name, variable] : my_cdf->variables)
        {
            std::cout << "\t" << name << " shape:" << variable.shape() << std::endl;
        }
        return 0;
    }
    return -1;
}

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

pycdfpp-0.2.3-cp310-cp310-win_amd64.whl (906.0 kB view details)

Uploaded CPython 3.10 Windows x86-64

pycdfpp-0.2.3-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (426.2 kB view details)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

pycdfpp-0.2.3-cp310-cp310-macosx_10_15_x86_64.whl (366.3 kB view details)

Uploaded CPython 3.10 macOS 10.15+ x86-64

pycdfpp-0.2.3-cp39-cp39-win_amd64.whl (906.6 kB view details)

Uploaded CPython 3.9 Windows x86-64

pycdfpp-0.2.3-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (426.5 kB view details)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

pycdfpp-0.2.3-cp39-cp39-macosx_10_15_x86_64.whl (366.2 kB view details)

Uploaded CPython 3.9 macOS 10.15+ x86-64

pycdfpp-0.2.3-cp38-cp38-win_amd64.whl (905.2 kB view details)

Uploaded CPython 3.8 Windows x86-64

pycdfpp-0.2.3-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (425.6 kB view details)

Uploaded CPython 3.8 manylinux: glibc 2.17+ x86-64

pycdfpp-0.2.3-cp38-cp38-macosx_10_14_x86_64.whl (365.7 kB view details)

Uploaded CPython 3.8 macOS 10.14+ x86-64

pycdfpp-0.2.3-cp37-cp37m-win_amd64.whl (902.3 kB view details)

Uploaded CPython 3.7m Windows x86-64

pycdfpp-0.2.3-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (429.1 kB view details)

Uploaded CPython 3.7m manylinux: glibc 2.17+ x86-64

pycdfpp-0.2.3-cp37-cp37m-macosx_10_14_x86_64.whl (370.4 kB view details)

Uploaded CPython 3.7m macOS 10.14+ x86-64

File details

Details for the file pycdfpp-0.2.3-cp310-cp310-win_amd64.whl.

File metadata

  • Download URL: pycdfpp-0.2.3-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 906.0 kB
  • Tags: CPython 3.10, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.9 tqdm/4.63.1 importlib-metadata/4.11.3 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.10.2

File hashes

Hashes for pycdfpp-0.2.3-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 e0b887eea87b941b4d43aac1dd477ed3100be879e4608c9caceb1afaaf72e654
MD5 56ac5413172f066743f268c75f0b5d29
BLAKE2b-256 2ac1f0a5d138c2322c4e5ad7ed7dd8c65b400ad27323e4f67b327ce903ece035

See more details on using hashes here.

File details

Details for the file pycdfpp-0.2.3-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

  • Download URL: pycdfpp-0.2.3-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
  • Upload date:
  • Size: 426.2 kB
  • Tags: CPython 3.10, manylinux: glibc 2.17+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.9 tqdm/4.63.1 importlib-metadata/4.11.3 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.10.2

File hashes

Hashes for pycdfpp-0.2.3-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 0dae9107e5e0889e12197aeaccdc5e1fbea98fd6486c2da743f91d1f46889a47
MD5 79e31b49ce4b136fabdbf020c7843550
BLAKE2b-256 b7ca484213f88ab57023c55616de3f38e0696d972d4594f34c347b18e6f05a82

See more details on using hashes here.

File details

Details for the file pycdfpp-0.2.3-cp310-cp310-macosx_10_15_x86_64.whl.

File metadata

  • Download URL: pycdfpp-0.2.3-cp310-cp310-macosx_10_15_x86_64.whl
  • Upload date:
  • Size: 366.3 kB
  • Tags: CPython 3.10, macOS 10.15+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.9 tqdm/4.63.1 importlib-metadata/4.11.3 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.10.3

File hashes

Hashes for pycdfpp-0.2.3-cp310-cp310-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 3611eb583ab6a3d1c3588fd6f46fbe00f8fe96ac9fa16cdfe20a3ce080d7d23b
MD5 a10e3fe56aa414df30549a21d19851f0
BLAKE2b-256 cb6fbfece1b16f730619ed408c9f1aae1e63eaacf6d35d3c7fc400065a348453

See more details on using hashes here.

File details

Details for the file pycdfpp-0.2.3-cp39-cp39-win_amd64.whl.

File metadata

  • Download URL: pycdfpp-0.2.3-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 906.6 kB
  • Tags: CPython 3.9, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.9 tqdm/4.63.1 importlib-metadata/4.11.3 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.10

File hashes

Hashes for pycdfpp-0.2.3-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 6d5aa665eea1aaebe332b4c239f2a57723e07c952836edac4f49af6f22aa2497
MD5 7f465ca9b51996e5de22313363c9da61
BLAKE2b-256 e56515c697533e3718f93b2418e185fab52aa1d3a89da089b0947e0afc4b3cce

See more details on using hashes here.

File details

Details for the file pycdfpp-0.2.3-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

  • Download URL: pycdfpp-0.2.3-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
  • Upload date:
  • Size: 426.5 kB
  • Tags: CPython 3.9, manylinux: glibc 2.17+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.9 tqdm/4.63.1 importlib-metadata/4.11.3 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.10.2

File hashes

Hashes for pycdfpp-0.2.3-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 47dcb0a01fbf4f9844febb267ae74b606831cf8bf6d82cd80d26dd72dfceaf3e
MD5 579b44d066702d46b5b27e6e4c8857aa
BLAKE2b-256 e126f9ace5ea0a26edec633e09d1218cd5739aa9d21125857de24324cbd0453a

See more details on using hashes here.

File details

Details for the file pycdfpp-0.2.3-cp39-cp39-macosx_10_15_x86_64.whl.

File metadata

  • Download URL: pycdfpp-0.2.3-cp39-cp39-macosx_10_15_x86_64.whl
  • Upload date:
  • Size: 366.2 kB
  • Tags: CPython 3.9, macOS 10.15+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.9 tqdm/4.63.1 importlib-metadata/4.11.3 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.11

File hashes

Hashes for pycdfpp-0.2.3-cp39-cp39-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 16ec5387ddfec8bdd0a726ce35ee5aa4f4434935cc3cc469f90c9b743f43305c
MD5 c77cd03e7c4215476410072f2bd8ec9c
BLAKE2b-256 a432dd7b07b42a04ab1e63374c3787e5c4fea7fbd749f98753317ccdca0baf02

See more details on using hashes here.

File details

Details for the file pycdfpp-0.2.3-cp38-cp38-win_amd64.whl.

File metadata

  • Download URL: pycdfpp-0.2.3-cp38-cp38-win_amd64.whl
  • Upload date:
  • Size: 905.2 kB
  • Tags: CPython 3.8, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.9 tqdm/4.63.1 importlib-metadata/4.11.3 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.8.10

File hashes

Hashes for pycdfpp-0.2.3-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 15d2b698f292deebeddb68d72853b5c5ef1b604100fb7c66d7208d9935035c27
MD5 bdf85ea42aea1f89dca59e992ba5d14f
BLAKE2b-256 c89dba7bbb204fdd8bebb4bbd2421017af9227426b2efe7c641b6bbf1c2d514e

See more details on using hashes here.

File details

Details for the file pycdfpp-0.2.3-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

  • Download URL: pycdfpp-0.2.3-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
  • Upload date:
  • Size: 425.6 kB
  • Tags: CPython 3.8, manylinux: glibc 2.17+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.9 tqdm/4.63.1 importlib-metadata/4.11.3 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.10.2

File hashes

Hashes for pycdfpp-0.2.3-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 8d888c96eccb761fcaab41af1f552bfe4f4e3f0a4079cc0a0f38476b0071044c
MD5 96fd12644e6492d6530200f85401a651
BLAKE2b-256 227b037f343075c7b6c9d6ffa02bd4a979c83a382bd405170b6eb25808e32de7

See more details on using hashes here.

File details

Details for the file pycdfpp-0.2.3-cp38-cp38-macosx_10_14_x86_64.whl.

File metadata

  • Download URL: pycdfpp-0.2.3-cp38-cp38-macosx_10_14_x86_64.whl
  • Upload date:
  • Size: 365.7 kB
  • Tags: CPython 3.8, macOS 10.14+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.9 tqdm/4.63.1 importlib-metadata/4.11.3 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.8.12

File hashes

Hashes for pycdfpp-0.2.3-cp38-cp38-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 5046af61adc6cd445c1277e89e910c2543afba42c7828d838130287cc47daab9
MD5 86d505599299a0f11f2c610b45894554
BLAKE2b-256 50250a4da248c66704b5ce9b3ba06ed8ce94a05e35eefe1c4dc2bf9e7c50d3bf

See more details on using hashes here.

File details

Details for the file pycdfpp-0.2.3-cp37-cp37m-win_amd64.whl.

File metadata

  • Download URL: pycdfpp-0.2.3-cp37-cp37m-win_amd64.whl
  • Upload date:
  • Size: 902.3 kB
  • Tags: CPython 3.7m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.9 tqdm/4.63.1 importlib-metadata/4.11.3 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.7.9

File hashes

Hashes for pycdfpp-0.2.3-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 540f1dc1cfc0179f9d83b77e08285832d2bc1d6805f1064d9c57a265129ef00c
MD5 bb142233717705ff6afd3640d5895b96
BLAKE2b-256 c9c3b4a83973d4980406cb4244697cfa2d5352a89b4f62f808bbae63ca2bc0d2

See more details on using hashes here.

File details

Details for the file pycdfpp-0.2.3-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

  • Download URL: pycdfpp-0.2.3-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
  • Upload date:
  • Size: 429.1 kB
  • Tags: CPython 3.7m, manylinux: glibc 2.17+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.9 tqdm/4.63.1 importlib-metadata/4.11.3 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.10.2

File hashes

Hashes for pycdfpp-0.2.3-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 1e382aefe89f9b772dc488cf26e9c56fd381ec6527960931ba95e0fdd2022ad6
MD5 7e66850e61cce1d8b11416ab43b267d2
BLAKE2b-256 7a5d8166cb31153fb928fee6f6962242348fdd7109dca06aa52d81a8d6309d54

See more details on using hashes here.

File details

Details for the file pycdfpp-0.2.3-cp37-cp37m-macosx_10_14_x86_64.whl.

File metadata

  • Download URL: pycdfpp-0.2.3-cp37-cp37m-macosx_10_14_x86_64.whl
  • Upload date:
  • Size: 370.4 kB
  • Tags: CPython 3.7m, macOS 10.14+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.9 tqdm/4.63.1 importlib-metadata/4.11.3 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.7.12

File hashes

Hashes for pycdfpp-0.2.3-cp37-cp37m-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 042ed9d12b9117fa81edbb21b2c318db56c8c5a110e1e1ce33e149ea13405e2e
MD5 fefe4b320039602ed6b09b16c1f84d6d
BLAKE2b-256 c82b855f15ee650b00e15dcdae37c1dc1c95d75835a7ebf72a7227d82b2cc579

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page