rust-netcdf

Build Status

High-level NetCDF bindings for Rust

Status

Not (yet) supported: appending to existing files (using unlimited dimensions), user defined types, string variables, multi-valued attributes, strided/subsetted reads. All variable data is read into a 1-dimensional Vec with the last variable dimension varying fastest.

Building

rust-netcdf depends on libnetcdf.

Read Example

```Rust // Open file simplexy.nc: let file = netcdf::open(&pathtosimplexy).unwrap();

// Access any variable, attribute, or dimension through simple HashMap's: let var = file.root.variables.get("data").unwrap();

// Read variable as any NCTYPE, optionally failing if doing so would // force a cast: let data : Vec = var.getint(false).unwrap();

// All variable data is read into 1-dimensional Vec. for x in 0..(6*12) { assert_eq!(data[x], x as i32); } ```

Write Example

```Rust let f = netcdf::testfilenew("crabs.nc"); // just gets a path inside repo

let mut file = netcdf::create(&f).unwrap();

let dimname = "ncrabs"; file.root.adddimension(dim_name, 10).unwrap();

let varname = "crabcoolnesslevel"; let data : Vec = vec![42; 10]; // Variable type written to file is inferred from Vec type: file.root.addvariable( varname, &vec![dimname.to_string()], &data ).unwrap(); ```

Documentation

I intend to improve documentation soon. For now, check out tests/lib.rs for quite a few usage examples.