public class FitsArrayBuilder extends Object implements ArrayBuilder
URLs are given in the format
fits-url.fitor
fits-url.fit[hdu-num]where the [] represent literal square brackets or
fits-url.fit#hdu-numwhere the # represents a literal hash sign. The fits-url.fit represents the full absolute or relative URL of a FITS file, and the hdu-num, if present, is the index of the HDU within it. If no HDU is given, the first HDU (hdu-num=0) is understood.
When writing a new NDArray, if hdu-num==0 then any existing FITS file of the same name will be erased. It is possible to write to HDUs after the first one by specifying the appropriate hdu-num, but only if this refers to the first non-existent HDU in an existing FITS file.
This is a singleton class; use getInstance()
to get an instance.
Modifier and Type | Method and Description |
---|---|
static FitsArrayBuilder |
getInstance()
Returns a FitsArrayBuilder.
|
NDArray |
makeNDArray(ArrayDataInput stream,
AccessMode mode)
Makes a readable NDArray from a data input stream.
|
NDArray |
makeNDArray(URL url,
AccessMode mode)
Constructs an NDArray based on the existing resource at a given URL.
|
NDArray |
makeNewNDArray(OutputStream stream,
NDShape shape,
Type type,
BadHandler bh,
boolean primary,
HeaderCard[] cards)
Makes a new HDU written into a given stream containing an NDArray
with the type and shape as specified.
|
NDArray |
makeNewNDArray(URL url,
NDShape shape,
Type type,
BadHandler bh)
Makes a new HDU at a given URL containing an NDArray with the
shape and type as specified.
|
public static FitsArrayBuilder getInstance()
public NDArray makeNDArray(URL url, AccessMode mode) throws IOException
ArrayBuilder
If the resource storing the NDArray is incapable of storing bad values,
an NDArray using the
default bad value handling policy
should be returned.
makeNDArray
in interface ArrayBuilder
url
- the URL of the resource from which an NDArray is to
be constructedmode
- the read/update/write mode with which to create the arrayIOException
- if the URL is understood but an NDArray cannot
be madepublic NDArray makeNDArray(ArrayDataInput stream, AccessMode mode) throws IOException
ArrayDataOutput
.stream
- the input stream supplying the HDU at which the
FITS array data can be foundmode
- read/write/update access modeIOException
- if some I/O error occurs or the stream does
not contain FITS array datapublic NDArray makeNewNDArray(URL url, NDShape shape, Type type, BadHandler bh) throws IOException
makeNewNDArray
in interface ArrayBuilder
url
- the URL at which the resource backing the NDArray is
to be writtenshape
- the shape of the new NDArray to constructtype
- the primitive data type of the new NDArray to constructbh
- requested bad value handling policyIOException
- if the URL is a FITS URL but the requested
NDArray cannot be constructed for some reasonpublic NDArray makeNewNDArray(OutputStream stream, NDShape shape, Type type, BadHandler bh, boolean primary, HeaderCard[] cards) throws IOException
stream
- the stream down which the NDArray is to be writtenshape
- the shape of the new NDArray to constructtype
- the primitive data type of the new NDArray to constructbh
- requested bad value handling policyprimary
- whether this is the primary HDU (first in file)cards
- array of additional FITS header cards to add - may be nullIOException
- if there is some I/O errorCopyright © 2023 Central Laboratory of the Research Councils. All Rights Reserved.