uk.ac.starlink.fits
Class FitsTableWriter

java.lang.Object
  |
  +--uk.ac.starlink.table.StreamStarTableWriter
        |
        +--uk.ac.starlink.fits.FitsTableWriter
All Implemented Interfaces:
StarTableWriter
Direct Known Subclasses:
FitsPlusTableWriter

public class FitsTableWriter
extends StreamStarTableWriter

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:

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).

Null cell values are written using some zero-like value, not a proper blank value. Doing this right would require some changes to the tables infrastructure.


Constructor Summary
FitsTableWriter()
           
 
Method Summary
 String getFormatName()
          Returns "FITS".
 boolean looksLikeFile(String location)
          Returns true if location ends with something like ".fit" or ".fits" or ".fts".
protected  void writePrimary(StarTable startab, DataOutputStream strm)
          Called from writeStarTable(uk.ac.starlink.table.StarTable, java.io.OutputStream) to write headers prior to the BINTABLE header which contains the table proper.
 void writeStarTable(StarTable startab, OutputStream out)
          Writes a table in FITS binary format.
 
Methods inherited from class uk.ac.starlink.table.StreamStarTableWriter
writeStarTable
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FitsTableWriter

public FitsTableWriter()
Method Detail

getFormatName

public String getFormatName()
Returns "FITS".

Returns:
format name

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

writeStarTable

public void writeStarTable(StarTable startab,
                           OutputStream out)
                    throws IOException
Writes a table in FITS binary format. Currently the output is to a new file called location, in the first extension (HDU 0 is a dummy header, since the primary HDU cannot hold a table).

Parameters:
startab - the table to write
out - the output stream to which startab should be written
Throws:
IOException - if there is some I/O error

writePrimary

protected void writePrimary(StarTable startab,
                            DataOutputStream strm)
                     throws IOException
Called from writeStarTable(uk.ac.starlink.table.StarTable, java.io.OutputStream) to write headers prior to the BINTABLE header which contains the table proper. The default implementation writes an empty primary HDU; subclasses may write one or more headers, though the first one should be a legal primary FITS HDU.

Parameters:
startab - the table which will be written into the next HDU
strm - the stream down which it will be written
IOException

Copyright © 2004 CLRC: Central Laboratory of the Research Councils. All rights reserved.