How to extract data from multiple HDF5 files
Mostrar comentarios más antiguos
First, I need a script that will allow me to extract data from a specific range in a dataset of multiple (tens to hundreds) HDF5 files. So far I've gotten a script from the help section that will allow me to do so but for a single file at a time only.
Here's the code I have so far
plist = 'H5P_DEFAULT';
fid = H5F.open(filename);
dset_id = H5D.open(fid,'/Grid/precipitation');
dims = fliplr([5 3]);
mem_space_id = H5S.create_simple(2,dims,[]);
file_space_id = H5D.get_space(dset_id);
offset = fliplr([1043 3009]);
block = fliplr([5 3]);
H5S.select_hyperslab(file_space_id,'H5S_SELECT_SET',offset,[],[],block);
data = H5D.read(dset_id,'H5ML_DEFAULT',mem_space_id,file_space_id,plist);
data = data';
H5D.close(dset_id);
H5F.close(fid);
A possible solution I thought of doing is using a text file containing the filenames of the files in a directory and running the script on loop to extract the data from each file. I can make the text file using command prompt and have Matlab read it but I have little idea how to code the rest.
Second, after which, I also need to organize the data like so

I did this manually using MS Excel.
Note: Each file corresponds to a specific time interval whereas the indices in the dataset correspond to decimal degree coordinates.
I thank any who give a solution to either part of the problem.
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre HDF5 Files en Centro de ayuda y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!