Skip to main content

No project description provided

Project description

License: GPL v3 CPP17 All OS test matrix Discover on MyBinder 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.3.0-cp310-cp310-win_amd64.whl (918.0 kB view details)

Uploaded CPython 3.10 Windows x86-64

pycdfpp-0.3.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (435.4 kB view details)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

pycdfpp-0.3.0-cp310-cp310-macosx_10_15_x86_64.whl (372.1 kB view details)

Uploaded CPython 3.10 macOS 10.15+ x86-64

pycdfpp-0.3.0-cp39-cp39-win_amd64.whl (917.9 kB view details)

Uploaded CPython 3.9 Windows x86-64

pycdfpp-0.3.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (436.0 kB view details)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

pycdfpp-0.3.0-cp39-cp39-macosx_10_15_x86_64.whl (372.2 kB view details)

Uploaded CPython 3.9 macOS 10.15+ x86-64

pycdfpp-0.3.0-cp38-cp38-win_amd64.whl (917.4 kB view details)

Uploaded CPython 3.8 Windows x86-64

pycdfpp-0.3.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (433.6 kB view details)

Uploaded CPython 3.8 manylinux: glibc 2.17+ x86-64

pycdfpp-0.3.0-cp38-cp38-macosx_10_14_x86_64.whl (371.8 kB view details)

Uploaded CPython 3.8 macOS 10.14+ x86-64

pycdfpp-0.3.0-cp37-cp37m-win_amd64.whl (913.3 kB view details)

Uploaded CPython 3.7m Windows x86-64

pycdfpp-0.3.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (438.3 kB view details)

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

pycdfpp-0.3.0-cp37-cp37m-macosx_10_14_x86_64.whl (376.1 kB view details)

Uploaded CPython 3.7m macOS 10.14+ x86-64

File details

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

File metadata

  • Download URL: pycdfpp-0.3.0-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 918.0 kB
  • Tags: CPython 3.10, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.10.2

File hashes

Hashes for pycdfpp-0.3.0-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 4bd15574c46ab9f17860d979a8a5ebf0593574b5faf1ed68a8e5b8a5701fa293
MD5 2ebddf6803e83bd873fb7713029bd41b
BLAKE2b-256 f245949ffed5f753b61ed3b05a099a927e24d7b1a611f6af9b8d81cf4fac2b96

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pycdfpp-0.3.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 6ce72c5a96e35bfe48d3215fb47c05e095a7fedac046d5ac83ea232e4c0323e6
MD5 33b4aa819e969675a2ecd37fce5a26d5
BLAKE2b-256 4c5970ab00a58473757941d6a42b3e6401fdde13c98be66f813df3433401f4ed

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pycdfpp-0.3.0-cp310-cp310-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 88fa7785996f94a57549dcff036e02f25e50365ee154c629e79b5e9dd6fa4341
MD5 b24a331d59b68814bce13427ff70bdab
BLAKE2b-256 df940e6a4d8b0ecb900325d334496ddf0f6b6044bfc86031a00f811a2437211d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pycdfpp-0.3.0-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 917.9 kB
  • Tags: CPython 3.9, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.9.10

File hashes

Hashes for pycdfpp-0.3.0-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 0d835828714354c96bfa5de8ef2a93f377822d5acf68547d7a2fe2a58f45549e
MD5 06f7eef58509b2730e194207fb506edf
BLAKE2b-256 5ebb843bc0cdd5f853dd77f9b1abc40589180f6f7a52d1be8075348d5d5d1181

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pycdfpp-0.3.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 85b0c799cff4320ac6934bfec01b5f5b3145c5507cd4d72c5b29a821ad4040c9
MD5 b3dc96000407435b995fccc9b69d87c9
BLAKE2b-256 d3c2817847121b61c613b9a61c8f1999184c1f62a36d952209538c544bf461bd

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pycdfpp-0.3.0-cp39-cp39-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 7970b93e0ccbbbd8cf1b8454c8f9f3553974e048ab7d8f1f87f7b5f0db0877f2
MD5 0902c9cb748717d7dae0e23ef8eab992
BLAKE2b-256 58f6e50e516682fc1353a8430f22e366a5bb507a469a864b37eea381e4b122ef

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pycdfpp-0.3.0-cp38-cp38-win_amd64.whl
  • Upload date:
  • Size: 917.4 kB
  • Tags: CPython 3.8, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.8.10

File hashes

Hashes for pycdfpp-0.3.0-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 42fe2ecd8b9e416fb919477eb2a81dbdcbdd72d45807642529d8b472397d54e4
MD5 259e0d487de431d23c55f5e4857f11aa
BLAKE2b-256 ecebdc4ebafa3b6db564d2dd3aff854e31417a095cad949845213f69f7a71bbb

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pycdfpp-0.3.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 6f7f13bd872e93aae6ecb008aab19c96f3b3948ac56ea9f3bbec17629b18f423
MD5 1c98bf8d6b05b78903bdbb8b21a0e4b1
BLAKE2b-256 01851ae66d201d95058fa7766b5b824e72c80be48542f46451a85ef618ee60fe

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pycdfpp-0.3.0-cp38-cp38-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 2181785436f27210283f821ec59ee24fe22d7125db0771aa3a6dd9f24253e6ed
MD5 25a4c6855933328302d6a37c6e4b3db9
BLAKE2b-256 0985db31dc859cad636753a4d37009c32fa51b7e4a8610ddc135e28f970166d0

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pycdfpp-0.3.0-cp37-cp37m-win_amd64.whl
  • Upload date:
  • Size: 913.3 kB
  • Tags: CPython 3.7m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.7.9

File hashes

Hashes for pycdfpp-0.3.0-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 c3ffbb5a19349b65da150c0ca142421c56faca7107f91740bbc58c42b17662be
MD5 b3c9aa6b081e68e2400f554335765567
BLAKE2b-256 fad591f19d01dd656907b1f63fb1045e1597e18cd0bb8c6cd4580361f0b73ccd

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pycdfpp-0.3.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 dd0e7e15c342455dd0e230b9e7a121196d41b731ca55637de222e522338a4113
MD5 0cd3cbdc5784ced8dda9e66ef73aafac
BLAKE2b-256 b4ad63b28323c36951d51bd8da6beebbc636c0bad893fb7ec1b87ea89239a5cb

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pycdfpp-0.3.0-cp37-cp37m-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 fd8d73e1acf005e1d5bceee4549574f3c29ac324080932e82ffeadd66b48b480
MD5 50824ae7647919e332d702c952689eaa
BLAKE2b-256 cc59c18034d68c4ecbb7edb77b55d4660e0baf805168e2b51d1117fb39fcfd88

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