Closed DevinBayly closed 3 years ago
f32
.data_array
is 2-D Point
.data_array
was 1-D, there's no direct conversion between 1-D structured arrays and 2-D scalar ones.Thanks for providing some extra info, I think I understand why the conversion error arises now. So is there a better way to read a dataset when my data is 2-D collection of f32
? I'm not tied to using the Point
struct, that was just my first guess when looking at the examples on crates.io.
Would a read_raw::<f32>
be a better approach?
Sorry to ask you to spell things out for me.
Well, yea - you can read_2d::<f32>()
, that should work.
If you really want an x/y/z struct, you can probably pull the data out of ndarray as a vec and unsafely transmute it into a vec of points. This is something that is technically doable at the library level but I guess there haven't been enough use cases (or contributors) to implement it.
oh wow nvm, just using
let mut f = hdf5::File::open("./positions_chunk0.hdf5").unwrap();
let mut dataset = f.dataset("snapshot_000").unwrap();
let data = dataset.read_2d::<f32>().unwrap();
println!("data read is {:?}",data);
did the trick. Thanks for the package!
I'm guessing this is almost as simple as the material in the documentation but I can't get the "no conversion path" error to go away. My hdf5 files are in this format and each one is formatted in this shape
given this info can anyone say why this rust code fails to read into a 2d array?