uk.ac.starlink.hds
Class NdfMaker

java.lang.Object
  extended by uk.ac.starlink.hds.NdfMaker

public class NdfMaker
extends Object

Creates NDFs on disk from Ndx objects.

Author:
Mark Taylor (Starlink)

Constructor Summary
NdfMaker()
          Constructs a default NdfMaker
 
Method Summary
 HDSType getType()
          Get the type with which the NDF DATA and VARIANCE arrays will be created.
 NDShape getWindow()
          Get the shape of NDFs to be created, in the manner of an NDF section.
 void makeBlankNDF(Ndx ndx, HDSObject ndfob)
          Creates an NDF structure at a given location based on an NDX, but doesn't fill in the array components.
 void makeNDF(Ndx ndx, HDSObject ndfob)
          Populates an NDF structure at a given location with data from an NDX.
 HDSReference makeNDF(Ndx ndx, String container)
          Creates an NDF in a named container file from an NDX.
 HDSReference makeTempNDF(Ndx ndx)
          Creates an NDF in temporary filespace from an NDX.
 void setType(HDSType hdstype)
          Set the type for the DATA and, if available, VARIANCE components of created NDFs.
 void setWindow(NDShape window)
          Set the shape of NDFs to be created, in the manner of an NDF section.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NdfMaker

public NdfMaker()
Constructs a default NdfMaker

Method Detail

setType

public void setType(HDSType hdstype)
Set the type for the DATA and, if available, VARIANCE components of created NDFs. It is not necessary to do this, but since a copy of the data has to be done in any case it may be more efficient than creating a copy of the original data type and subsequently mapping the NDF array data with a different type.

Note: not all HDS types may be used: only the following are valid: _BYTE, _WORD, _INTEGER, _REAL, _DOUBLE

Parameters:
hdstype - the required data type for DATA and VARIANCE components. If null, a type corresponding to that of the NDX arrays is used.

getType

public HDSType getType()
Get the type with which the NDF DATA and VARIANCE arrays will be created.

Returns:
the HDS data type with which DATA and VARIANCE components will be created. If null, a type corresponding to that of the NDX arrays is used.

setWindow

public void setWindow(NDShape window)
Set the shape of NDFs to be created, in the manner of an NDF section.

Parameters:
window - the shape of NDFs to be written. If null, the shape of the NDX's image array will be used

getWindow

public NDShape getWindow()
Get the shape of NDFs to be created, in the manner of an NDF section.

Returns:
the shape of NDFs to be written. If null, the shape of the NDX's image array will be used

makeTempNDF

public HDSReference makeTempNDF(Ndx ndx)
                         throws IOException
Creates an NDF in temporary filespace from an NDX. The new NDF will be at the top level in a newly-created container file; its location is given by the return value of this call. It is the responsibility of the caller to delete the container file when it is no longer needed.

The container file is written in one of the following directories (listed in order of preference):

  1. the uk.ac.starlink.hds.scratch system property
  2. the java.io.tmpdir system property
  3. the current directory

Parameters:
ndx - the NDX to copy
Returns:
an HDSReference object giving the location of the new NDF structure based on ndx.
Throws:
IOException - if there was some error in parsing the NDX or creating the NDF

makeNDF

public HDSReference makeNDF(Ndx ndx,
                            String container)
                     throws IOException
Creates an NDF in a named container file from an NDX.

Parameters:
ndx - the NDX to copy
container - the pathname of a container file to which the NDF should be written. Do not include the '.sdf'. A new file container.sdf will be written and the NDF will put into the top-level structure.
Returns:
an HDSReference giving the location of the new NDF structure
Throws:
IOException - if there was some error in parsing the NDX or creating the NDF

makeNDF

public void makeNDF(Ndx ndx,
                    HDSObject ndfob)
             throws IOException
Populates an NDF structure at a given location with data from an NDX.

Parameters:
ndx - the NDX to copy
ndfob - an HDS structure into which the NDF's components are to be written
Throws:
IOException - if there was some error in parsing the NDX or creating the NDF

makeBlankNDF

public void makeBlankNDF(Ndx ndx,
                         HDSObject ndfob)
                  throws IOException
Creates an NDF structure at a given location based on an NDX, but doesn't fill in the array components.

Parameters:
ndx - the NDX to copy
ndfob - an HDS structure into which the NDF's components are to be written
Throws:
IOException - if there was some error in parsing the NDX or creating the NDF


Copyright © 2015 Central Laboratory of the Research Councils. All Rights Reserved.