Hi all,
I'm currently experiencing some difficulties in extending a 1D dataset.
It's a trivial problem, I'm sure, but I'm having difficulty getting past it.
First off, my project is currently being developed in C#.
The main method I'm using is below:
*public void AppendNumericArrayToDataset(string address, double[] data)
···
{
long[] start = new long[1];
long[] stride = new long[1];
long[] count = new long[1];
long[] block = new long[1];
long[] dims = new long[1];
long[] maxdims = new long[1];
int datasetID = H5Dopen2(fileID, address, H5P_DEFAULT);
int dataspaceID = H5Dget_space(datasetID);
status = H5Sget_simple_extent_dims(dataspaceID, dims,
maxdims);
long[] extdims = new long[1];
extdims[0] = dims[0] + data.Length;
status = H5Dset_extent(datasetID, extdims);
start[0] = (long) dims[0];
stride = null;
count[0] = (long) data.Length;
block = null;*
*
status = H5Sselect_hyperslab(dataspaceID, H5S_SET, start,
stride, count, block);
status = H5Dwrite(datasetID, H5T_NATIVE_DOUBLE, H5S_ALL,
dataspaceID, H5P_DEFAULT, data);
status = H5Dclose(datasetID);
status = H5Sclose(dataspaceID);
}*
After passing a 10-element array to the method, I get the following results:
*status (H5Sselect_hyperslab) = 0
status (H5Dwrite) = -1
**H5Sselect_valid(dataspaceID) = 1*
*H5Sget_select_npoints(dataspaceID) = 10
H5Sselect_valid(dataspaceID) = 0
H5Sget_select_hyper_nblocks(dataspaceID) = 10*
I'm unable to write to the dataset when using a hyperslab. If I use the
H5S_ALL keyword for my dataset property list ID, it writes fine for the most
part.
Is anyone able to offer any insight into this problem?
--
Stefan Novak
Sent from Greenbelt, Maryland, United States
To answer my own question, the problem I was experiencing was due to a
couple of issues:
- After extending a dataset, I have to extend the corresponding dataspace as
well.
- I assumed that H5S_ALL selected the full memory space of the data I was
writing. However, the dataspace would be used for the memory space as well.
I had to define a memory space object that had the same dimension as my
data and pass it through H5Sselect_all
Just fyi for anyone else who gets caught up in the same situation.
···
On Thu, Jul 23, 2009 at 1:11 PM, Stefan Novak <stefan.louis.novak@gmail.com>wrote:
Hi all,
I'm currently experiencing some difficulties in extending a 1D dataset.
It's a trivial problem, I'm sure, but I'm having difficulty getting past it.
First off, my project is currently being developed in C#.
The main method I'm using is below:
*public void AppendNumericArrayToDataset(string address, double[] data)
{
long[] start = new long[1];
long[] stride = new long[1];
long[] count = new long[1];
long[] block = new long[1];
long[] dims = new long[1];
long[] maxdims = new long[1];
int datasetID = H5Dopen2(fileID, address, H5P_DEFAULT);
int dataspaceID = H5Dget_space(datasetID);
status = H5Sget_simple_extent_dims(dataspaceID, dims,
maxdims);
long[] extdims = new long[1];
extdims[0] = dims[0] + data.Length;
status = H5Dset_extent(datasetID, extdims);
start[0] = (long) dims[0];
stride = null;
count[0] = (long) data.Length;
block = null;*
*
status = H5Sselect_hyperslab(dataspaceID, H5S_SET, start,
stride, count, block);
status = H5Dwrite(datasetID, H5T_NATIVE_DOUBLE, H5S_ALL,
dataspaceID, H5P_DEFAULT, data);
status = H5Dclose(datasetID);
status = H5Sclose(dataspaceID);
}*
After passing a 10-element array to the method, I get the following
results:
*status (H5Sselect_hyperslab) = 0
status (H5Dwrite) = -1
**H5Sselect_valid(dataspaceID) = 1*
*H5Sget_select_npoints(dataspaceID) = 10
H5Sselect_valid(dataspaceID) = 0
H5Sget_select_hyper_nblocks(dataspaceID) = 10*
I'm unable to write to the dataset when using a hyperslab. If I use the
H5S_ALL keyword for my dataset property list ID, it writes fine for the most
part.
Is anyone able to offer any insight into this problem?
--
Stefan Novak
Sent from Greenbelt, Maryland, United States
--
Stefan Novak
Sent from Arlington, Virginia, United States