Пример #1
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);
        }
Пример #2
0
 public Dictionary <string, string> GetAttributes()
 {
     if (!_readFileAttrs)
     {
         Dictionary <string, string> cacheAttrs = GlobalFileAttributeCache.GetFileAttributes(_fname);
         if (cacheAttrs == null)
         {
             _readFileAttrs = true;
             int id = HDF4Helper.SDstart(_fname, HDF4Helper.AccessCodes.DFACC_READ);
             try
             {
                 int dsCount  = 0;
                 int attCount = 0;
                 HDF4Helper.SDfileinfo(id, out dsCount, out attCount);
                 if (attCount == 0)
                 {
                     return(null);
                 }
                 _fileAttrs = GetAttributes(id, attCount);
                 GlobalFileAttributeCache.SetFileAttributes(_fname, _fileAttrs);
             }
             finally
             {
                 HDF4Helper.SDend(id);
             }
         }
         else
         {
             _fileAttrs = cacheAttrs;
         }
     }
     return(_fileAttrs);
 }
Пример #3
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);
            }
        }
Пример #4
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);
            }
        }
Пример #5
0
        private string[] GetALLDataset()
        {
            int sd_id = HDF4Helper.SDstart(_fname, HDF4Helper.AccessCodes.DFACC_READ);

            try
            {
                int num_datasets     = 0;
                int num_global_attrs = 0;
                HDF4Helper.SDfileinfo(sd_id, out num_datasets, out num_global_attrs);
                string[] dsNames = ReadSDinfo(sd_id, num_datasets);
                return(dsNames);
            }
            finally
            {
                HDF4Helper.SDend(sd_id);
            }
        }