I'm adding information, after I try to run my program again, the string data was converted into another symbol, and for other data (int, float, short) as well. I do not know what factors caused it, since I already used the available data type in HDF5DotNet.
But, if I try for each of the data, first I try to insert just string, it is still changed into another symbol, but if I only insert integer data, the actual value can be inserted. I guess the problem comes from H5Array<struct1>(dset_data), when it wrap the array, it changes the value as well? H5D.write(dataSetId,typeId1,new H5Array<struct1>(dset_data)); Hope that I can see any reply regarding this matter. Thank you. regards, Elisa --- On Tue, 8/31/10, elisa sibarani <[email protected]> wrote: From: elisa sibarani <[email protected]> Subject: [Hdf-forum] using compound data types To: [email protected] Date: Tuesday, August 31, 2010, 11:48 PM Hi All, I use compound data types for my dataset, and here I create the struct first, and then load the data, after that create compound data types, create dataset using that compound data types, and finally write into the dataset. I don't know what was wrong with my code, because the result's looking was not exactly what I want. The reason because: 1. The string data that should contains hour:minute (for example 1:20, 17:50) was change into symbol in the HDF5 file 2. The dataset do not containt the same structures as the dset_data (array as the source data), it is messy in the HDF5 file. Until now, I'm trying to fix this, but still can't find any clue. Thanks regards, Elisa Here is the copy of my code: public struct struct1 { public string a; public int b; public float c; public short d; public int e; } public void btnInsert() { struct1[] dset_data = new struct1[numline]; foreach (string s in pd_data) { if (temp1 == 1) { dset_data[temp].a = s; } if (temp1 == 2) { dset_data[temp].b = int.Parse(s); } if (temp1 == 3) { if (s == null || s.Length == 0) { dset_data[temp].c = float.Parse("0"); } else { dset_data[temp].c = float.Parse(s); } } if (temp1 == 4) { dset_data[temp].d = short.Parse(s); } if (temp1 == 5) { if (s == null || s.Length == 0) { dset_data[temp].e = int.Parse("0"); } else { dset_data[temp].e = int.Parse(s); } } temp1 = temp1 + 1; } //create data space ulong[] dims = new ulong[1]; dims[0] = ulong.Parse(numline.ToString()); spaceId = H5S.create_simple(1, dims); //create compound data type typeId1 = H5T.create(H5T.CreateClass.COMPOUND,15); H5T.insert(typeId1, "minutes", 0, H5T.H5Type.C_S1); H5T.insert(typeId1, "fractional", 1, H5T.H5Type.NATIVE_INT); H5T.insert(typeId1, "charges", 5, H5T.H5Type.NATIVE_FLOAT); H5T.insert(typeId1, "phase angle", 9, H5T.H5Type.NATIVE_SHORT); H5T.insert(typeId1, "EMT", 11, H5T.H5Type.NATIVE_INT); dataSetId = H5D.create(fileId, "/" + circuitid + "/" + groupname[0] + "/" + groupname[1] + "/" + groupname[2] + "/" + groupname[3], typeId1, spaceId); // Write the data to the data set. H5D.write(dataSetId,typeId1,new H5Array<struct1>(dset_data)); -----Inline Attachment Follows----- _______________________________________________ Hdf-forum is for HDF software users discussion. [email protected] http://mail.hdfgroup.org/mailman/listinfo/hdf-forum_hdfgroup.org
_______________________________________________ Hdf-forum is for HDF software users discussion. [email protected] http://mail.hdfgroup.org/mailman/listinfo/hdf-forum_hdfgroup.org
