next up previous
Next: THE QUALITY COMPONENT IN MORE DETAIL
Up: BAD PIXELS
Previous: Interaction with Initialisation Options

A Practical Template for Handling the Bad-Pixel Flag   

The detailed discussion of the bad-pixel flag above will probably have obscured what needs to be done in practice when writing a simple application, so this section is intended to redress the balance. The overall message is that the NDF_ system will look after all the details. The only golden rule to be followed is:

If you alter the values in an array component, then use NDF_SBAD to update the bad-pixel flag before unmapping it.

The following program fragment shows what action is typically required:

      INTEGER PNTR1( 1 ), PNTR( 1 ), EL, NBAD
      LOGICAL BAD

      ...

*  Map the input array for reading and the output array for writing.
      CALL NDF_MAP( INDF1, 'Data', '_REAL', 'READ', PNTR1, EL, STATUS )
      CALL NDF_MAP( INDF2, 'Data', '_REAL', 'WRITE', PNTR2, EL, STATUS )

*  See if the mapped input array may contain bad pixels.
      CALL NDF_BAD( INDF1, 'Data', .FALSE., BAD, STATUS )

      ...

      <process the data, counting new bad pixels in NBAD>

      ...

*  See if there may be bad pixels in the output array and declare their
*  presence/absence.
      BAD = BAD .OR. ( NBAD .NE. 0 )
      CALL NDF_SBAD( BAD, INDF2, 'Data', STATUS )

*  Unmap the arrays.
      CALL NDF_UNMAP( INDF1, 'Data', STATUS )
      CALL NDF_UNMAP( INDF2, 'Data', STATUS )

In this example, a single input data array is being processed to produce a single output array and the application proceeds as follows:

1.
After mapping the arrays as required, it enquires whether the mapped input values may contain bad pixels.
2.
The main processing stage then takes place, during which additional bad pixels may be introduced. Some indication is needed of whether this has occurred; in this case a count of the number of new bad pixels is assumed to be returned in NBAD.

3.
The bad-pixel flag for the output array is updated, taking account of bad pixels which were present initially, and those introduced by the processing performed above.

4.
The arrays are then unmapped.

In cases where the processing algorithm provides no clear indication of whether bad pixels may have been introduced, the application would need to err on the side of caution and set the output bad-pixel flag to .TRUE..



next up previous
Next: THE QUALITY COMPONENT IN MORE DETAIL
Up: BAD PIXELS
Previous: Interaction with Initialisation Options


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