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()

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.2-cp310-cp310-macosx_10_15_x86_64.whl (366.0 kB view details)

Uploaded CPython 3.10 macOS 10.15+ x86-64

pycdfpp-0.2.2-cp39-cp39-macosx_10_15_x86_64.whl (365.9 kB view details)

Uploaded CPython 3.9 macOS 10.15+ x86-64

pycdfpp-0.2.2-cp38-cp38-macosx_10_14_x86_64.whl (365.5 kB view details)

Uploaded CPython 3.8 macOS 10.14+ x86-64

pycdfpp-0.2.2-cp37-cp37m-macosx_10_14_x86_64.whl (370.1 kB view details)

Uploaded CPython 3.7m macOS 10.14+ x86-64

File details

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

File metadata

  • Download URL: pycdfpp-0.2.2-cp310-cp310-macosx_10_15_x86_64.whl
  • Upload date:
  • Size: 366.0 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.2-cp310-cp310-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 5bfcde699bd397e55d9dde1c5598cc8732b5ca5ee6988ce0584ff8d7ab9f2ec7
MD5 2163ed0f502e43c95ee1d43c32809382
BLAKE2b-256 46b6acc57fa9322a8448158136b566bd68fe89bb611e9984ecbf56db948aec6c

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pycdfpp-0.2.2-cp39-cp39-macosx_10_15_x86_64.whl
  • Upload date:
  • Size: 365.9 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.2-cp39-cp39-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 be610117b4b55c4a969e08d36169a60b5cff4ac00998aceb615d8a08cd59bd95
MD5 910bf74e332e8c1713d7e22fb1cbf2e5
BLAKE2b-256 a45d2353e7af2036368b021b4d1be33bda838024bdabfbf4d9ffe42fb1e07e5a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pycdfpp-0.2.2-cp38-cp38-macosx_10_14_x86_64.whl
  • Upload date:
  • Size: 365.5 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.2-cp38-cp38-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 d242d8299c61789559bc27adaf114c9c9cd86de2ce9f55c2505143c1054b9f9b
MD5 3afb504fc9fb0c6948b1629b9acd7c83
BLAKE2b-256 ee5273ba6735e8b45b74e14937f9a45d759d22c1645eb56b4f37b123b8d66962

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pycdfpp-0.2.2-cp37-cp37m-macosx_10_14_x86_64.whl
  • Upload date:
  • Size: 370.1 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.2-cp37-cp37m-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 de96e0f1a2f57aee6792ffa08897e81250d82631fc5f804b9afcea518783f2f3
MD5 2d17ae99cb0bfec6eba8da7ada1767c9
BLAKE2b-256 fadf75ba15cb529908bd1199e196ecc86ed5e9f1bd0b799045e302aacd8d9e37

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