public class FitsNdxHandler extends Object implements NdxHandler, HdxDocumentFactory
When reading an NDX from a FITS file, the handler will look for the NDX_XML header; if one is found it will retrieve the metadata from the XML stored in the referenced table extension as described above. If this header is not present, it will make an NDX with no components apart from the image array it is pointed at and any WCS defined by FITS WCS headers in that HDU in the normal way.
The coordinate system information of an NDX written to a FITS file is currently written to the Image HDU for use by non-NDX-aware software. However, the WCS is read from the XML if present, so in the case of discrepancies between the two the WCS represented in the FITS headers may be out of date.
FitsArrayBuilder
class. If an HDU other than the first one is referenced, that is
where the NDX_XML header will be sought.
This is a singleton class; use getInstance()
to get an instance.
Modifier and Type | Method and Description |
---|---|
static FitsNdxHandler |
getInstance()
Returns a FitsNdxHandler.
|
boolean |
makeBlankNdx(URL url,
Ndx template)
Constructs a new Ndx containing writable and uninitialised
array components at the given URL with characteristics
matching those of a given template Ndx.
|
Document |
makeHdxDocument(URL url)
Obtains a Document representing the data referred to by the URL.
|
Source |
makeHdxSource(URL url)
Obtains a Source which can produce the data referred to by the
URL.
|
Ndx |
makeNdx(URL url,
AccessMode mode)
Constructs a readable Ndx based on the existing resource at a given URL.
|
void |
outputNdx(ArrayDataOutput strm,
URL url,
Ndx ndx)
Writes an NDX to a given output stream.
|
boolean |
outputNdx(URL url,
Ndx ndx)
Constructs a new Ndx which is a copy of the given Ndx at a
location determined by a given URL.
|
public static FitsNdxHandler getInstance()
public Ndx makeNdx(URL url, AccessMode mode) throws IOException
NdxHandler
null
should be returned.
If the resource exists but some error occurs in processing it,
or if this factory knows that it understands the URL but is
unable to locate such a resource then an IOException should be
thrown; however, if it is possible that a different factory could
correctly construct an Ndx from this URL then a null return
is preferred.makeNdx
in interface NdxHandler
url
- the URL of the resource from which an Ndx is to
be constructedmode
- read/write/update access mode for component arraysIOException
- if the URL is understood but an Ndx cannot
be madepublic boolean makeBlankNdx(URL url, Ndx template) throws IOException
NdxHandler
If the URL is not recognised by this handler or it is not known
how to construct such an Ndx then false
should be returned.
If the handler recognises the URL but some error occurs in
creating the new Ndx, then an IOException should be thrown;
however, if it is possible that a different handler could
correctly construct a writable Ndx as requested then a false
return is preferred.
makeBlankNdx
in interface NdxHandler
url
- a URL at which the new NDX should be writtentemplate
- a template Ndx object from which non-array data
should be initialised - all scalar components
will be copied from it, and new blank writable
array components matching the ones in it will be
createdurl
,
false if it doesn't understand this URLIOException
- if the URL is understood but an NDArray cannot
be madepublic boolean outputNdx(URL url, Ndx ndx) throws IOException
NdxHandler
The return status indicates whether such a resource was successfully created. If the URL is not recognised or this factory does not feel qualified to construct an Ndx with the given URL then it must return false. If some error occurs during construction then an IOException should in general be thrown; however if this factory thinks that another factory might have more luck then a false return is preferred.
outputNdx
in interface NdxHandler
url
- the URL at which the resource backing the Ndx is
to be writtenndx
- an Ndx whose data is to be copied to the resource
given by url
IOException
- if an error occurred during the resource
creation or data copyingpublic void outputNdx(ArrayDataOutput strm, URL url, Ndx ndx) throws IOException
strm
- the stream to which the NDX should be writtenurl
- the URL represented by the stream; may be null
ndx
- the ndx to writeIOException
public Document makeHdxDocument(URL url) throws HdxException
HdxDocumentFactory
makeHdxDocument
in interface HdxDocumentFactory
HdxException
- if we ought to be able to read this type
of URL, but processing fails for some reason. That is, do not
simply fail silently in this situation.HdxResourceType
public Source makeHdxSource(URL url) throws HdxException
HdxDocumentFactory
makeHdxSource
in interface HdxDocumentFactory
HdxException
- if we ought to be able to read this type
of URL, but processing fails for some reason. That is, do not
simply fail silently in this situation.Copyright © 2025 Central Laboratory of the Research Councils. All Rights Reserved.