SYNOPSIS
use PDL::IO::NDF;
$a = PDL->rndf($file);
$a = rndf('test_image');
$a = rndf('test_image', 1);
$a->wndf($file);
wndf($a, 'out_image');
propndfx($a, 'template', 'out_image');
DESCRIPTION
This module adds the ability to read and write Starlink N-dimensional data files as N-dimensional PDLs.You must have the Starlink NDF library installed to use it. The library is distributed under the GPL and is available from ``http://www.starlink.ac.uk''.
FUNCTIONS
rndf()
Reads a piddle from a NDF format data file.
$pdl = rndf('file.sdf'); $pdl = rndf('file.sdf',1);
The '.sdf' suffix is optional. The optional second argument turns off automatic quality masking and returns a quality array as well.
BUG? "rndf('bob.sdf',1)" calls ndf_sqmf(1,...), which means that the quality array is turned into bad pixels - ie the opposite of above. Or am I confused?
Header information and NDF Extensions are stored in the piddle as a hash which can be retreived with the "$pdl->gethdr" command. Array extensions are stored in the header as follows:
$a - the base DATA_ARRAY
If "$hdr = $a->gethdr";
then:
%{$hdr} contains all the FITS headers plus: $$hdr{Error} contains the Error/Variance PDL $$hdr{Quality} The quality byte array (if reqeusted) @{$$hdr{Axis}} Is an array of piddles containing the information for axis 0, 1, etc. $$hdr{NDF_EXT} Contains all the NDF extensions $$hdr{Hist} Contains the history information $$hdr{NDF_EXT}{_TYPES} Data types for non-PDL NDF extensions so that wndf can reconstruct a NDF.
All extension information is stored in the header hash array. Extension structures are preserved in hashes, so that the PROJ_PARS component of the IRAS.ASTROMETRY extension is stored in $$hdr{NDF_EXT}{IRAS}{ASTROMETRY}{'PROJ_PARS'}. All array structures are stored as arrays in the Hdr: numeric arrays are stored as PDLs, logical and character arrays are stored as plain Perl arrays. FITS arrays are a special case and are expanded as scalars into the header.
PDL does not have a signed byte datatype, so any '_BYTE' data is read into a "byte" (unsigned) piddle and a warning is printed to "STDOUT".
If the starlink bad flag is set, then the bad flag on the output piddle is also set. Starlink bad values are converted to the current bad value used by the piddle type (if they are different).
wndf()
Writes a piddle to a NDF format file:
$pdl->wndf($file); wndf($pdl,$file);
wndf can be used for writing PDLs to NDF files. The '.sdf' suffix is optional. All the extensions created by rndf are supported by wndf. This means that error, axis and quality arrays will be written if they exist. Extensions are also reconstructed by using their name (ie FIGARO.TEST would be expanded as a FIGARO extension and a TEST component). Hdr keywords Label, Title and Units are treated as special cases and are written to the label, title and units fields of the NDF.
Header information is written to corresponding NDF extensions. NDF extensions can also be created in the {NDF} hash by using a key containing '.', ie {NDF}{'IRAS.DATA'} would write the information to an IRAS.DATA extension in the NDF. rndf stores this as $$hdr{NDF}{IRAS}{DATA} and the two systems are interchangeable.
rndf stores type information in {NDF}{'_TYPES'} and below so that wndf can reconstruct the data type of non-PDL extensions. If no entry exists in _TYPES, wndf chooses between characters, integer and double on a best guess basis. Any perl arrays are written as CHAR array extensions (on the assumption that numeric arrays will exist as PDLs).
The bad flag is written to the file, if set.
propndfx()
Routine to write a PDL to an NDF by copying the extension information from an existing NDF and writing DATA,VARIANCE, QUALITY and AXIS info from a PDL (if they exist).Extensions, labels and history are propogated from the old NDF. No new extension information is written.
This command has been superseded by wndf().
NOTES
The perl NDF module must be available. This is available from the author or from Starlink (http://www.starlink.rl.ac.uk).If an NDF is read which contains AST World Coordinate information (a .WCS component) this information is currently ignored. Currently WCS information can only be written and stored using standard FITS headers. See <http://rlspc5.bnsc.rl.ac.uk/star/docs/sun211.htx/sun211.html#xref_> for more information on AST.