Class FitsTableWriter

java.lang.Object
uk.ac.starlink.table.StreamStarTableWriter
uk.ac.starlink.fits.AbstractFitsTableWriter
uk.ac.starlink.fits.FitsTableWriter
All Implemented Interfaces:
uk.ac.starlink.table.MultiStarTableWriter, uk.ac.starlink.table.StarTableWriter

public class FitsTableWriter extends AbstractFitsTableWriter
Handles writing of a StarTable in FITS binary format. Not all columns can be written to a FITS table, only those ones whose contentClass is in the following list:
  • Boolean
  • Character
  • Byte
  • Short
  • Integer
  • Long
  • Float
  • Double
  • Character
  • String
  • boolean[]
  • char[]
  • byte[]
  • short[]
  • int[]
  • long[]
  • float[]
  • double[]
  • String[]
In all other cases a warning message will be logged and the column will be ignored for writing purposes.

Output is currently to fixed-width columns only. For StarTable columns of variable size, a first pass is made through the table data to determine the largest size they assume, and the size in the output table is set to the largest of these. Excess space is padded with some sort of blank value (NaN for floating point values, spaces for strings, zero-like values otherwise).

Author:
Mark Taylor (Starlink)
  • Constructor Details

    • FitsTableWriter

      public FitsTableWriter()
      Default constructor.
    • FitsTableWriter

      @Deprecated public FitsTableWriter(String name, boolean allowSignedByte, WideFits wide)
      Deprecated.
      allows some configuration options but not others; use no-arg constructor and configuration methods instead
      Deprecated custom constructor.
  • Method Details

    • looksLikeFile

      public boolean looksLikeFile(String location)
      Returns true if location ends with something like ".fit" or ".fits" or ".fts".
      Parameters:
      location - filename
      Returns:
      true if it sounds like a fits file
    • setPrimaryType

      public void setPrimaryType(FitsTableWriter.PrimaryType primaryType)
      Sets the type of Primary HDU that will precede the extension HDU(s) corresponding to the table(s) being written.
      Parameters:
      primaryType - type of primary HDU
    • getPrimaryType

      public FitsTableWriter.PrimaryType getPrimaryType()
      Returns the type of Primary HDU that will precede the extension HDU(s) corresponding to the table(s) being written.
      Returns:
      type of primary HDU
    • setColfits

      public void setColfits(boolean colfits)
      Sets whether table data should be written in column-oriented form. If true, the output will be a single-row table of array-valued columns, in which each cell is an array with nrow elements.
      Parameters:
      colfits - true for column-oriented, false for row-oriented
    • isColfits

      public boolean isColfits()
      Returns whether table data will be written in column-oriented form.
      Returns:
      true for column-oriented, false for row-oriented
    • setVarArray

      public void setVarArray(FitsTableWriter.VarArrayMode varArray)
      Configures how variable-length array values will be stored.
      Parameters:
      varArray - variable-length array storage mode
    • getVarArray

      public FitsTableWriter.VarArrayMode getVarArray()
      Indicates how variable-length array valued columns will be stored.
      Returns:
      variable-length array storage mode
    • setStoragePolicy

      public void setStoragePolicy(uk.ac.starlink.table.StoragePolicy storage)
      Sets the storage policy to use where required. This is only relevant for column-oriented output, for which data has to be cached before rewriting it.
      Parameters:
      storage - storage policy to use when writing colfits
    • getStoragePolicy

      public uk.ac.starlink.table.StoragePolicy getStoragePolicy()
      Returns the storage policy that will be used if required.
      Returns:
      storage policy used when writing colfits
    • getAllowSignedByte

      public boolean getAllowSignedByte()
      Description copied from class: AbstractFitsTableWriter
      Returns a flag indicating how Byte-valued columns are written.
      Overrides:
      getAllowSignedByte in class AbstractFitsTableWriter
      Returns:
      true to write offset bytes, false to write shorts
    • createSerializer

      public FitsTableSerializer createSerializer(uk.ac.starlink.table.StarTable table) throws IOException
      Description copied from class: AbstractFitsTableWriter
      Provides a suitable serializer for a given table. Note this should throw an IOException if it can be determined that the submitted table cannot be written by this writer, for instance if it has too many columns.
      Specified by:
      createSerializer in class AbstractFitsTableWriter
      Parameters:
      table - table to serialize
      Returns:
      FITS serializer
      Throws:
      IOException - if the table can't be written
    • writeStarTables

      public void writeStarTables(uk.ac.starlink.table.TableSequence tableSeq, OutputStream out) throws IOException
      Description copied from class: AbstractFitsTableWriter
      Writes tables. Calls AbstractFitsTableWriter.writePrimaryHDU(java.io.OutputStream) to write the primary HDU. Subclasses which want to put something related to the input tables into the primary HDU will need to override this method (writeStarTables).
      Specified by:
      writeStarTables in interface uk.ac.starlink.table.MultiStarTableWriter
      Overrides:
      writeStarTables in class AbstractFitsTableWriter
      Throws:
      IOException