public override bool IsSupport(string fname, byte[] header1024, Dictionary <string, string> datasetNames) { string ext = Path.GetExtension(fname).ToUpper(); if (ext != ".HDF" || !HDF5Helper.IsHdf5(header1024)) { return(false); } using (Hdf5Operator hdf5 = new Hdf5Operator(fname)) { if (hdf5 == null) { return(false); } string[] dss = hdf5.GetDatasetNames; if (dss == null) { return(false); } foreach (string bandname in defaultBandnames) { if (!dss.Contains(bandname)) { return(false); } } } TryGetDef(); return(true); }
public static bool IsCompatible(string fileName, byte[] header1024) { if (header1024 == null) { header1024 = new byte[1024]; using (FileStream fs = new FileStream(fileName, FileMode.Open, FileAccess.Read)) { fs.Read(header1024, 0, 1024); fs.Close(); } } if (!HDF5Helper.IsHdf5(header1024)) { return(false); } Hdf5Operator oper = new Hdf5Operator(fileName); string[] datasets = oper.GetDatasetNames; string[] alldatasets = new string[16] { "SD_Flags_NorthernDaily_A", "SD_Flags_NorthernDaily_D", "SD_Flags_SouthernDaily_A", "SD_Flags_SouthernDaily_D", "SD_NorthernDaily_A", "SD_NorthernDaily_D", "SD_SouthernDaily_A", "SD_SouthernDaily_D", "SWE_Flags_NorthernDaily_A", "SWE_Flags_NorthernDaily_D", "SWE_Flags_SouthernDaily_A", "SWE_Flags_SouthernDaily_D", "SWE_NorthernDaily_A", "SWE_NorthernDaily_D", "SWE_SouthernDaily_A", "SWE_SouthernDaily_D" }; foreach (object set in alldatasets) { if (!datasets.Contains(set)) { return(false); } } return(false); }
public static bool IsCompatible(string fileName, byte[] header1024) { if (header1024 == null) { header1024 = new byte[1024]; using (FileStream fs = new FileStream(fileName, FileMode.Open, FileAccess.Read)) { fs.Read(header1024, 0, 1024); fs.Close(); } } if (!HDF5Helper.IsHdf5(header1024)) { return(false); } Hdf5Operator hdfic = new Hdf5Operator(fileName); string[] HDFdatasets = hdfic.GetDatasetNames; string[] alldatasets = new string[6] { "icecon_north_asc", "icecon_north_avg", "icecon_north_des", "icecon_south_asc", "icecon_south_avg", "icecon_south_des" }; foreach (object set in alldatasets) { if (!HDFdatasets.Contains(set))//数据集必须完全匹配,才能用此数据集 { return(false); } } return(false); }
private static void AppendData <T>(hid_t dataSet, T[] data, ref hsize_t rows) { var fileSpace = H5D.get_space(dataSet); if (fileSpace < 0) { throw new HDF5Exception("Failed to get data space of data set."); } var offset = new ulong[] { rows }; var count = new ulong[] { (ulong)data.Length }; if (H5S.select_hyperslab(fileSpace, H5S.seloper_t.SET, offset, null, count, null) < 0) { throw new HDF5Exception("H5S.select_hyperslab failed."); } var memSpace = H5S.create_simple(1, count, null); if (memSpace < 0) { throw new HDF5Exception("H5S.create_simple failed."); } if (H5D.write(dataSet, HDF5Helper.NumericTypeToHDF5Type <T>(), memSpace, fileSpace, H5P.DEFAULT, new PinnedObject(data)) < 0) { throw new HDF5Exception("H5D.write failed."); } H5S.close(memSpace); H5S.close(fileSpace); rows += (hsize_t)data.Length; }
protected override bool IsCompatible(string fileName, byte[] header1024, params object[] args) { string ext = Path.GetExtension(fileName).ToUpper(); if (!HDF5Helper.IsHdf5(header1024)) { return(false); } return(SICRasterDataProvider.IsSupport(fileName)); }
public override bool IsSupport(string fname, byte[] header1024, Dictionary <string, string> datasetNames) { string ext = Path.GetExtension(fname).ToUpper(); if (!HDF5Helper.IsHdf5(header1024)) { return(false); } return(HasDatasets(fname)); }
public static void SaveAsNewHDF5ByFeatures(string src, string dst, Feature[] features, Action <int, string> progress) { int width = features[0].FieldValues.Length; int height = features.Length; using (HDF5Helper helperSrc = new HDF5Helper(src, false)) { using (HDF5Helper helperDst = new HDF5Helper(dst, true)) { //写文件属性 Dictionary <string, string> fileAttributes = helperSrc.GetFileAttributes(); foreach (KeyValuePair <string, string> fileAttribute in fileAttributes) { helperDst.WriteFileAttribute(fileAttribute.Key, fileAttribute.Value); } List <string> datasetNames = helperSrc.DatasetNames; foreach (string datasetName in datasetNames) { //写数据集 string datasetType = helperSrc.GetDatasetType(datasetName); int bandN = 0, bandH = 0, bandW = 0; switch (datasetType) { case "FLOAT": { float[] data = new float[width * height]; helperSrc.ReadDataArray <float>(datasetName, ref bandN, ref bandH, ref bandW); int index = 0; int pct = 0; foreach (Feature f in features) { if (progress != null) { progress(pct++, null); } foreach (string s in f.FieldValues) { data[index++] = Convert.ToSingle(s); } } //helperDst.WriteDataArray<float>(datasetName, data, bandN, bandH, bandW); helperDst.WriteDataArray <float>(datasetName, data, bandN, height, width); //zyb,20140424 break; } } //写数据集属性 Dictionary <string, string> datasetAttributes = helperSrc.GetDatasetAttributes(datasetName); foreach (KeyValuePair <string, string> datasetAttribute in datasetAttributes) { helperDst.WriteDatasetAttribute(datasetName, datasetAttribute.Key, datasetAttribute.Value); } } } } }
public override bool IsSupport(string fname, byte[] header1024, Dictionary <string, string> datasetNames) { string ext = Path.GetExtension(fname).ToUpper(); if (ext != ".HDF" || !HDF5Helper.IsHdf5(header1024)) { return(false); } TryGetBandProviderDefinition(fname, datasetNames); return(_matchedBandProviderDef != null); }
public void Setup() { bytes_ = RandomExtension.RandomBytes(1024); file_ = new FileStream("HDF5Benchmark_FileIO.dat", FileMode.Create, FileAccess.ReadWrite); fileRows_ = 0; h5file_ = H5F.create("HDF5Benchmark_FileIO.h5", H5F.ACC_TRUNC); dataSet_ = HDF5Helper.CreateDataSet(h5file_, "data", H5T.NATIVE_UINT8, new ulong[] { 0 }, new ulong[] { H5S.UNLIMITED }, new ulong[] { (ulong)bytes_.Length }); dataSetRows_ = 0; }
private IHdfOperator HdfOperatorFactory(string filename) { if (HDF5Helper.IsHdf5(filename)) { return(new Hdf5Operator(filename)); } if (HDF4Helper.IsHdf4(filename)) { return(new Hdf4Operator(filename)); } return(null); }
private bool IsHDF5(string fileName) { byte[] header1024 = new byte[1024]; using (FileStream fs = new FileStream(fileName, FileMode.Open, FileAccess.Read)) { fs.Read(header1024, 0, 1024); fs.Close(); } if (!HDF5Helper.IsHdf5(header1024)) { return(false); } return(true); }
protected override bool IsCompatible(string fileName, byte[] header1024, params object[] args) { if (args == null || args.Length == 0) { return(false); } string ext = Path.GetExtension(fileName).ToUpper(); if (ext != ".HDF" || !HDF5Helper.IsHdf5(header1024)) { return(false); } return(true); }
protected override bool IsCompatible(string fileName, byte[] header1024, params object[] args) { if (header1024 == null) { header1024 = new byte[1024]; using (FileStream fs = new FileStream(fileName, FileMode.Open, FileAccess.Read)) { fs.Read(header1024, 0, 1024); fs.Close(); } } if (!HDF5Helper.IsHdf5(header1024)) { return(false); } Hdf5Operator hdfic = new Hdf5Operator(fileName); string[] HDFdatasets = hdfic.GetDatasetNames; bool matched = false; foreach (String[] sets in FY3AASOandASLProvider._datasets) { foreach (string set in sets) { matched = false; for (int i = 0; i < HDFdatasets.Length; i++) { if (HDFdatasets[i] == set) { matched = true; } } if (!matched) { break; } } if (matched) { return(true); } } return(false); }
protected override bool IsCompatible(string fileName, byte[] header1024, params object[] args) { if (header1024 == null) { header1024 = new byte[1024]; using (FileStream fs = new FileStream(fileName, FileMode.Open, FileAccess.Read)) { fs.Read(header1024, 0, 1024); fs.Close(); } } if (!HDF5Helper.IsHdf5(header1024)) { return(false); } string geoprjstr = "Projection Type".ToUpper(); string geoprj1 = "Geographic Longitude/Latitude".ToUpper(); string geoprj2 = "Geographic Longitude/Latitute".ToUpper(); string geoprj3 = "GLL"; string prjType = null; Hdf5Operator hdfic = new Hdf5Operator(fileName); Dictionary <string, string> fileAttributes = hdfic.GetAttributes(); foreach (KeyValuePair <string, string> fileAttribute in fileAttributes) { if (fileAttribute.Key.ToUpper() == geoprjstr) { prjType = fileAttribute.Value.ToUpper(); break; } } if (prjType == null) { return(false); } if (prjType != null && (prjType != geoprj1 && prjType != geoprj2 && prjType != geoprj3)) { return(false); } return(true); }
public static bool IsCompatible(string fileName, byte[] header1024) { if (header1024 == null) { header1024 = new byte[1024]; using (FileStream fs = new FileStream(fileName, FileMode.Open, FileAccess.Read)) { fs.Read(header1024, 0, 1024); fs.Close(); } } if (!HDF5Helper.IsHdf5(header1024) && !HDF4Helper.IsHdf4(header1024)) { return(false); } L2ProductDefind[] l2Pros = L2ProductDefindParser.GetL2ProductDefs(fileName); if (l2Pros == null || l2Pros.Length == 0) { return(false); } return(true); }
public static void GetDataCoordEnvelope(string hdffname, out CoordEnvelope env) { env = null; try { double lulat = 0, lulon = 0, rdlat = 0, rdlon = 0; double ldlat = 0, ldlon = 0, rulat = 0, rulon = 0; double lulatorbit = 0, lulonorbit = 0, rdlatorbit = 0, rdlonorbit = 0, ldlatorbit = 0, ldlonorbit = 0, rulatorbit = 0, rulonorbit = 0; string lulatstr = "Left-Top Latitude", lulonstr = "Left-Top Longitude", rdlatstr = "Right-Bottom Latitude", rdlonstr = "Right-Bottom Longitude"; string ldlatstr = "Left-Bottom Latitude", ldlonstr = "Left-Bottom Longitude", rulatstr = "Right-Top Latitude", rulonstr = "Right-Top Longitude"; string lulatstrOrbit = "Left-Top X", lulonstrOrbit = "Left-Top Y", rdlatstrOrbit = "Right-Bottom X", rdlonstrOrbit = "Right-Bottom Y"; string ldlatstrOrbit = "Left-Bottom X", ldlonstrOrbit = "Left-Bottom Y", rulatstrOrbit = "Right-Top X", rulonstrOrbit = "Right-Top Y"; HDF5Helper helperSrc = new HDF5Helper(hdffname, false); Dictionary <string, string> fileAttributes = helperSrc.GetFileAttributes(); foreach (KeyValuePair <string, string> fileAttribute in fileAttributes) { if (fileAttribute.Key == lulatstr) { lulat = double.Parse(fileAttribute.Value); } else if (fileAttribute.Key == lulonstr) { lulon = double.Parse(fileAttribute.Value); } else if (fileAttribute.Key == rdlatstr) { rdlat = double.Parse(fileAttribute.Value); } else if (fileAttribute.Key == rdlonstr) { rdlon = double.Parse(fileAttribute.Value); } else if (fileAttribute.Key == ldlonstr) { ldlon = double.Parse(fileAttribute.Value); } else if (fileAttribute.Key == ldlatstr) { ldlat = double.Parse(fileAttribute.Value); } else if (fileAttribute.Key == rulonstr) { rulon = double.Parse(fileAttribute.Value); } else if (fileAttribute.Key == rulatstr) { rulat = double.Parse(fileAttribute.Value); } else if (fileAttribute.Key == lulatstrOrbit) { lulatorbit = double.Parse(fileAttribute.Value); } else if (fileAttribute.Key == lulonstrOrbit) { lulonorbit = double.Parse(fileAttribute.Value); } else if (fileAttribute.Key == ldlatstrOrbit) { ldlatorbit = double.Parse(fileAttribute.Value); } else if (fileAttribute.Key == ldlonstrOrbit) { ldlonorbit = double.Parse(fileAttribute.Value); } else if (fileAttribute.Key == rdlatstrOrbit) { rdlatorbit = double.Parse(fileAttribute.Value); } else if (fileAttribute.Key == rdlonstrOrbit) { rdlonorbit = double.Parse(fileAttribute.Value); } else if (fileAttribute.Key == rulatstrOrbit) { rulatorbit = double.Parse(fileAttribute.Value); } else if (fileAttribute.Key == rulonstrOrbit) { rulonorbit = double.Parse(fileAttribute.Value); } } double minlon, maxlon, minlat, maxlat; bool lonreverse = false, latreverse = false; if (lulon != 0 || rdlon != 0 || rdlat != 0 || lulat != 0 || ldlat != 0 || ldlon != 0 || rulat != 0 || rulon != 0) { if (lulon > rdlon) { lonreverse = true; } if (rdlat > lulat) { latreverse = true; } if (!lonreverse) { lulon = Math.Min(lulon, ldlon); rdlon = Math.Max(rdlon, rulon); } else { lulon = Math.Max(lulon, ldlon); rdlon = Math.Min(rdlon, rulon); } if (!latreverse) { lulat = Math.Max(lulat, rulat); rdlat = Math.Min(ldlat, rdlat); } else { lulat = Math.Min(lulat, rulat); rdlat = Math.Max(rdlat, ldlat); } minlon = !lonreverse ? lulon : rdlon; maxlon = lonreverse ? lulon : rdlon; minlat = !latreverse?rdlat:lulat; maxlat = latreverse ? rdlat : lulat; } else { lulon = lulonorbit < ldlonorbit ? lulonorbit : ldlonorbit; //左侧经度取小的 lulat = lulatorbit > rulatorbit ? lulatorbit : rulatorbit; //上侧纬度取大的 rdlon = rulonorbit > rdlonorbit ? rulonorbit : rdlonorbit; //右侧经度取大的 rdlat = ldlatorbit < rdlatorbit ? ldlatorbit : rdlatorbit; //下侧纬度取小的 minlon = lulon < rdlon ? lulon : rdlon; maxlon = lulon > rdlon ? lulon : rdlon; minlat = rdlat < lulat ? rdlat : lulat; maxlat = rdlat > lulat ? rdlat : lulat; } env = new CoordEnvelope(minlon, maxlon, minlat, maxlat); } catch (System.Exception ex) { throw new ArgumentException(ex.Message); } }
public string AsString() { return(HDF5Helper.AttributeAsString(m_AttributeId)); }
public Double AsDouble() { return(HDF5Helper.AttributeAsDouble(m_AttributeId)); }
public Int32 AsInt32() { return(HDF5Helper.AttributeAsInt32(m_AttributeId)); }
public List <string> GetChildDatasetNames() { return(HDF5Helper.GetChildDatasetNames(m_GroupId)); }