Ejemplo n.º 1
0
 protected override void DirectRead(int xOffset, int yOffset, int xSize, int ySize, IntPtr buffer, enumDataType dataType, int xBufferSize, int yBufferSize)
 {
     if (xSize == xBufferSize && ySize == yBufferSize)
     {
         int[] start = new int[] { yOffset, xOffset };
         int[] edges = new int[] { ySize, xSize };
         _sds.Read(start, null, edges, buffer);
     }
     else
     {
     }
 }
Ejemplo n.º 2
0
        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
        }