0

I am trying to extract a specific layer from multiple ( > 4000 ) HDF5 files. I used the code below. It worked, but when I tried to load the new saved files, they were not recognized as HDF5. Help would be highly appreciated.

files=dir('C:\OLD_GPM\*.HDF5') % Open  dataset
for j = 1:numel(files)
         r = h5read(files(j).name,'/Grid/precipitationCal');% Read the correct layer "Precipitation calibrated mm/hr"
save([''C:\New_GPM\' files(j).name],'r'); % save this layer
end
serenesat
  • 4,611
  • 10
  • 37
  • 53
AdeB
  • 3
  • 6
  • You could try enforcing version 7.3 when using `save` (older versions of mat-file don't use hdf5), alternatively try `hdf5write` – Daniel Mar 17 '15 at 14:45
  • Much appreciation Daniel for the kind reply. I am wondering if it would be possible to just convert the files to .mat files straight away? – AdeB Mar 17 '15 at 16:23
  • If you want HDF5-based mat-files use `save(['C:\New_GPM\' files(j).name],'r','-v7.3');` – Daniel Mar 17 '15 at 16:25

1 Answers1

0

Only mat-file version 7.3 are HDF5 files, all older versions use another format. Use save(['C:\New_GPM\' files(j).name],'r','-v7.3'); to enforce writing an HDF5 file.

Community
  • 1
  • 1
Daniel
  • 36,610
  • 3
  • 36
  • 69