#dataset #net-cdf #file-reader

netcdf3

A pure Rust library for reading and writing NetCDF-3 files

8 releases (4 breaking)

0.6.0 Jul 27, 2025
0.5.2 Feb 14, 2022
0.5.1 Dec 23, 2020
0.4.0 May 27, 2020
0.1.0 Apr 28, 2020

#260 in Rust patterns

Download history 171/week @ 2025-08-08 156/week @ 2025-08-15 226/week @ 2025-08-22 190/week @ 2025-08-29 183/week @ 2025-09-05 308/week @ 2025-09-12 235/week @ 2025-09-19 155/week @ 2025-09-26 199/week @ 2025-10-03 122/week @ 2025-10-10 680/week @ 2025-10-17 353/week @ 2025-10-24 147/week @ 2025-10-31 305/week @ 2025-11-07 196/week @ 2025-11-14 146/week @ 2025-11-21

812 downloads per month
Used in 4 crates (3 directly)

MIT/Apache

555KB
8K SLoC

netcdf3

Crates.io Crates.io Version Documentation Build Status codecov Minimum rustc version

Description

A pure Rust library for reading and writing NetCDF-3 files.

Technical features

  • Define a NetCDF-3 data set :
    • Create, get, rename, and remove global attributes.
    • Create, get, rename, and remove dimensions.
    • Create, get, rename, and remove variables.
    • Create, get, rename, and remove variable attributes.
  • Read a NetCDF-3 file :
    • Read all data of a variable.
    • Read all data of a record (a part of a variable defined on one NetCDF-3 record).
    • Read a slice of data.
    • Read a variable's data into a N-dimensional array (using the crate ndarray).
  • Write a NetCDF-3 file :
    • Write all data of a variable.
    • Write all data of a record (a part of a variable defined on one NetCDF-3 record).
    • Write a slice of data.
    • Write a variable's data from a N-dimensional array (using the crate ndarray).

Notes

  • Validations are done by comparing files produced by this crate and files produced by the Python library netCDF4(see the Python script pyscripts/create_test_nc3_files.py and the Rust test file tests/tests_write_nc3_files.rs).
  • If the number of records numrecs is greater than std::i32::MAX then this value is considered as indeterminate and the actually written value is numrecs = 2^32 - 1(see the File Format Specifications).
  • If the chunk size of a given variable vsize is greater the std::i32::MAX then its value is considered as indeterminate and the actually written value is vsize = 2^32 - 1 (see the File Format Specifications).

Known limitations

  • Cannot read/write a subset of a variable data yet.
  • Cannot rewrite a NetCDF-3 file.

Examples

Various examples are available here.

Dependencies

~1MB
~20K SLoC