Package nom.tam.fits

Class TableHDU<T extends AbstractTableData>

    • Field Detail

      • LOG

        private static final java.util.logging.Logger LOG
    • Constructor Detail

      • TableHDU

        protected TableHDU​(Header hdr,
                           T td)
        Create the TableHDU. Note that this will normally only be invoked by subclasses in the FITS package.
        Parameters:
        hdr - the header
        td - The data for the table.
    • Method Detail

      • addColumn

        public int addColumn​(java.lang.Object newCol)
                      throws FitsException
        Add a column to the table without any associated header information.
        Parameters:
        newCol - 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
      • addRow

        public int addRow​(java.lang.Object[] newRows)
                   throws FitsException
        Add a row to the end of the table. If this is the first row, then this will add appropriate columns for each of the entries. The rows to add must be supplied as column based array of arrays.
        Parameters:
        newRows - rows to add to the table
        Returns:
        the number of rows in the adapted table
        Throws:
        FitsException - if the operation failed
      • columnKeyStems

        protected abstract IFitsHeader[] columnKeyStems()
        Returns:
        the stems of the keywords that are associated with table columns. Users can supplement this with their own and call the appropriate deleteColumns fields.
      • deleteColumnsIndexOne

        public void deleteColumnsIndexOne​(int column,
                                          int len)
                                   throws FitsException
        Delete a set of columns from a table.
        Parameters:
        column - The one-indexed start column.
        len - The number of columns to delete.
        Throws:
        FitsException - if the operation failed
      • deleteColumnsIndexOne

        public void deleteColumnsIndexOne​(int column,
                                          int len,
                                          java.lang.String[] fields)
                                   throws FitsException
        Delete a set of columns from a table.
        Parameters:
        column - The one-indexed start column.
        len - The number of columns to delete.
        fields - Stems for the header fields to be removed for the table.
        Throws:
        FitsException - if the operation failed
      • deleteColumnsIndexZero

        public void deleteColumnsIndexZero​(int column,
                                           int len)
                                    throws FitsException
        Delete a set of columns from a table.
        Parameters:
        column - The one-indexed start column.
        len - The number of columns to delete.
        Throws:
        FitsException - if the operation failed
      • deleteColumnsIndexZero

        public void deleteColumnsIndexZero​(int column,
                                           int len,
                                           IFitsHeader[] fields)
                                    throws FitsException
        Delete a set of columns from a table.
        Parameters:
        column - The zero-indexed start column.
        len - The number of columns to delete.
        fields - Stems for the header fields to be removed for the table.
        Throws:
        FitsException - if the operation failed
      • deleteRows

        public void deleteRows​(int row)
                        throws FitsException
        Remove all rows from the table starting at some specific index from the table. Inspired by a routine by R. Mathar but re-implemented using the DataTable and changes to AsciiTable so that it can be done easily for both Binary and ASCII tables.
        Parameters:
        row - the (0-based) index of the first row to be deleted.
        Throws:
        FitsException - if an error occurs.
      • deleteRows

        public void deleteRows​(int firstRow,
                               int nRow)
                        throws FitsException
        Remove a number of adjacent rows from the table. This routine was inspired by code by R.Mathar but re-implemented using changes in the ColumnTable class abd AsciiTable so that we can do it for all FITS tables.
        Parameters:
        firstRow - the (0-based) index of the first row to be deleted. This is zero-based indexing: 0<=firstrow< number of rows.
        nRow - the total number of rows to be deleted.
        Throws:
        FitsException - If an error occurs in the deletion.
      • findColumn

        public int findColumn​(java.lang.String colName)
        Find the 0-based column index corresponding to a particular column name.
        Parameters:
        colName - the name of the column
        Returns:
        index of the column
      • getColumn

        public java.lang.Object getColumn​(int col)
                                   throws FitsException
        Parameters:
        col - column index to get
        Returns:
        a specific column from the table using 0-based column indexing.
        Throws:
        FitsException - if the operation failed
      • getColumn

        public java.lang.Object getColumn​(java.lang.String colName)
                                   throws FitsException
        Parameters:
        colName - The name of the column to be extracted.
        Returns:
        a specific column of the table where the column name is specified using the TTYPEn keywords in the header.
        Throws:
        FitsException - if the operation failed
      • getColumnFormat

        public java.lang.String getColumnFormat​(int index)
                                         throws FitsException
        Get the FITS type of a column in the table.
        Parameters:
        index - The 0-based index of the column.
        Returns:
        The FITS type.
        Throws:
        FitsException - if an invalid index was requested.
      • getColumnMeta

        public java.lang.String getColumnMeta​(int index,
                                              java.lang.String type)
        Convenience method for getting column data. Note that this works only for metadata that returns a string value. This is equivalent to getStringValue(type+index);
        Parameters:
        index - index of the colum
        type - the key type to get
        Returns:
        meta data string value
      • getColumnName

        public java.lang.String getColumnName​(int index)
        Get the name of a column in the table.
        Parameters:
        index - The 0-based column index.
        Returns:
        The column name.
      • getColumns

        public java.lang.Object[] getColumns()
                                      throws FitsException
        Returns:
        all of the columns of the table.
        Throws:
        FitsException - if the operation failed
      • getElement

        public java.lang.Object getElement​(int row,
                                           int col)
                                    throws FitsException
        Parameters:
        row - the row index of the element
        col - the column index of the element
        Returns:
        a specific element of the table using 0-based indices.
        Throws:
        FitsException - if the operation failed
      • getNCols

        public int getNCols()
        Get the number of columns for this table
        Returns:
        The number of columns in the table.
      • getNRows

        public int getNRows()
        Get the number of rows for this table
        Returns:
        The number of rows in the table.
      • getRow

        public java.lang.Object[] getRow​(int row)
                                  throws FitsException
        Parameters:
        row - the index of the row to retreive
        Returns:
        a specific row of the table.
        Throws:
        FitsException - if the operation failed
      • setColumn

        public void setColumn​(int col,
                              java.lang.Object newCol)
                       throws FitsException
        Update a column within a table. The new column should have the same format ast the column being replaced.
        Parameters:
        col - index of the column to replace
        newCol - the replacement column
        Throws:
        FitsException - if the operation failed
      • setColumn

        public void setColumn​(java.lang.String colName,
                              java.lang.Object newCol)
                       throws FitsException
        Update a column within a table. The new column should have the same format as the column being replaced.
        Parameters:
        colName - name of the column to replace
        newCol - the replacement column
        Throws:
        FitsException - if the operation failed
      • setColumnMeta

        public void setColumnMeta​(int index,
                                  IFitsHeader key,
                                  java.lang.String value,
                                  java.lang.String comment,
                                  boolean after)
                           throws FitsException
        Specify column metadata for a given column in a way that allows all of the column metadata for a given column to be organized together.
        Parameters:
        index - The 0-based index of the column
        key - The column key. I.e., the keyword will be key+(index+1)
        value - The value to be placed in the header.
        comment - The comment for the header
        after - Should the header card be after the current column metadata block (true), or immediately before the TFORM card (false). @throws FitsException if the operation failed
        Throws:
        FitsException - if the header could not be updated
      • setColumnMeta

        public void setColumnMeta​(int index,
                                  java.lang.String key,
                                  boolean value,
                                  java.lang.String comment,
                                  boolean after)
                           throws FitsException
        Throws:
        FitsException
      • setColumnMeta

        public void setColumnMeta​(int index,
                                  java.lang.String key,
                                  double value,
                                  java.lang.String comment,
                                  boolean after)
                           throws FitsException
        Throws:
        FitsException
      • setColumnMeta

        public void setColumnMeta​(int index,
                                  java.lang.String key,
                                  double value,
                                  int precision,
                                  java.lang.String comment,
                                  boolean after)
                           throws FitsException
        Throws:
        FitsException
      • setColumnMeta

        public void setColumnMeta​(int index,
                                  java.lang.String key,
                                  long value,
                                  java.lang.String comment,
                                  boolean after)
                           throws FitsException
        Throws:
        FitsException
      • setColumnMeta

        public void setColumnMeta​(int index,
                                  java.lang.String key,
                                  java.lang.String value,
                                  java.lang.String comment)
                           throws FitsException
        Throws:
        FitsException
      • setColumnMeta

        @Deprecated
        public void setColumnMeta​(int index,
                                  java.lang.String key,
                                  java.lang.String value,
                                  java.lang.String comment,
                                  boolean after)
                           throws FitsException
        Specify column metadata for a given column in a way that allows all of the column metadata for a given column to be organized together.
        Parameters:
        index - The 0-based index of the column
        key - The column key. I.e., the keyword will be key+(index+1)
        value - The value to be placed in the header.
        comment - The comment for the header
        after - Should the header card be after the current column metadata block (true), or immediately before the TFORM card (false). @throws FitsException if the operation failed
        Throws:
        FitsException - if the header could not be updated
      • setColumnName

        public void setColumnName​(int index,
                                  java.lang.String name,
                                  java.lang.String comment)
                           throws FitsException
        Throws:
        FitsException
      • setCurrentColumn

        public void setCurrentColumn​(int col)
        Set the cursor in the header to point after the metadata for the specified column
        Parameters:
        col - The 0-based index of the column
      • setCurrentColumn

        public void setCurrentColumn​(int col,
                                     boolean after)
        Set the cursor in the header to point either before the TFORM value or after the column metadat
        Parameters:
        col - The 0-based index of the column
        after - True if the cursor should be placed after the existing column metadata or false if the cursor is to be placed before the TFORM value. If no corresponding TFORM is found, the cursoe will be placed at the end of current header.
      • setElement

        public void setElement​(int row,
                               int col,
                               java.lang.Object element)
                        throws FitsException
        Update a single element within the table.
        Parameters:
        row - the row index
        col - the column index
        element - the replacement element
        Throws:
        FitsException - if the operation failed
      • setRow

        public void setRow​(int row,
                           java.lang.Object[] newRow)
                    throws FitsException
        Update a row within a table.
        Parameters:
        row - row index
        newRow - the replacement row
        Throws:
        FitsException - if the operation failed