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
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[]
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)
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classCharacterises the type of Primary HDU that will precede table extensions written by this writer.static enumEnumeration for variable-length array value storage options. -
Constructor Summary
ConstructorsConstructorDescriptionDefault constructor.FitsTableWriter(String name, boolean allowSignedByte, WideFits wide) Deprecated.allows some configuration options but not others; use no-arg constructor and configuration methods instead -
Method Summary
Modifier and TypeMethodDescriptioncreateSerializer(uk.ac.starlink.table.StarTable table) Provides a suitable serializer for a given table.booleanReturns a flag indicating how Byte-valued columns are written.Returns the type of Primary HDU that will precede the extension HDU(s) corresponding to the table(s) being written.uk.ac.starlink.table.StoragePolicyReturns the storage policy that will be used if required.Indicates how variable-length array valued columns will be stored.booleanReturns whether table data will be written in column-oriented form.booleanlooksLikeFile(String location) Returns true iflocationends with something like ".fit" or ".fits" or ".fts".voidsetColfits(boolean colfits) Sets whether table data should be written in column-oriented form.voidsetPrimaryType(FitsTableWriter.PrimaryType primaryType) Sets the type of Primary HDU that will precede the extension HDU(s) corresponding to the table(s) being written.voidsetStoragePolicy(uk.ac.starlink.table.StoragePolicy storage) Sets the storage policy to use where required.voidsetVarArray(FitsTableWriter.VarArrayMode varArray) Configures how variable-length array values will be stored.voidwriteStarTables(uk.ac.starlink.table.TableSequence tableSeq, OutputStream out) Writes tables.Methods inherited from class AbstractFitsTableWriter
getAllowZeroLengthString, getConfig, getCurrentDate, getFormatName, getMetadataCards, getMimeType, getPadCharacter, getWide, getWriteDate, setAllowSignedByte, setAllowZeroLengthString, setFormatName, setPadCharacter, setWide, setWriteDate, writePrimaryHDU, writeStarTable, writeStarTables, writeTableHDUMethods inherited from class uk.ac.starlink.table.StreamStarTableWriter
writeStarTable, writeStarTableMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface uk.ac.starlink.table.StarTableWriter
writeStarTable
-
Constructor Details
-
FitsTableWriter
public FitsTableWriter()Default constructor. -
FitsTableWriter
Deprecated.allows some configuration options but not others; use no-arg constructor and configuration methods insteadDeprecated custom constructor.
-
-
Method Details
-
looksLikeFile
Returns true iflocationends with something like ".fit" or ".fits" or ".fts".- Parameters:
location- filename- Returns:
- true if it sounds like a fits file
-
setPrimaryType
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
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 withnrowelements.- 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
Configures how variable-length array values will be stored.- Parameters:
varArray- variable-length array storage mode
-
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:AbstractFitsTableWriterReturns a flag indicating how Byte-valued columns are written.- Overrides:
getAllowSignedBytein classAbstractFitsTableWriter- 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:AbstractFitsTableWriterProvides 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:
createSerializerin classAbstractFitsTableWriter- 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:AbstractFitsTableWriterWrites tables. CallsAbstractFitsTableWriter.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:
writeStarTablesin interfaceuk.ac.starlink.table.MultiStarTableWriter- Overrides:
writeStarTablesin classAbstractFitsTableWriter- Throws:
IOException
-