Package nom.tam.fits
Class BinaryTable
java.lang.Object
nom.tam.fits.Data
nom.tam.fits.AbstractTableData
nom.tam.fits.BinaryTable
- All Implemented Interfaces:
FitsElement,TableData
- Direct Known Subclasses:
CompressedImageData,CompressedTableData
This class defines the methods for accessing FITS binary table data.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static classCollect all of the information we are using to describe a column into a single object.protected static classOpaque state to pass to ColumnTable -
Field Summary
Fields inherited from class nom.tam.fits.Data
dataSize, fileOffset, input -
Constructor Summary
ConstructorsConstructorDescriptionCreate a null binary table data segment.BinaryTable(Object[] o) Create a binary table from existing data in column order.BinaryTable(Object[][] data) Create a binary table from existing data in row order.BinaryTable(Header myHeader) Create a binary table from given header information.BinaryTable(ColumnTable<?> tabIn) Create a binary table from an existing ColumnTable -
Method Summary
Modifier and TypeMethodDescriptionprotected voidintAdd a column to the table without any associated header information.intaddFlattenedColumn(Object o, int[] dims) Add a column where the data is already flattened.intAdd a row at the end of the table.static voidcreateColumnDataFor(BinaryTable table) TODO: this is only for internal access!protected ColumnTable<BinaryTable.SaveState> createColumnTable(Object[] arrCol, int[] sizes) voiddeleteColumns(int start, int len) Delete a set of columns.voiddeleteRows(int row, int len) Delete rows from a table.voidfillHeader(Header h) Update a FITS header to reflect the current state of the data.Class<?>[]getBases()getColumn(int col) Get a given columngetData()int[][]getElement(int i, int j) Get a particular element from the table.Object[]getFlattenedColumn(int col) intintObject[]intgetNCols()Get the number of columns in the table.intgetNRows()Get the number of rows in the tablegetRawElement(int i, int j) Object[]getRow(int row) Get a given rowint[]getSizes()static int[]Parse the TDIMS value.longGet the size of the data in the HDU sans padding.char[]getTypes()voidRead the data -- or defer reading on random access.protected voidreadHeap(ArrayDataInput input) Read the heap which contains the data for variable length arrays.protected voidRead table, heap and paddingvoidReplace a column in the table.voidsetElement(int i, int j, Object o) Replace a single element within the table.voidsetFlattenedColumn(int col, Object data) Set a column with the data already flattened.voidReplace a row in the table.voidupdateAfterDelete(int oldNcol, Header hdr) Update the header after a deletion.protected booleanvalidColumn(int j) Check if the column number is valid.protected booleanvalidRow(int i) Check to see if this is a valid row.voidwrite(ArrayDataOutput os) Write the table, heap and padding.Methods inherited from class nom.tam.fits.Data
getFileOffset, getKernel, getSize, reset, rewrite, rewriteable, setFileOffset
-
Constructor Details
-
BinaryTable
public BinaryTable()Create a null binary table data segment. -
BinaryTable
Create a binary table from an existing ColumnTable- Parameters:
tabIn- the column table to create the binary table from
-
BinaryTable
Create a binary table from given header information.- Parameters:
myHeader- A header describing what the binary table should look like.- Throws:
FitsException- if the specified header is not usable for a binary table
-
BinaryTable
Create a binary table from existing data in column order.- Parameters:
o- array of columns- Throws:
FitsException- if the data for the columns could not be used as coulumns
-
BinaryTable
Create a binary table from existing data in row order.- Parameters:
data- The data used to initialize the binary table.- Throws:
FitsException- if the data could not be converted to a binary table
-
-
Method Details
-
createColumnDataFor
TODO: this is only for internal access!- Parameters:
table- the table to create the column data.- Throws:
FitsException- if the data could not be created.
-
getTDims
Parse the TDIMS value. If the TDIMS value cannot be deciphered a one-d array with the size given in arrsiz is returned.- Parameters:
tdims- The value of the TDIMSn card.- Returns:
- An int array of the desired dimensions. Note that the order of the tdims is the inverse of the order in the TDIMS key.
-
addColumn
Description copied from interface:TableDataAdd a column to the table without any associated header information. Users should be cautious of calling this routine directly rather than the corresponding routine in AsciiTableHDU since this routine knows nothing of the FITS header modifications required.- Parameters:
o- the new column information. the newCol should be an Object[] where type of all of the constituents is identical. The length of data should match the other columns. Note: 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).- Returns:
- the number of columns in the adapted table
- Throws:
FitsException- if the operation failed
-
addFlattenedColumn
Add a column where the data is already flattened.- Parameters:
o- The new column data. This should be a one-dimensional primitive array.dims- The dimensions of one row of the column.- Returns:
- the new column size
- Throws:
FitsException- if the array could not be flattened
-
addRow
Description copied from interface:TableDataAdd a row at the end of the table. Given the way the table is structured this will normally not be very efficient.Users should be cautious of calling this routine directly rather than the corresponding routine in AsciiTableHDU since this routine knows nothing of the FITS header modifications required.- Parameters:
o- An array of elements to be added. Each element of o should be an array of primitives or a String.- Returns:
- the number of rows in the adapted table
- Throws:
FitsException- if the operation failed
-
deleteColumns
Delete a set of columns. Note that this does not fix the header, so users should normally call the routine in TableHDU. * @throws FitsException if the operation failed- Throws:
FitsException
-
deleteRows
Delete rows from a table.- Parameters:
row- The 0-indexed start of the rows to be deleted.len- The number of rows to be deleted. * @throws FitsException if the operation failed- Throws:
FitsException
-
fillHeader
Update a FITS header to reflect the current state of the data. * @throws FitsException if the operation failed- Throws:
FitsException
-
getBases
- Returns:
- the types in the table, not the underlying types (e.g., for varying length arrays or booleans).
-
getColumn
Get a given column- Parameters:
col- The index of the column. * @throws FitsException if the operation failed- Throws:
FitsException
-
getData
- Specified by:
getDatain classData- Returns:
- the data array object.
- Throws:
FitsException- if the data could not be gathered .
-
getDimens
public int[][] getDimens() -
getElement
Get a particular element from the table.- Parameters:
i- The row of the element.j- The column of the element. * @throws FitsException if the operation failed- Throws:
FitsException
-
getFlatColumns
-
getFlattenedColumn
- Parameters:
col- the column to flatten- Returns:
- column in flattened format. For large tables getting a column in standard format can be inefficient because a separate object is needed for each row. Leaving the data in flattened format means that only a single object is created.
- Throws:
FitsException- if the column could not be flattened
-
getHeapOffset
public int getHeapOffset()- Returns:
- the offset to the heap
-
getHeapSize
public int getHeapSize()- Returns:
- the size of the heap -- including the offset from the end of the table data.
-
getModelRow
- Returns:
- a row that may be used for direct i/o to the table.
-
getNCols
public int getNCols()Get the number of columns in the table. -
getNRows
public int getNRows()Get the number of rows in the table -
getRawElement
- Parameters:
i- The row of the element.j- The column of the element.- Returns:
- a particular element from the table but do no processing of this element (e.g., dimension conversion or extraction of variable length array elements/)
- Throws:
FitsException- if the operation failed
-
getRow
Get a given row- Parameters:
row- The index of the row to be returned.- Returns:
- A row of data. * @throws FitsException if the operation failed
- Throws:
FitsException
-
getSizes
public int[] getSizes() -
getTrueSize
public long getTrueSize()Get the size of the data in the HDU sans padding. -
getTypes
public char[] getTypes() -
read
Read the data -- or defer reading on random access. * @throws FitsException if the operation failed- Specified by:
readin interfaceFitsElement- Specified by:
readin classData- Parameters:
i- The input data stream- Throws:
FitsException- if the read was unsuccessful.
-
setColumn
Replace a column in the table.- Parameters:
col- The index of the column to be replaced.xcol- The new data for the column- Throws:
FitsException- Thrown if the data does not match the current column description.
-
setElement
Replace a single element within the table.- Parameters:
i- The row of the data.j- The column of the data.o- The replacement data. * @throws FitsException if the operation failed- Throws:
FitsException
-
setFlattenedColumn
Set a column with the data already flattened.- Parameters:
col- The index of the column to be replaced.data- The new data array. This should be a one-d primitive array.- Throws:
FitsException- Thrown if the type of length of the replacement data differs from the original.
-
setRow
Replace a row in the table.- Parameters:
row- The index of the row to be replaced.data- The new values for the row.- Throws:
FitsException- Thrown if the new row cannot match the existing data.
-
updateAfterDelete
Update the header after a deletion.- Throws:
FitsException- if the operation failed
-
write
Write the table, heap and padding. * @throws FitsException if the operation failed- Specified by:
writein interfaceFitsElement- Specified by:
writein classData- Parameters:
os- The output stream on which to write the data.- Throws:
FitsException- if the write was unsuccessful.
-
addByteVaryingColumn
- Throws:
TableException
-
createColumnTable
protected ColumnTable<BinaryTable.SaveState> createColumnTable(Object[] arrCol, int[] sizes) throws TableException - Throws:
TableException
-
readHeap
Read the heap which contains the data for variable length arrays. A. Kovacs (4/1/08) Separated heap reading, s.t. the heap can be properly initialized even if in deferred read mode. columnToArray() checks and initializes the heap as necessary.- Parameters:
input- stream to read from.- Throws:
FitsException- if the heap could not be read from the stream
-
readTrueData
Read table, heap and padding- Parameters:
i- the stream to read the data from.- Throws:
FitsException- if the reading failed
-
validColumn
protected boolean validColumn(int j) Check if the column number is valid.- Parameters:
j- The Java index (first=0) of the column to check.- Returns:
trueif the column is valid
-
validRow
protected boolean validRow(int i) Check to see if this is a valid row.- Parameters:
i- The Java index (first=0) of the row to check.- Returns:
trueif the row is valid
-