dotthz

Crates.iodotthz
lib.rsdotthz
version
sourcesrc
created_at2024-11-14 16:38:48.063786+00
updated_at2025-02-21 15:31:05.451044+00
descriptionCrate to open and write dotThz files in rust.
homepagehttps://github.com/hacknus/dotthz-rs
repositoryhttps://github.com/hacknus/dotthz-rs
max_upload_size
id1448014
Cargo.toml error:TOML parse error at line 18, column 1 | 18 | autolib = false | ^^^^^^^ unknown field `autolib`, expected one of `name`, `version`, `edition`, `authors`, `description`, `readme`, `license`, `repository`, `homepage`, `documentation`, `build`, `resolver`, `links`, `default-run`, `default_dash_run`, `rust-version`, `rust_dash_version`, `rust_version`, `license-file`, `license_dash_file`, `license_file`, `licenseFile`, `license_capital_file`, `forced-target`, `forced_dash_target`, `autobins`, `autotests`, `autoexamples`, `autobenches`, `publish`, `metadata`, `keywords`, `categories`, `exclude`, `include`
size0
(hacknus)

documentation

https://docs.rs/dotthz-rs

README

Interface with dotThz files using rust

crates.io Docs Rust

This crate provides an easy way to interface with dotThz files in rust.

Load it in your cargo.toml

[dependencies]
dotthz-rs = "0.2.8"

and then use like specified in the following example:

use std::path::PathBuf;
use dotthz::{DotthzFile};

fn main() {
    // Load data from the original file
    let file_path = PathBuf::new("test_files/2_VariableTemperature.thz");
    let file = DotthzFile::create(&file_path);
    
    // Initialize test metadata
    let meta_data = DotthzMetaData {
        user: "Test User".to_string(),
        email: "test@example.com".to_string(),
        orcid: "0000-0001-2345-6789".to_string(),
        institution: "Test Institute".to_string(),
        description: "Test description".to_string(),
        md: [("Thickness (mm)".to_string(), "0.52".to_string())]
            .into_iter()
            .collect(),
        ds_description: vec!["ds1".to_string()],
        version: "1.0".to_string(),
        mode: "Test mode".to_string(),
        instrument: "Test instrument".to_string(),
        time: "12:34:56".to_string(),
        date: "2024-11-08".to_string(),
    };

    // create a group with metadata
    let mut original_dotthz = DotthzFile::create(&path)?;
    let group_name = "Measurement".to_string();
    original_dotthz.add_group(&group_name, &meta_data)?;

    // write data
    let dataset_name = "test_dataset".to_string();
    let dataset_data: Array2<f32> = array![[1.0, 2.0], [3.0, 4.0], [3.0, 4.0]];

    original_dotthz.add_dataset(&group_name, &dataset_name, dataset_data.view())?;
    
    // data is now already saved to the file.
    
    
    // Load data from the dotTHz file
    let file = DotthzFile::open(&file_path)?;

    for group in file
        .get_groups()?
    {
        // Compare the original and copied metadata
        let meta_data = file.get_meta_data(&group.name());
        
        for dataset in group.get_datasets() {
            // do stuff with the loaded dataset
            // ...
        }
        let data = file.get_dataset(&group.name(), &dataset_name);
    }

}

Use the hdf5-sys-static feature to compile hdf5 and statically link it. This requires cmake to be installed. Use the serde feature to derive Serialize and Deserialize for DotthzMetaData.

Commit count: 44

cargo fmt