Ejemplo n.º 1
0
        void doTile(String test,
            float[][] data,
            ImageTiler t,
            int x, int y, int nx, int ny)
        {
            float[] tile = new float[nx * ny];
            t.GetTile(tile, new int[] { y, x }, new int[] { ny, nx });

            float sum0 = 0;
            float sum1 = 0;

            for (int i = 0; i < nx; i += 1)
            {
                for (int j = 0; j < ny; j += 1)
                {
                    sum0 += tile[i + j * nx];
                    sum1 += data[j + y][i + x];
                }
            }

            Assertion.AssertEquals("Tiler" + test, sum0, sum1);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Method to read data
        /// </summary>
        /// <param name="i"></param>
        public override void Read(ArrayDataIO i)
        {
            // Don't need to read null data (noted by Jens Knudstrup)
            if (byteSize == 0)
            {
                return ;
            }
            SetFileOffset(i);

            //if(i is RandomAccess)
            if(i.CanSeek)
            {
                //tiler = new ImageDataTiler(this, (RandomAccess) i, ((RandomAccess) i).FilePointer, dataDescription);
                tiler = new ImageDataTiler(this, (RandomAccess) i, ((Stream)i).Position, dataDescription);
                try
                {
                    double pos = i.Position;
                    //pos = i.Seek((int)byteSize) - pos;
                    i.Seek((int)byteSize);
                }
                catch(IOException e)
                {
                    throw new FitsException("Unable to skip over data:" + e);
                }
            }
            else
            {
                dataArray = ArrayFuncs.NewInstance(dataDescription.type, dataDescription.dims);
                try
                {
                    i.ReadArray(dataArray);
                }
                catch(IOException e)
                {
                    throw new FitsException("Unable to read image data:" + e);
                }

                tiler = new ImageDataTiler(this, null, 0, dataDescription);
            }

            int pad = FitsUtil.Padding(TrueSize);
            try
            {
                long pos = i.Seek(pad);
                if(pos != pad)
                {
                    throw new FitsException("Error skipping padding");
                }
            }
            catch(IOException e)
            {
                throw new FitsException("Error reading image padding:" + e);
            }
        }