16 Using Quality Names

 16.1 Introduction
 16.2 Quality Names
 16.3 Quality Expressions

16.1 Introduction

As described in Section 15, an NDF may optionally contain a component called QUALITY. If this component exists, it will be an array with the same bounds as the main DATA array. Each element in the QUALITY array can be used to store several flags that are associated with the corresponding element in the DATA array. These flags may be used to indicate that the DATA value holds some specified property. For instance, one of the flags may be used to indicate if the corresponding DATA values are saturated, another may be used to indicate if the DATA value lies within a background area, and so on.

You are free to use the flags in whatever way seems most suited to the particular process being performed. You can set (or reset) any of the flags within any sub-region of the NDF using application SETQUAL. Each of the flags is referred to by a Quality Name specified by the user. Names that reflect the nature of the quality should be used, e.g. the quality name SATURATED could be used to flag saturated data values. These quality names get stored within the NDF and can be used to refer to the quality flag when running later applications. The terminology adopted here is that an element of the DATA array ‘holds’ the quality SATURATED (for instance) if the flag that is associated with the quality name SATURATED is set for the corresponding element within the QUALITY array.

The number of quality names that can be stored within an NDF is limited, and therefore it may become necessary to remove quality names that are no longer needed to make room for new ones. The applications SHOWQUAL and REMQUAL allow you to do this. SHOWQUAL displays a list of the quality names currently defined within an NDF, and REMQUAL removes specified quality names from an NDF.

Some applications have a Parameter QEXP, which may be used to specify that the application is only to use data values that hold a specified selection of qualities. As an example, when running QUALTOBAD you could (for instance) specify a value of BACKGROUND for the QEXP parameter. This means that only those data values for which the flag associated with the quality name BACKGROUND is set, are to be set bad. The quality name BACKGROUND must previously have been defined and assigned to the appropriate data values using application SETQUAL.

The specification of the data values to be used by an application can be more complex than this, and can depend on several qualities combined together using ‘Boolean’ operators. For instance, assigning the value .NOT. (SOURCE_A .OR. SOURCE_B) would cause the application to use only those data values that hold neither of the qualities SOURCE_A and/or SOURCE_B. These sort of strings are known as quality expressions.

16.2 Quality Names

Quality names are names by which the user refers to particular flags stored in the QUALITY  component of the NDF. They must not be longer than 15 characters. Leading blanks are ignored, and they are always stored in upper case, even if they are supplied by the user in lower case. Embedded blanks are considered to be significant. Quality names must not contain any fullstops ("."), and there are three reserved names that cannot be used; these are ANY, IRQ_BAD_SLOT and IRQ_FREE_SLOT.

16.3 Quality Expressions

Quality names may be combined together using Boolean operators into complex quality expressions. The quality expression is evaluated at each element within the NDF by substituting a value of true or false for each quality name used in the expression, depending on whether or not that element holds the specified quality. Elements are used if the quality expression evaluates to a true value. Boolean operators are delimited on each side by a period (e.g. .AND. ). The operands on which these operators act must be either a quality name (which must be defined within the NDF), or one of the Boolean constants .TRUE. and .FALSE. Parentheses can be used to nest expressions.

Quality expressions can be up to 254 characters long, and must not contain more than 40 symbols (Boolean operators, constants, or quality names). Some attempts are made to simplify a quality expression to reduce the run time needed to evaluate the expression for every data value.

The precedence of the Boolean operators decreases in the following order; .NOT., .AND., .OR., .XOR., .EQV. (the final two have equal precedence). In an expression such as ( A .XOR. B .EQV. C .XOR. D ) in which all operators have equal precedence, the evaluation proceeds from left to right, i.e. the expression is evaluated as ( ( ( A .XOR. B ) .EQV. C ) .XOR. D ). If there is any doubt about the order in which an expression will be evaluated, parentheses should be used to ensure the required order of evaluation.

.NOT.
- The expression (.NOT.A) is true only if A is false.
.AND.
- The expression (A.AND.B) is true only if A and B are both true.
.OR.
- The expression (A.OR.B) is true if either (or both) of A or B are true.
.XOR.
- The expression (A.XOR.B) is true if either A is true and B is false, or A is false and B is true.
.EQV.
- The expression (A.EQV.B) is true if either A is true and B is true, or A is false and B is false.