From: Luis Fernandes on
Hi,

I've tried your solution with R2008a (7.6.0) to adapt for my case and I get an error:

??? Could not read dataset.

So, I've copied your code to see if it was my problem and I get the same error.

??? Could not read dataset.

Error in ==> testhyperslab at 20
rdata = H5D.read(dset,'H5T_NATIVE_INT',mem_space,space,'H5P_DEFAULT');

testhyperslab is the m file with your code as shown below:

hdf5write('o.h5','/DS1',reshape(1:53*512*512,[53 512 512]))

fileID=H5F.open('o.h5','H5F_ACC_RDONLY','H5P_DEFAULT');
dset=H5D.open(fileID,'/DS1'); % this is a 53x512x512 data set
space=H5D.get_space(dset);


start=[7 18 26]; %zero based!
stride=[1 1 1];
count=[1 1 1]; block=[ ];


H5S.select_hyperslab(space,'H5S_SELECT_SET',fliplr(start-1),... %-1 totake care of 0 based indexing
fliplr(stride),fliplr(count),fliplr(block)); %fliplrto take care of row/column major reversal (please see the ReadMe.txt in myprevious post
mem_space = H5S.create_simple(3, fliplr(count), []); %see Readme.txt forexplanation on need for flipping


rdata = H5D.read(dset,'H5T_NATIVE_INT',mem_space,space,'H5P_DEFAULT');

H5D.close(dset);
H5S.close(space);
H5S.close(mem_space);
H5F.close(fileID);

disp(rdata)

If I read the entire array it's fine, but with hyperslab I get the "can't read dataset" error. Any idea on what's going on? Thanks!
Luis
From: John Evans on
"Luis Fernandes" <luisfernandes77(a)hotmail.com> wrote in message <hmr5jo$5dc$1(a)fred.mathworks.com>...
> Hi,
>
> I've tried your solution with R2008a (7.6.0) to adapt for my case and I get an error:
>
> ??? Could not read dataset.
>
> So, I've copied your code to see if it was my problem and I get the same error.
>
> ??? Could not read dataset.
>
> Error in ==> testhyperslab at 20
> rdata = H5D.read(dset,'H5T_NATIVE_INT',mem_space,space,'H5P_DEFAULT');
>
> testhyperslab is the m file with your code as shown below:
>
> hdf5write('o.h5','/DS1',reshape(1:53*512*512,[53 512 512]))
>
> fileID=H5F.open('o.h5','H5F_ACC_RDONLY','H5P_DEFAULT');
> dset=H5D.open(fileID,'/DS1'); % this is a 53x512x512 data set
> space=H5D.get_space(dset);
>
>
> start=[7 18 26]; %zero based!
> stride=[1 1 1];
> count=[1 1 1]; block=[ ];
>
>
> H5S.select_hyperslab(space,'H5S_SELECT_SET',fliplr(start-1),... %-1 totake care of 0 based indexing
> fliplr(stride),fliplr(count),fliplr(block)); %fliplrto take care of row/column major reversal (please see the ReadMe.txt in myprevious post
> mem_space = H5S.create_simple(3, fliplr(count), []); %see Readme.txt forexplanation on need for flipping
>
>
> rdata = H5D.read(dset,'H5T_NATIVE_INT',mem_space,space,'H5P_DEFAULT');
>
> H5D.close(dset);
> H5S.close(space);
> H5S.close(mem_space);
> H5F.close(fileID);
>
> disp(rdata)
>
> If I read the entire array it's fine, but with hyperslab I get the "can't read dataset" error. Any idea on what's going on? Thanks!
> Luis

Try using 'H5ML_DEFAULT' instead of 'H5T_NATIVE_INT'.
From: Ashish Uthama on
On Fri, 05 Mar 2010 09:48:24 -0500, Luis Fernandes
<luisfernandes77(a)hotmail.com> wrote:

> Hi,
>
> I've tried your solution with R2008a (7.6.0) to adapt for my case and I
> get an error:
>
> ??? Could not read dataset.
>
> So, I've copied your code to see if it was my problem and I get the same
> error.
>
> ??? Could not read dataset.
>
> Error in ==> testhyperslab at 20
> rdata = H5D.read(dset,'H5T_NATIVE_INT',mem_space,space,'H5P_DEFAULT');
>
> testhyperslab is the m file with your code as shown below:
> hdf5write('o.h5','/DS1',reshape(1:53*512*512,[53 512 512]))
>
> fileID=H5F.open('o.h5','H5F_ACC_RDONLY','H5P_DEFAULT');
> dset=H5D.open(fileID,'/DS1'); % this is a 53x512x512 data set
> space=H5D.get_space(dset);
>
>
> start=[7 18 26]; %zero based!
> stride=[1 1 1];
> count=[1 1 1]; block=[ ];
>
>
> H5S.select_hyperslab(space,'H5S_SELECT_SET',fliplr(start-1),... %-1
> totake care of 0 based indexing
> fliplr(stride),fliplr(count),fliplr(block)); %fliplrto take care of
> row/column major reversal (please see the ReadMe.txt in myprevious post
> mem_space = H5S.create_simple(3, fliplr(count), []); %see Readme.txt
> forexplanation on need for flipping
>
>
> rdata = H5D.read(dset,'H5T_NATIVE_INT',mem_space,space,'H5P_DEFAULT');
>
> H5D.close(dset);
> H5S.close(space);
> H5S.close(mem_space);
> H5F.close(fileID);
>
> disp(rdata)
>
> If I read the entire array it's fine, but with hyperslab I get the
> "can't read dataset" error. Any idea on what's going on? Thanks!
> Luis

For 8a, try replacing the read with:
rdata = H5D.read(dset,'H5ML_DEFAULT',mem_space,space,'H5P_DEFAULT');

From: Luis Fernandes on

> For 8a, try replacing the read with:
> rdata = H5D.read(dset,'H5ML_DEFAULT',mem_space,space,'H5P_DEFAULT');


Thanks, it worked.