public class FitsConstants extends Object
Modifier and Type | Field and Description |
---|---|
static HeaderCard |
END_CARD
Image of end-of-header card.
|
static int |
FITS_BLOCK
Standard size of a FITS block in bytes.
|
static int |
MAX_NCOLSTD
Maximum number of columns in standard FITS BINTABLE extension.
|
static String |
NDARRAY_ORIGIN
FITS header card for indicating NDArray origin values.
|
static String |
NDARRAY_PREFIX
Prefix for NDArray-related FITS header cards.
|
static String |
NDX_PREFIX
Prefix for NDX-related FITS header cards.
|
static String |
NDX_XML
FITS header card for location (relative URL) of XML representation.
|
static boolean |
REQUIRE_HIERARCH
Whether HIERARCH convention is used; true by default.
|
static String |
WCS_ENCODING
Default encoding used for writing WCS into FITS headers.
|
Constructor and Description |
---|
FitsConstants() |
Modifier and Type | Method and Description |
---|---|
static void |
addStringValue(Header hdr,
String key,
String value,
String comment)
Attempts to add a string-valued card to the header.
|
static void |
addTrimmedValue(Header hdr,
String key,
String value,
String comment)
Adds a string-valued card to the header.
|
static HeaderCard |
createHeaderCard(String cardImage)
Create a HeaderCard from a FITS card image.
|
static HeaderCard |
createRawHeaderCard(String keyname,
String rawvalue,
String comment)
Create a header card given the final representation of the
card value.
|
static Header |
createUnsortedHeader()
Creates a Header instance which does not perform any unsolicited
reordering of the header cards.
|
static List<String> |
defaultFitsExtensions()
Gets the default permitted list of extensions which identify a
FITS resource in the path part of a URL.
|
static long |
getDataSize(Header hdr)
Utility function to find the number of bytes in the data segment
of an HDU.
|
static ArrayDataInput |
getInputStreamStart(DataSource datsrc)
Returns an input stream which can be used with the various FITS
classes based on a given DataSource object, positioned at the
start of the stream.
|
static Iterable<HeaderCard> |
headerIterable(Header hdr)
Returns an iterable over HeaderCards for a given Header.
|
static boolean |
isMagic(byte[] buffer)
Indicates whether the supplied buffer is the start of a FITS file.
|
static int |
readHeader(Header hdr,
ArrayDataInput strm)
Populates a header from an input stream, reporting its length in bytes.
|
static long |
skipHDUs(ArrayDataInput stream,
int nskip)
Skips forward over a given number of HDUs in the supplied stream.
|
static void |
writeEmptyPrimary(DataOutput strm)
Writes a null header representing an empty primary HDU to a stream.
|
static void |
writeHeader(DataOutput strm,
Header hdr)
Writes a header object to a DataOutput.
|
public static final String NDARRAY_PREFIX
public static final HeaderCard END_CARD
public static final String NDARRAY_ORIGIN
public static final String NDX_PREFIX
public static final String NDX_XML
public static final String WCS_ENCODING
public static final int FITS_BLOCK
public static final int MAX_NCOLSTD
public static boolean REQUIRE_HIERARCH
public static List<String> defaultFitsExtensions()
public static Header createUnsortedHeader()
public static HeaderCard createHeaderCard(String cardImage)
cardImage
- the 80 character card imagepublic static HeaderCard createRawHeaderCard(String keyname, String rawvalue, String comment) throws HeaderCardException
keyname
- header card namerawvalue
- raw header card valuecomment
- comment text (ignored if too long)HeaderCardException
- if card would be too longpublic static Iterable<HeaderCard> headerIterable(Header hdr)
hdr
- headerpublic static long skipHDUs(ArrayDataInput stream, int nskip) throws IOException
stream
- the stream to skip throughnskip
- the number of HDUs to skipIOException
public static boolean isMagic(byte[] buffer)
SIMPLE =
".buffer
- a byte buffer containing
the start of a file to testtrue
iff the bytes in buffer
look like
the start of a FITS filepublic static ArrayDataInput getInputStreamStart(DataSource datsrc) throws IOException
datsrc
- the DataSource pointing to the file/HDU requireddatsrc
,IOException
public static int readHeader(Header hdr, ArrayDataInput strm) throws TruncatedFileException, IOException
Header.read(nom.tam.util.ArrayDataInput)
, but
it returns the number of bytes read from the input stream in order
to populate the header (including any padding bytes). There is
no way to retrieve this information from the Header
class
in general; though Header.getSize()
will sometimes give you the right answer, in the case of
duplicated header keywords it can give an underestimate.
This could be seen as a bug in nom.tam.fits
classes,
but there may be code somewhere which relies on that behaviour.
You can make a Header from scratch by doing
Header hdr = new Header(); int headsize = read( hdr, strm );This method also differs from the
Header
implementation
in that it does not print warnings to standard output about
duplicate keywords.hdr
- the header to populatestrm
- the input stream supplying the dataTruncatedFileException
IOException
Header.read(nom.tam.util.ArrayDataInput)
public static void writeHeader(DataOutput strm, Header hdr) throws IOException
strm
- destination streamhdr
- the header to writeIOException
public static void writeEmptyPrimary(DataOutput strm) throws IOException
strm
- stream to write toIOException
public static long getDataSize(Header hdr)
hdr
- the Headerhdr
public static void addTrimmedValue(Header hdr, String key, String value, String comment) throws HeaderCardException
hdr
- headerkey
- card keyvalue
- card valuecomment
- card commentHeaderCardException
public static void addStringValue(Header hdr, String key, String value, String comment)
hdr
- headerkey
- card keyvalue
- card valuecomment
- card commentCopyright © 2024 Central Laboratory of the Research Councils. All Rights Reserved.