No project description provided
Project description
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distributions
Hashes for pycdfpp-0.2.1-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3afc10d8baa6941b85e4b63f68be37b967c5a11286d237a8836dbbca15bce71e |
|
MD5 | 6a3387451c8cbf701d0ed5579db62c3f |
|
BLAKE2b-256 | 3cfc2e800d6d6815605dfb76f36fd3cf8cf57579b55e8a75ad986caaede66044 |
Hashes for pycdfpp-0.2.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5e6ddfd82e20e465f79130cbc07a043896835c56aca9d7a40eb7c3b033cf6b11 |
|
MD5 | 1f8a20cb496940dd78bae4bb06b81c54 |
|
BLAKE2b-256 | f622291a137a9fc1257f3313db0ae7469db7eaa7ea03c5187734ca383fbdb32b |
Hashes for pycdfpp-0.2.1-cp310-cp310-macosx_10_15_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 40737b180e469beddde92b2f5f2736088fd718b0a2e61682ea3e57a94b9f78e8 |
|
MD5 | 691afd0699c3680d2c46c3d9ce1b6f1b |
|
BLAKE2b-256 | 63cd5bf392cbeba709841d7786d25bf9269cb9baf1309d08ca5f21a65edadf04 |
Hashes for pycdfpp-0.2.1-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a35440c3afed167556a0bfcfde913da2f3e2a7436bb4fc5d49c3617f78369ed6 |
|
MD5 | b3240ff4c6804d89dee87551c2592a79 |
|
BLAKE2b-256 | 9ac18141e977d1afacf98a7ed326480d0189505c2015082d6bde755eea133d15 |
Hashes for pycdfpp-0.2.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d9fce56b05cba0640b50d633e97a32bee2ba7aadb2804ab49738e25f07286428 |
|
MD5 | 0b92fe9b96040537770c755ad36f866f |
|
BLAKE2b-256 | 94f0e70871d89a2da2ad945397bf217e48c225d6762f1657bd6c0f429444e77d |
Hashes for pycdfpp-0.2.1-cp39-cp39-macosx_10_15_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | deda1c2234fb5f5175cd3dd475c5aaa337f809068b9eaaf0bc8f921c09cb7564 |
|
MD5 | 59771ae72bf8133685cfbad96ecd7d64 |
|
BLAKE2b-256 | a1979ca705873eafa4d0dbbc9b6433091c74e0cffe13f139f38cbb10b7b975d7 |
Hashes for pycdfpp-0.2.1-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 127cbc3529c875bfde5a982f7805346b456c7355314f0d40ba59eb070772d381 |
|
MD5 | 6d84eeebda5088fe4c870029b46a5d30 |
|
BLAKE2b-256 | 6f27344564c35be4cfa760055e17c098ba7a2afde1347ba03f56f6dd3cd7ba69 |
Hashes for pycdfpp-0.2.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8991d57815e517cad19081c50b77542120c8e20811592363b6691c6b658ea006 |
|
MD5 | 566d624e0065302a5dabd8f74bb9ba07 |
|
BLAKE2b-256 | d3cef197048ea7e107be65b0c335d06837ef0902e1b9028b679a806a5e7adf3d |
Hashes for pycdfpp-0.2.1-cp38-cp38-macosx_10_14_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 12a9c2cd1fe6c28832ace250a7a6e003b3b97f2e34d30b13d4793594cb0b1ff9 |
|
MD5 | 09a6f144a3b4f8aefc780e9577415b5a |
|
BLAKE2b-256 | 0c0d91a27924d87c811c1084b0fd3d253e4f4eeefcecc5c76c4a2281442c6aca |
Hashes for pycdfpp-0.2.1-cp37-cp37m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 80a870dce003b4f68a9746c8346ac2c2a1a1faf9e41e34b189f55d7b08099b7f |
|
MD5 | c2c348f4e60c32931cb2bd64e306a17a |
|
BLAKE2b-256 | 4673cad19348927be6a2052e43eb196c194c42e575c8f2a3a44e19b7413b4f55 |
Hashes for pycdfpp-0.2.1-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4269f5d479f6ddc7b15dc6179a4b0c4ebc57a80845380a0571fcde9f6d149f13 |
|
MD5 | 17be5eeab331e81bf7188a8906df57bd |
|
BLAKE2b-256 | 83405a050711b68a93ce57012e8d1166e40552b064747a973918455c63628c85 |
Hashes for pycdfpp-0.2.1-cp37-cp37m-macosx_10_14_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 76d0d471df1901620115fe858b08de90ac4c0f1acbe699b77a9b4b586136ad03 |
|
MD5 | 30c548a08fcb94e3e0949234d79d055e |
|
BLAKE2b-256 | d5f33961368e92d6b0ba24d598f78db64ae70cb4622da41235af71cb5e6587ab |