Beispiel #1
0
        /// <summary>
        /// Create a new dataset with a given `name` under this group.
        /// An attempt to write a readonly-file will throw an `InvalidOperationException`.
        /// </summary>
        public H5DataSet CreateDataset(string name, int rank, long[] dims, Type primitive, long[] maxdims = null)
        {
            if (!IsWritable)
            {
                throw new InvalidOperationException("trying to write a readonly file");
            }

            return(H5DataSet.Create(ID, name, rank, dims, maxdims, primitive));
        }
Beispiel #2
0
        /// <summary>
        /// Retrieve the `H5DataSet` located by the `key` relative to this Group.
        /// The type of dataset returned depends on the actual datatype under
        /// the `key`. A non-existing `key` throws a `KeyNotFoundException`.
        /// </summary>
        /// <remarks>
        /// In order to use the object, an explicit cast to one of the generic
        /// datasets is necessary. Beware of casting as it might throw an
        /// `InvalidCastException`.
        /// </remarks>
        /// <example>
        /// <code>
        /// H5Group root = h5file.Root;
        /// double2d dset = (double2d)root["level1/doubleset"];
        /// string1d names = root["level1/names"] as string1d;
        /// if (names == null)
        ///     throw new ApplicationException("no such dataset: level1/names!");
        /// </code>
        /// </example>
        public H5DataSet this[string key]
        {
            get
            {
                if (key.StartsWith("/") || key.EndsWith("/") || !H5Link.Exists(ID, key))
                {
                    throw new KeyNotFoundException(key);
                }

                if (!H5Link.Exists(ID, key))
                {
                    throw new KeyNotFoundException(key);
                }

                return(H5DataSet.FromID(H5DataSet.Open(ID, key)));
            }
        }