h5read() error, I'm not sure how to fix this?
27 views (last 30 days)
Show older comments
Hi all,
I am having problems opening a dataset from .h5 files. The code is below.
filename = 'r0184KB.h5';
rawSpectra = h5read(filename, '/K_alpha/spectra');
This is strange because sometimes this code runs with no problem whereas other times I get this error message:
Error using h5readc
The HDF5 library encountered an error and produced the following stack trace information:
H5FD_sec2_read file read failed: time = Thu Jun 23 12:54:52 2022
, filename = 'Z:\Projects\XES\Reduced Data\r0184KB.h5', file descriptor = 3, errno =
22, error message = 'Invalid argument', buf = 000001D1E4447060, total read size = 102875136, bytes
this sub-read = 102875136, bytes actually read = 18446744073709551615, offset = 104616
H5FD_read driver read request failed
H5F_accum_read driver read request failed
H5F_block_read read through metadata accumulator failed
H5D__contig_readvv_sieve_cb block read failed
H5V_opvv can't perform operation
H5D__contig_readvv can't perform vectorized sieve buffer read
H5D__select_io read error
H5D__select_read read error
H5D__contig_read contiguous read failed
H5D__read can't read data
H5Dread can't read data
Error in h5read (line 66)
[data,var_class] = h5readc(Filename,Dataset,start,count,stride);
Error in ExtractingXESDataFromH5Files (line 13)
rawSpectra = h5read(filename, '/K_alpha/spectra');
Does anyone know how to fix this problem? I think it could be a memory problem as it works everytime when I read in smaller dataset but only sometimes when I read the larger ones.
Thanks!
5 Comments
per isakson
on 23 Jun 2022
Edited: per isakson
on 23 Jun 2022
And HDFView has no problems to open the file?
I once made a Matlab program that invoked a simulation program in a loop. It ran for hours. I used a gaming PC, which someone else had configured. The simulation program fairly often returned erroneous results. I found that the frequency of errors depended on the air temperature in the room. Lowering the CPU clock frequency and removing some dust solved the problem.
Is Z: mapped to something on the net, a server somewhere?
Answers (1)
Shuba Nandini
on 3 Oct 2023
Hi Kyle,
It is my understanding that you are facing sporadic issues due to size of the dataset that you are using with “h5read” function. Here are few possible reasons that could give the error:
- Error might occur when you are trying to read more data than what’s available in the dataset. To fix this, you need to adjust your start and count parameters appropriately using this command
data = h5read(filename,ds,start,count);
- Memory Issues: If your dataset is very large, it might exceed the available memory on your computer. This could potentially lead to errors. You might need to consider reading the data in smaller chunks.
- Make sure the dataset path you are providing exists in your file. If the path doesn’t exist, h5read will throw an error.
Please refer to the following documentation to know more about “h5read” function:
I hope this helps you to resolve the issue!
Regards,
Shuba Nandini
0 Comments
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!