/// <summary>Create a null binary table data segment.</summary> /// <exception cref="TableException"> TableException</exception> public BinaryTable() { try { table = new ColumnTable(new Object[0], new int[0]); } catch (TableException e) { Console.Error.WriteLine("Impossible exception in BinaryTable() constructor" + e); } heap = new FitsHeap(0); ExtendArrays(0); nRow = 0; nCol = 0; rowLen = 0; }
/// <summary>Create a binary table from existing data in column order.</summary> public BinaryTable(Object[] o) { heap = new FitsHeap(0); modelRow = new Object[o.Length]; ExtendArrays(o.Length); for (int i=0; i<o.Length; i += 1) { AddColumn(o[i]); } }
/// <summary>Create a binary table from an existing ColumnTable.</summary> public BinaryTable(ColumnTable tab) { nCol = tab.NCols; ExtendArrays(nCol); bases = tab.Bases; sizes = tab.Sizes; modelRow = new Object[nCol]; dimens = new int[nCol][]; // Set all flags to 0. flags = new int[nCol]; // Set the column dimension. Note that // we cannot distinguish an array of length 1 from a // scalar here: we assume a scalar. for (int col=0; col<nCol; col += 1) { if (sizes[col] != 1) { dimens[col] = new int[]{sizes[col]}; } else { dimens[col] = new int[0]; } } for (int col=0; col < nCol; col += 1) { modelRow[col] = ArrayFuncs.NewInstance(bases[col], sizes[col]); } columns = null; table = tab; heap = new FitsHeap(0); rowLen = 0; for (int col = 0; col < nCol; col += 1) { rowLen += sizes[col] * ArrayFuncs.GetBaseLength(tab.GetColumn(col)); } heapOffset = 0 ; nRow = tab.NRows; }
/// <summary>Create a binary table from given header information.</summary> /// <param name="myHeader">header describing what the binary table should look like.</param> public BinaryTable(Header myHeader) { int heapSize = myHeader.GetIntValue("PCOUNT"); heapOffset = myHeader.GetIntValue("THEAP"); // .99.1 changes: changed the sequence of code lines. int rwsz = myHeader.GetIntValue("NAXIS1"); nRow = myHeader.GetIntValue("NAXIS2"); // Subtract out the size of the regular table from // the heap offset. if (heapOffset > 0) { heapOffset -= nRow * rwsz; } if (heapOffset < 0 || heapOffset > heapSize) { throw new FitsException("Inconsistent THEAP and PCOUNT"); } heap = new FitsHeap(heapSize - heapOffset); nCol = myHeader.GetIntValue("TFIELDS"); rowLen = 0; ExtendArrays(nCol); for (int col = 0; col < nCol; col += 1) { rowLen += ProcessCol(myHeader, col); } // .99.1 changes: Added to replace new value of NAXIS1 keyword. HeaderCard card = myHeader.FindCard("NAXIS1"); card.Value = rowLen.ToString(); myHeader.UpdateLine("NAXIS1", card); }