private void TestHelper() { int major_v; int minor_v; int release; StringBuilder libraryversion = new StringBuilder(); HDF4API.Hgetlibversion(out major_v, out minor_v, out release, libraryversion); string fullfilename = @"E:\Smart\CloudArgs\cloudsat\2007101034511_05065_CS_2B-GEOPROF_GRANULE_P_R04_E02.hdf"; int file_id = HDF4API.Hopen(fullfilename, DFACC.DFACC_READ, 0); HDF4API.Hgetfileversion(file_id, out major_v, out minor_v, out release, libraryversion); H4File hdf = new H4File(null, null, null, null); hdf.Load(fullfilename); //测试读取的全局属性 for (int i = 0; i < hdf.Num_Global_Attrs; i++) { dynamic attValue = hdf.GlobalAttrs[i].Value; } //测试读取的科学数据集及其属性 for (int i = 0; i < hdf.Num_Datasets; i++) { H4SDS sd = hdf.Datasets[i]; HDFAttribute[] attrs = sd.SDAttributes; if (sd.Rank == 2) { int buffersize = (int)sd.Dimsizes[0] * sd.Dimsizes[1]; int typesize = HDFDataType.GetSize(sd.Datatype); IntPtr ptr = Marshal.AllocHGlobal(buffersize * typesize); sd.Read(new int[] { 0, 0 }, null, sd.Dimsizes, ptr); short[] buffer = new short[buffersize]; Marshal.Copy(ptr, buffer, 0, buffersize); Marshal.FreeHGlobal(ptr); } } //测试读取的Vdata }
private void BuilderRastersAndTables() { Dictionary <string, string> dss = new Dictionary <string, string>(); dss.Add("1B-CPR", "ReceivedEchoPowers");//这个没有height dss.Add("2B-CLDCLASS", "cloud_scenario"); dss.Add("2B-CWC-RO", "RO_liq_effective_radius,RO_ice_phase_fraction,RO_radar_uncertainty,LO_RO_AP_geo_mean_radius,LO_RO_AP_sdev_geo_mean_radius,"); dss.Add("2B-CWC-RVOD", ""); dss.Add("2B-FLXHR", ""); dss.Add("2B-GEOPROF", "Radar_Reflectivity"); dss.Add("2B-GEOPROF-LIDAR", "CloudFraction,UncertaintyCF"); dss.Add("2B-TAU", "layer_optical_depth"); dss.Add("2C-PRECIP-COLUMN", ""); dss.Add("ECMWF-AUX", "Pressure,Temperature,Specific_humidity,Ozone"); dss.Add("MODIS-AUX", ""); if (dss.ContainsKey(_fileNameProductName)) { file = new H4File(null, null, null, new long[] { 0, 0 }); file.Load(_filename); string[] vas = dss[_fileNameProductName].Split(','); if (vas == null || vas.Length == 0) { return; } H4SDS[] sds = file.Datasets; for (int i = 0; i < sds.Length; i++) { if (vas.Contains(sds[i].Name)) { CloudSatRasterBand rasterBand = new CloudSatRasterBand(this, sds[i], i + 1); _rasterBands.Add(rasterBand); break; } } } }