27 releases

0.10.5 Aug 20, 2024
0.9.3 May 20, 2024
0.9.1 Mar 28, 2024
0.8.3 Oct 8, 2023
0.1.0 Jun 27, 2015

#120 in Network programming

Download history 934/week @ 2024-07-27 1248/week @ 2024-08-03 1218/week @ 2024-08-10 657/week @ 2024-08-17 557/week @ 2024-08-24 685/week @ 2024-08-31 726/week @ 2024-09-07 1010/week @ 2024-09-14 927/week @ 2024-09-21 425/week @ 2024-09-28 628/week @ 2024-10-05 644/week @ 2024-10-12 1085/week @ 2024-10-19 1281/week @ 2024-10-26 1168/week @ 2024-11-02 1195/week @ 2024-11-09

4,812 downloads per month
Used in 15 crates (10 directly)

MIT/Apache

305KB
8K SLoC

netcdf

Docs Build Status Crates.io codecov Crates.io

Medium-level netCDF bindings for Rust, allowing easy reading and writing of array-like structures to a file. netCDF can read and write hdf5 files, which is a commonly used file format in scientific computing.

Status

Supported:

  • Variables
  • Normal Dimensions
  • Attributes
  • Subgroups
  • Open/Append/Create modes
  • Reading from memory
  • Unlimited dimensions
  • User defined types, using the feature derive (enum, compound, other types requires additional work)

Not (yet) supported (PRs welcome):

  • Writing using memory-mapped file

All variable data is read into a contiguous buffer, or into an ndarray if the ndarray feature is activated.

Building

This crate depends on libnetcdf, but a static build from source is also supported, which can be enabled using the static feature.

The crate is built on several platforms using github actions, and is currently known to build form from source on all major platforms (linux, macos, windows (gnu+msvc)), and through the package installers conda and apt.

If during compilation there is an error in building the hdf5 crate, consider using the static feature which will include a compatible version of both netcdf and hdf5. This is likely to be an issue upstream.

Building without libnetcdf or building statically

  1. git clone https://github.com/georust/netcdf
  2. git submodule update --init --recursive
  3. cargo build --features static

Documentation

Some examples of usage can be found in the tests/lib.rs file. The documentation can also be generated using cargo doc.

Thread safety

The netcdf crate is thread-safe, although the netcdf-c library is not itself threadsafe. To render a safe interface, a global mutex is used to serialize access to the underlying library. Consider using a non threadsafe version of hdf5 to avoid double locking (performance consideration).

Use of netcdf-sys is not thread-safe. Users of this library must take care that calls do not interfere with simultaneous use of e.g. netcdf or hdf5-sys. Use the lock provided by netcdf-sys to serialise access to the hdf5 and netCDF libraries.

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Dependencies

~3–16MB
~226K SLoC