next up previous
Next: Deleting Extensions
Up: EXTENSIONS
Previous: Creating New Extensions

Accessing Array Information in Extensions   

It is relatively common to store quite large amounts of information in NDF extensions and this may include arrays whose size and shape matches that of the main NDF data array itself. In this case, the close association between the NDF_ routines and the ARY_ library (SUN/11) provides a number of convenient features for accessing this information.

For example, suppose that an astronomical instrument produces data in NDF format and also produces a measure of (say) temperature for each pixel of the NDF. This temperature information might conveniently be stored as an array within an NDF extension so that it is available during data reduction. The ARRAY data structure, which is handled by the ARY_ routines (a primitive HDS array is an example), would be convenient for this purpose since it also allows arbitrary pixel-index bounds which may be chosen to match those of the associated NDF.

To access the temperature information, we could use the techniques discussed above to locate the array within its extension and then to import it into the ARY_ system. This system provides analogous facilities to the NDF_ routines except that it applies to ARRAY data structures. In particular, the ARY_MAP routine may be used to obtain mapped access to an array, so that the process of accessing the temperature data might be as follows:

*  Obtain a locator to the extension.
      CALL NDF_XLOC( INDF, 'INSTR_EXTN', 'READ', LOC, STATUS )

*  Find the array within the extension.
      CALL ARY_FIND( LOC, 'TEMPERATURE', IARY, STATUS )

*  Map the array for access.
      CALL ARY_MAP( IARY, '_REAL', 'READ', PNTR, EL, STATUS )

      <access the mapped array values>

*  Clean up.
      CALL ARY_ANNUL( IARY, STATUS )
      CALL DAT_ANNUL( LOC, STATUS )

Here, the integer value IARY is an ARY_ system identifier, analogous to an NDF identifier.

A more convenient method of achieving the same result would be to call the routine NDF_XIARY, which combines the process of locating the extension and finding the array into a single call, as follows:

      CALL NDF_XIARY( INDF, 'INSTR_EXTN', 'TEMPERATURE', 'READ', IARY, STATUS )
      CALL ARY_MAP( IARY, '_REAL', 'READ', PNTR, EL, STATUS )

      <access the mapped array values>

      CALL ARY_ANNUL( IARY, STATUS )

An additional advantage of this latter method is that NDF_XIARY will check whether the NDF identifier refers to an NDF section and will, if necessary, select a matching section from the temperature array (for a discussion of NDF sections, see §[*]). NDF_XIARY is also able to accept a compound HDS component name as its third argument, and can therefore access arrays nested more deeply within an extension.



next up previous
Next: Deleting Extensions
Up: EXTENSIONS
Previous: Creating New Extensions


Starlink User Note 33
R.F. Warren-Smith
11th January 2000
E-mail:rfws@star.rl.ac.uk

Copyright © 2000 Council for the Central Laboratory of the Research Councils