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); } }
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); }
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); } }
private static string[] ReadSDinfo(int sd_id, int num_datasets) { string[] dsNames = new string[num_datasets]; for (int dsIndex = 0; dsIndex < num_datasets; dsIndex++) { int sds_id = HDF4Helper.SDselect(sd_id, dsIndex); try { StringBuilder sds_name = new StringBuilder(256); int rank; int[] dimsizes = new int[256]; GeoDo.HDF4.HDF4Helper.DataTypeDefinitions data_type; int num_attrs; HDF4Helper.SDgetinfo(sds_id, sds_name, out rank, dimsizes, out data_type, out num_attrs); dsNames[dsIndex] = sds_name.ToString(); } finally { HDF4Helper.SDend(sds_id); } } return(dsNames); }