예제 #1
0
        public Dictionary <string, string> GetAttributes(string datasetName)
        {
            StringBuilder sds_name = new StringBuilder();
            int           rank     = 0;

            int[] dimsizes = new int[MAX_DIMSIZES];
            HDF4Helper.DataTypeDefinitions datatype;
            int id = HDF4Helper.SDstart(_fname, HDF4Helper.AccessCodes.DFACC_READ);

            try
            {
                int dsIndex  = HDF4Helper.SDnametoindex(id, datasetName);
                int dsObjId  = HDF4Helper.SDselect(id, dsIndex);
                int attCount = 0;
                HDF4Helper.SDgetinfo(dsObjId, sds_name, out rank, dimsizes, out datatype, out attCount);
                //int dsCount = 0;
                //HDF4Helper.SDfileinfo(id, out dsCount, out attCount);
                if (attCount == 0)
                {
                    return(null);
                }
                return(GetAttributes(dsObjId, attCount));
            }
            finally
            {
                HDF4Helper.SDend(id);
            }
        }
예제 #2
0
        public bool GetDataSizeInfos(string datasetName, out int rank, out int[] dimsizes, out HDF4Helper.DataTypeDefinitions hdf4Type, out Type dataType, out int dataTypeSize)
        {
            StringBuilder sds_name = new StringBuilder();

            rank         = 0;
            dimsizes     = new int[MAX_DIMSIZES];
            dataType     = typeof(UInt16);
            hdf4Type     = HDF4Helper.DataTypeDefinitions.DFNT_NUINT16;
            dataTypeSize = 0;
            int id = HDF4Helper.SDstart(_fname, HDF4Helper.AccessCodes.DFACC_READ);

            try
            {
                int dsIndex  = HDF4Helper.SDnametoindex(id, datasetName);
                int dsObjId  = HDF4Helper.SDselect(id, dsIndex);
                int attCount = 0;
                HDF4Helper.SDgetinfo(dsObjId, sds_name, out rank, dimsizes, out hdf4Type, out attCount);
                if (rank != 0)
                {
                    dataType = GetTypeFromHDF4DataType(hdf4Type, out dataTypeSize);
                    return(true);
                }
            }
            finally
            {
                HDF4Helper.SDend(id);
            }
            return(false);
        }
예제 #3
0
        public string GetAttributeValue(string datasetName, string attributeName)
        {
            int id = HDF4Helper.SDstart(_fname, HDF4Helper.AccessCodes.DFACC_READ);

            try
            {
                int dsIndex  = HDF4Helper.SDnametoindex(id, datasetName);
                int dsObjId  = HDF4Helper.SDselect(id, dsIndex);
                int attIndex = HDF4Helper.SDfindattr(dsObjId, attributeName);
                return(ReadAttribute(dsObjId, attIndex));
            }
            finally
            {
                HDF4Helper.SDend(id);
            }
        }