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.1-cp310-cp310-win_amd64.whl (918.0 kB view details)

Uploaded CPython 3.10 Windows x86-64

pycdfpp-0.3.1-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.1-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.1-cp39-cp39-win_amd64.whl (917.9 kB view details)

Uploaded CPython 3.9 Windows x86-64

pycdfpp-0.3.1-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.1-cp39-cp39-macosx_10_15_x86_64.whl (372.3 kB view details)

Uploaded CPython 3.9 macOS 10.15+ x86-64

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

Uploaded CPython 3.8 Windows x86-64

pycdfpp-0.3.1-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.1-cp38-cp38-macosx_10_14_x86_64.whl (371.9 kB view details)

Uploaded CPython 3.8 macOS 10.14+ x86-64

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

Uploaded CPython 3.7m Windows x86-64

pycdfpp-0.3.1-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.1-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.1-cp310-cp310-win_amd64.whl.

File metadata

  • Download URL: pycdfpp-0.3.1-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.4

File hashes

Hashes for pycdfpp-0.3.1-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 b833b408acfb4c97c2b53a94fd6db03e7a24621601360edbcb320fb49e5e6d3f
MD5 4719d08114ec4965f4eb6763a3747a89
BLAKE2b-256 0be54417cf397caa9df1378eec93820d39cc77cd290de85f3afa9fe41c82d02b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pycdfpp-0.3.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 d0bea555c4c677bd7a3f62219d0d4a17408e4f6a18998ba300c6918f03e40d01
MD5 79b8e68a9dc446ce2bb527bf068d5d51
BLAKE2b-256 2946859d150060d2c8d779201625cf5fb59ea73bd8e5c11e731fa35ff103db8a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pycdfpp-0.3.1-cp310-cp310-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 dff38ab0dee4550c07af3c67b2dc45f90fa7a51fc7639d5c9f66348e464a554f
MD5 be68509ed70989b417b6b623d64d381f
BLAKE2b-256 03a5abcdc23cfa3e329e59f7c67c607ec78d7e7d1153d1dc3cb39610cd3e2e52

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pycdfpp-0.3.1-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.12

File hashes

Hashes for pycdfpp-0.3.1-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 c06c806066bb0889484cccb3675a2d100d1af8e5bb5fdc21802a182894952d82
MD5 ce3a6052c38ecc481f6bbdbadd035003
BLAKE2b-256 4d4425849c0c75eaef14b86eb441144325deff33f7cc3296ce3cc7fa618b5086

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pycdfpp-0.3.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 e768d83df66a93a271b28d44e199b07bf9722296aae5730363e06c442d27c959
MD5 74ff2832458c6bfeb873300fa195949a
BLAKE2b-256 dc423a4d4e08fc97125a43843a56870c87fccb3d2d81c419ec80e5643fe84549

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pycdfpp-0.3.1-cp39-cp39-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 82bca4d6c67199a4f197412767d018b7fe7494de757963d191cb955d687ade96
MD5 0ba4b62a69324c9ba4aa7d17c95abffd
BLAKE2b-256 583756b9f406589882c24857433bdbfcaba77d5252b4fda4b7ce5b3bfcf41afe

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pycdfpp-0.3.1-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.1-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 5725c6b2b3afddd527ba7e2ed2a08a61ceb279e04d0ff55cad034f6be8a698ad
MD5 5a3ee1982fcd931eb38f38258fe55be3
BLAKE2b-256 982c9ed0deeb05bb68f5be8e1e32c08b9b042e17e3033bdb21717d53d4401e21

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pycdfpp-0.3.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 8fef7fbc1c3be2ecadfef4fac1741df60cbb0f77637a8cea7969a3d7042c383a
MD5 64470b1f79f46ff47a4b0d0a3772b156
BLAKE2b-256 13e98a7ee1947e645f61f86d17d357d077b88ff056e23f7ee0847ca8fca6e43b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pycdfpp-0.3.1-cp38-cp38-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 782eff51a9707ea0c8e8104896d3c3cf5a5b761778e37cb1b29442f5f1e566fb
MD5 51cacccf210fe52923478d49c9117910
BLAKE2b-256 8816cb9e5ee1270dc3cfd64aaaffa1b79aa4a12f06e122edd56408f97e798a97

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pycdfpp-0.3.1-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.1-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 22cf5f1e30de43b4123884b7577ca3ba011f59e762eee2b142825a9b4cf79ab3
MD5 4da8e65aa1a3d02becdb3ada49580d9d
BLAKE2b-256 464b1407dd1627c129bbdeae6d894f1bc9e09ee47e818f5fc8ae2d69ce8d9579

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pycdfpp-0.3.1-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 076ea9a8e5bf46d7a2f0c2e10c63a70b2397987dd6ab78079c7a4022fd2b034f
MD5 3839430e9372567d3c1efcfa20869503
BLAKE2b-256 8dcd6c5ffdca061f911fe6d4bec3de4e9dc2f7107d12c4898c12e49fafdcfd45

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pycdfpp-0.3.1-cp37-cp37m-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 c348b1ca36a759b50ee7b6a9a90fab99a717b2646098c765f2ceb698490508f2
MD5 698f1af111bf0d99492d6bf76f560617
BLAKE2b-256 dbf5fd61902dba4968b9d203d00550bae0b626e22ddd2e8b429af079440ec0da

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