public class FitsUtil extends Object
Modifier and Type | Field and Description |
---|---|
static int |
BLOCK_LENG
FITS block length in bytes (@value).
|
static int |
CARD_LENG
FITS header card length in bytes (@value).
|
static int |
CARDS_PER_BLOCK
Number of header cards per FITS block (@value).
|
static String |
FLOAT_REGEX
Regex pattern matching floating point value, no grouping.
|
static int |
MAX_NCOLSTD
Maximum No.
|
Modifier and Type | Method and Description |
---|---|
static Object |
asNumericArray(String txt)
Attempts to interpret a string as a formatted numeric array.
|
static void |
checkColumnCount(WideFits wide,
int ncol)
Checks that a table with the given number of columns can be written.
|
static boolean |
isFitsCharacter(int ch)
Indicates whether a given character is a legal FITS header character
(0x20..0x7e inclusive).
|
static boolean |
isMagic(byte[] buffer)
Indicates whether the supplied buffer is the start of a FITS file.
|
static ParsedCard<?> |
parseCard(byte[] buf80)
Turns an 80-byte array into a ParsedCard.
|
static FitsHeader |
readHeader(InputStream in)
Reads a FITS header from an input stream.
|
static FitsHeader |
readHeaderIfPresent(InputStream in)
Reads a FITS header from an input stream if the stream has content.
|
static long |
roundUp(long value,
int blockSize)
Utility method to round an integer value up to a multiple of
a given block size.
|
static long |
skipHDUs(InputStream in,
int nskip)
Skips forward over a given number of HDUs in the supplied stream.
|
static void |
writeEmptyPrimary(OutputStream out)
Writes a data-less Primary HDU.
|
static int |
writeHeader(CardImage[] cards,
OutputStream out)
Writes a FITS header whose content is supplied by an array of cards.
|
public static final int BLOCK_LENG
public static final int CARD_LENG
public static final int CARDS_PER_BLOCK
public static final int MAX_NCOLSTD
public static final String FLOAT_REGEX
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 boolean isFitsCharacter(int ch)
ch
- character to checkpublic static FitsHeader readHeader(InputStream in) throws IOException
in
- input stream positioned at start of HDUIOException
public static FitsHeader readHeaderIfPresent(InputStream in) throws IOException
in
- input stream positioned where an HDU may startIOException
public static ParsedCard<?> parseCard(byte[] buf80)
buf80
- 80-byte array giving card imagepublic static long skipHDUs(InputStream in, int nskip) throws IOException
in
- the stream to skip through, positioned at start of HDUnskip
- the number of HDUs to skipIOException
public static long roundUp(long value, int blockSize)
value
- non-negative countblockSize
- non-negative size of blockcount
and a multiple of blockSize
public static int writeHeader(CardImage[] cards, OutputStream out) throws IOException
cards
- cards forming content of headerout
- destination streamIOException
public static void writeEmptyPrimary(OutputStream out) throws IOException
out
- destination streamIOException
public static void checkColumnCount(WideFits wide, int ncol) throws IOException
wide
- extended column convention
- may be null for FITS standard behaviour onlyncol
- number of columns to writeIOException
- if there are too many columnspublic static Object asNumericArray(String txt)
This is a bit hacky, it doesn't correspond to prescriptions in the FITS stanard, but it's useful for some purposes.
txt
- stringCopyright © 2024 Central Laboratory of the Research Councils. All Rights Reserved.