Example #1
0
        public void H5Pget_virtual_vspaceTestVDS1()
        {
            hid_t vds = H5D.open(m_vds_class_file, "VDS");

            Assert.IsTrue(vds >= 0);

            hid_t dcpl = H5D.get_create_plist(vds);

            Assert.IsTrue(dcpl >= 0);

            IntPtr count = IntPtr.Zero;

            Assert.IsTrue(H5P.get_virtual_count(dcpl, ref count) >= 0);
            Assert.IsTrue(3 == count.ToInt32());

            for (int i = 0; i < count.ToInt32(); ++i)
            {
                size_t index  = new size_t(i);
                hid_t  vspace = H5P.get_virtual_vspace(dcpl, index);
                Assert.IsTrue(vspace >= 0);

                Assert.IsTrue(H5S.is_regular_hyperslab(vspace) > 0);

                Assert.IsTrue(H5S.close(vspace) >= 0);
            }

            Assert.IsTrue(H5P.close(dcpl) >= 0);
            Assert.IsTrue(H5D.close(vds) >= 0);
        }
        public void H5Pget_virtual_dsetnameTestVDS1()
        {
            hid_t vds = H5D.open(m_vds_class_file, "VDS");

            Assert.IsTrue(vds >= 0);

            hid_t dcpl = H5D.get_create_plist(vds);

            Assert.IsTrue(dcpl >= 0);

            IntPtr count = IntPtr.Zero;

            Assert.IsTrue(H5P.get_virtual_count(dcpl, ref count) >= 0);
            Assert.IsTrue(3 == count.ToInt32());

            string[] names = { "A", "B", "C" };

            for (int i = 0; i < count.ToInt32(); ++i)
            {
                size_t  index = new ssize_t(i);
                ssize_t len   = H5P.get_virtual_filename(dcpl, index, null,
                                                         IntPtr.Zero);
                Assert.IsTrue(len.ToInt32() > 0);
                StringBuilder name = new StringBuilder(len.ToInt32() + 1);
                len = H5P.get_virtual_dsetname(dcpl, index, name, len + 1);
                Assert.IsTrue(len.ToInt32() > 0);
                Assert.IsTrue(name.ToString() == names[i]);
            }

            Assert.IsTrue(H5P.close(dcpl) >= 0);
            Assert.IsTrue(H5D.close(vds) >= 0);
        }
        /// <summary>
        /// Reads an n-dimensional dataset.
        /// </summary>
        /// <typeparam name="T">Generic parameter strings or primitive type</typeparam>
        /// <param name="groupId">id of the group. Can also be a file Id</param>
        /// <param name="name">name of the dataset</param>
        /// <returns>The n-dimensional dataset</returns>
        public static Array ReadDatasetToArray <T>(hid_t groupId, string name) //where T : struct
        {
            var datatype = GetDatatype(typeof(T));


            var   datasetId = H5D.open(groupId, name);
            var   spaceId   = H5D.get_space(datasetId);
            int   rank      = H5S.get_simple_extent_ndims(spaceId);
            long  count     = H5S.get_simple_extent_npoints(spaceId);
            Array dset;
            Type  type = typeof(T);

            if (rank >= 0 && count >= 0)
            {
                int     rankChunk;
                ulong[] maxDims   = new ulong[rank];
                ulong[] dims      = new ulong[rank];
                ulong[] chunkDims = new ulong[rank];
                hid_t   memId     = H5S.get_simple_extent_dims(spaceId, dims, maxDims);
                long[]  lengths   = dims.Select(d => Convert.ToInt64(d)).ToArray();
                dset = Array.CreateInstance(type, lengths);
                var typeId   = H5D.get_type(datasetId);
                var mem_type = H5T.copy(datatype);
                if (datatype == H5T.C_S1)
                {
                    H5T.set_size(datatype, new IntPtr(2));
                }

                var propId = H5D.get_create_plist(datasetId);

                if (H5D.layout_t.CHUNKED == H5P.get_layout(propId))
                {
                    rankChunk = H5P.get_chunk(propId, rank, chunkDims);
                }

                memId = H5S.create_simple(rank, dims, maxDims);
                GCHandle hnd = GCHandle.Alloc(dset, GCHandleType.Pinned);
                H5D.read(datasetId, datatype, memId, spaceId,
                         H5P.DEFAULT, hnd.AddrOfPinnedObject());
                hnd.Free();
            }
            else
            {
                dset = Array.CreateInstance(type, new long[1] {
                    0
                });
            }
            H5D.close(datasetId);
            H5S.close(spaceId);
            return(dset);
        }
Example #4
0
        public void H5Pget_layoutTestVDS1()
        {
            hid_t vds = H5D.open(m_vds_class_file, "VDS");

            Assert.IsTrue(vds >= 0);

            hid_t dcpl = H5D.get_create_plist(vds);

            Assert.IsTrue(dcpl >= 0);

            H5D.layout_t layout = H5P.get_layout(dcpl);
            Assert.IsTrue(layout == H5D.layout_t.VIRTUAL);

            Assert.IsTrue(H5P.close(dcpl) >= 0);
            Assert.IsTrue(H5D.close(vds) >= 0);
        }
        public void H5Pget_virtual_countTestVDS1()
        {
            hid_t vds = H5D.open(m_vds_class_file, "VDS");

            Assert.IsTrue(vds >= 0);

            hid_t dcpl = H5D.get_create_plist(vds);

            Assert.IsTrue(dcpl >= 0);

            IntPtr count = IntPtr.Zero;

            Assert.IsTrue(H5P.get_virtual_count(dcpl, ref count) >= 0);
            Assert.IsTrue(3 == count.ToInt32());

            Assert.IsTrue(H5P.close(dcpl) >= 0);
            Assert.IsTrue(H5D.close(vds) >= 0);
        }
Example #6
0
        public void H5PglobalsTest1()
        {
            hsize_t[] dims     = { 10, 10, 10 };
            hsize_t[] max_dims = { H5S.UNLIMITED, H5S.UNLIMITED, H5S.UNLIMITED };
            hid_t     space    = H5S.create_simple(3, dims, max_dims);

            hid_t lcpl = H5P.create(H5P.LINK_CREATE);

            Assert.IsTrue(H5P.set_create_intermediate_group(lcpl, 1) >= 0);

            hid_t dcpl = H5P.create(H5P.DATASET_CREATE);

            Assert.IsTrue(dcpl >= 0);
            hsize_t[] chunk = { 64, 64, 64 };
            Assert.IsTrue(H5P.set_chunk(dcpl, 3, chunk) >= 0);
            Assert.IsTrue(H5P.set_deflate(dcpl, 9) >= 0);

            hid_t dset = H5D.create(m_v0_test_file, "A/B/C", H5T.IEEE_F32BE,
                                    space, lcpl, dcpl);

            Assert.IsTrue(dset >= 0);

            hid_t plist = H5D.get_create_plist(dset);

            Assert.IsTrue(H5D.layout_t.CHUNKED == H5P.get_layout(plist));
            Assert.IsTrue(H5P.close(plist) >= 0);

            Assert.IsTrue(H5D.close(dset) >= 0);

            dset = H5D.create(m_v2_test_file, "A/B/C", H5T.IEEE_F32BE,
                              space, lcpl, dcpl);
            Assert.IsTrue(dset >= 0);

            plist = H5D.get_create_plist(dset);
            Assert.IsTrue(H5D.layout_t.CHUNKED == H5P.get_layout(plist));
            Assert.IsTrue(H5P.close(plist) >= 0);

            Assert.IsTrue(H5D.close(dset) >= 0);

            Assert.IsTrue(H5P.close(dcpl) >= 0);
            Assert.IsTrue(H5P.close(lcpl) >= 0);
            Assert.IsTrue(H5S.close(space) >= 0);
        }
Example #7
0
        public static T[,] ReadDataset <T>(int groupId, string name) where T : struct
        {
            var      datatype = GetDatatype(typeof(T));

            name = ToHdf5Name(name);

            var      datasetId = H5D.open(groupId, name);
            var      spaceId   = H5D.get_space(datasetId);
            int      rank      = H5S.get_simple_extent_ndims(spaceId);
            long     count     = H5S.get_simple_extent_npoints(spaceId);
            int      rankChunk;
            ulong[]  maxDims   = new ulong[rank];
            ulong[]  dims      = new ulong[rank];
            ulong[]  chunkDims = new ulong[rank];
            var      memId     = H5S.get_simple_extent_dims(spaceId, dims, maxDims);
            T[,] dset = new T[dims[0], dims[1]];
            var      typeId   = H5D.get_type(datasetId);
            var      mem_type = H5T.copy(datatype);
            if (datatype == H5T.C_S1)
            {
                H5T.set_size(datatype, new IntPtr(2));
            }

            var      propId = H5D.get_create_plist(datasetId);

            if (H5D.layout_t.CHUNKED == H5P.get_layout(propId))
            {
                rankChunk = H5P.get_chunk(propId, rank, chunkDims);
            }

            memId = H5S.create_simple(rank, dims, maxDims);
            GCHandle hnd = GCHandle.Alloc(dset, GCHandleType.Pinned);
            H5D.read(datasetId, datatype, memId, spaceId,
                     H5P.DEFAULT, hnd.AddrOfPinnedObject());
            hnd.Free();
            H5D.close(typeId);
            H5D.close(datasetId);
            H5S.close(spaceId);
            return(dset);
        }
        public void H5Dget_create_plistTest1()
        {
            hid_t dset = H5D.create(m_v0_test_file, "dset", H5T.IEEE_F64BE,
                                    m_space_null);

            Assert.IsTrue(dset >= 0);

            hid_t dapl = H5D.get_create_plist(dset);

            Assert.IsTrue(dapl >= 0);

            Assert.IsTrue(H5P.close(dapl) >= 0);
            Assert.IsTrue(H5D.close(dset) >= 0);

            dset = H5D.create(m_v2_test_file, "dset", H5T.IEEE_F64BE,
                              m_space_null);
            Assert.IsTrue(dset >= 0);

            dapl = H5D.get_create_plist(dset);
            Assert.IsTrue(dapl >= 0);

            Assert.IsTrue(H5P.close(dapl) >= 0);
            Assert.IsTrue(H5D.close(dset) >= 0);
        }
 public void H5Dget_create_plistTest2()
 {
     Assert.IsFalse(
         H5D.get_create_plist(Utilities.RandomInvalidHandle()) >= 0);
 }