Exemple #1
0
        public void BuildByColumn()
        {
            Fits f = null;

            try
            {
                BinaryTable btab = new BinaryTable();

                btab.AddColumn(floats);
                btab.AddColumn(vf);
                btab.AddColumn(strings);
                btab.AddColumn(vbool);
                btab.AddColumn(ints);

                f = new Fits();
                f.AddHDU(Fits.MakeHDU(btab));

                BufferedFile bdos =
                    new BufferedFile(
                        TestFileSetup.GetTargetFilename("bt3.fits"),
                        FileAccess.ReadWrite,
                        FileShare.ReadWrite);
                f.Write(bdos);
                bdos.Close();
                bdos.Dispose();
                f.Close();

                f = new Fits(TestFileSetup.GetTargetFilename("bt3.fits"));
                BinaryTableHDU bhdu = (BinaryTableHDU)f.GetHDU(1);
                btab = (BinaryTable)bhdu.Data;

                Assert.AreEqual(true, ArrayFuncs.ArrayEquals(floats, bhdu.GetColumn(0)));
                Assert.AreEqual(true, ArrayFuncs.ArrayEquals(vf, bhdu.GetColumn(1))); // problem is here only

                String[] col = (String[])bhdu.GetColumn(2);
                for (int i = 0; i < col.Length; i += 1)
                {
                    col[i] = col[i].Trim();
                }

                Assert.AreEqual(true, ArrayFuncs.ArrayEquals(strings, col));
                Assert.AreEqual(true, ArrayFuncs.ArrayEquals(vbool, bhdu.GetColumn(3)));
                Assert.AreEqual(true, ArrayFuncs.ArrayEquals(ints, bhdu.GetColumn(4)));
            }
            finally
            {
                if (f != null)
                {
                    f.Close();
                }
            }
        }
Exemple #2
0
        /// <summary>Add a column without any associated header information.</summary>
        /// <param name="data">The column data to be added.  Data should be an Object[] where
        /// type of all of the constituents is identical.  The length
        /// of data should match the other columns.  <b> Note:</b> It is
        /// valid for data to be a 2 or higher dimensionality primitive
        /// array.  In this case the column index is the first (in Java speak)
        /// index of the array.  E.g., if called with int[30][20][10], the
        /// number of rows in the table should be 30 and this column
        /// will have elements which are 2-d integer arrays with TDIM = (10,20).
        /// </param>
        /// <exception cref=""> FitsException the column could not be added.</exception>
        public override int AddColumn(Object data)
        {
            int col = table.AddColumn(data);

            table.PointToColumn(NCols - 1, myHeader);
            return(col);
        }
Exemple #3
0
        public void BuildByColumn()
        {
            BinaryTable btab = new BinaryTable();

            btab.AddColumn(floats);
            btab.AddColumn(vf);
            btab.AddColumn(strings);
            btab.AddColumn(vbool);
            btab.AddColumn(ints);

            Fits f = new Fits();

            f.AddHDU(Fits.MakeHDU(btab));

            // BufferedDataStream bdos = new BufferedDataStream(new FileStream("bt3.fits",FileMode.Open));
            BufferedFile bdos = new BufferedFile("bt3.fits", FileAccess.ReadWrite, FileShare.ReadWrite);

            f.Write(bdos);
            bdos.Close();

            f = new Fits("bt3.fits");
            BinaryTableHDU bhdu = (BinaryTableHDU)f.GetHDU(1);

            btab = (BinaryTable)bhdu.Data;

            Assertion.AssertEquals("col1", true, ArrayFuncs.ArrayEquals(floats, bhdu.GetColumn(0)));
            Assertion.AssertEquals("col2", true, ArrayFuncs.ArrayEquals(vf, bhdu.GetColumn(1))); // problem is here only

            String[] col = (String[])bhdu.GetColumn(2);
            for (int i = 0; i < col.Length; i += 1)
            {
                col[i] = col[i].Trim();
            }
            Assertion.AssertEquals("coi3", true, ArrayFuncs.ArrayEquals(strings, col));

            Assertion.AssertEquals("col4", true, ArrayFuncs.ArrayEquals(vbool, bhdu.GetColumn(3)));
            Assertion.AssertEquals("col5", true, ArrayFuncs.ArrayEquals(ints, bhdu.GetColumn(4)));
            f.Close();
        }