Пример #1
0
        protected H5Space GetSpace()
        {
            if (!(ID > 0))
            {
                throw new InvalidOperationException("operation on closed dataset");
            }

            return(H5Space.FromDataset(ID));
        }
Пример #2
0
 /// <summary>
 /// Load an existing dataset by `dset_id`.
 /// </summary>
 /// <remarks>
 /// Creates and returns an `H5DataSet` of the appropriate `space` and `dtype`.
 /// Throws `H5LibraryException` if `dset_id` is invalid.
 /// </remarks>
 internal static H5DataSet FromID(hid_t dset_id)
 {
     using (H5Space space = H5Space.FromDataset(dset_id)) {
         using (H5Type dtype = H5Type.FromDataset(dset_id)) {
             if (space.Rank == 1)
             {
                 if (dtype.PrimitiveType == typeof(System.Double))
                 {
                     return(new dset1d <double>(dset_id));
                 }
                 if (dtype.PrimitiveType == typeof(System.Single))
                 {
                     return(new dset1d <float>(dset_id));
                 }
                 if (dtype.PrimitiveType == typeof(System.Byte))
                 {
                     return(new dset1d <byte>(dset_id));
                 }
                 if (dtype.PrimitiveType == typeof(System.Int64))
                 {
                     return(new dset1d <long>(dset_id));
                 }
                 if (dtype.PrimitiveType == typeof(System.Int32))
                 {
                     return(new dset1d <int>(dset_id));
                 }
                 if (dtype.PrimitiveType == typeof(System.String))
                 {
                     return(new string1d(dset_id));
                 }
             }
             if (space.Rank == 2)
             {
                 if (dtype.PrimitiveType == typeof(System.Double))
                 {
                     return(new dset2d <double>(dset_id));
                 }
                 if (dtype.PrimitiveType == typeof(System.Single))
                 {
                     return(new dset2d <float>(dset_id));
                 }
                 if (dtype.PrimitiveType == typeof(System.Byte))
                 {
                     return(new dset2d <byte>(dset_id));
                 }
                 if (dtype.PrimitiveType == typeof(System.Int64))
                 {
                     return(new dset2d <long>(dset_id));
                 }
                 if (dtype.PrimitiveType == typeof(System.Int32))
                 {
                     return(new dset2d <int>(dset_id));
                 }
                 if (dtype.PrimitiveType == typeof(System.String))
                 {
                     return(new string2d(dset_id));
                 }
             }
             if (space.Rank == 3)
             {
                 if (dtype.PrimitiveType == typeof(System.Double))
                 {
                     return(new dset3d <double>(dset_id));
                 }
                 if (dtype.PrimitiveType == typeof(System.Single))
                 {
                     return(new dset3d <float>(dset_id));
                 }
                 if (dtype.PrimitiveType == typeof(System.Byte))
                 {
                     return(new dset3d <byte>(dset_id));
                 }
                 if (dtype.PrimitiveType == typeof(System.Int64))
                 {
                     return(new dset3d <long>(dset_id));
                 }
                 if (dtype.PrimitiveType == typeof(System.Int32))
                 {
                     return(new dset3d <int>(dset_id));
                 }
             }
             throw new NotImplementedException($"dataset<{dtype.PrimitiveType}> of rank ({space.Rank})");
         }
     }
 }