which defines a transformation from Cartesian to polar coordinates. Here, the variables that appear on the left of each expression (R and THETA) provide names for the output variables and those that appear on the right (X and Y) are references to input variables.
To complement this, you must also supply expressions for the inverse transformation via the INV argument. In this case, the number of expressions given would normally match the number of MathMap input coordinates (given by the Nin attribute). If Nin is 2, you might use:
which expresses the transformation from polar to Cartesian coordinates. Note that here the input variables (X and Y) are named on the left of each expression, and the output variables (R and THETA) are referenced on the right.
Normally, you cannot refer to a variable on the right of an expression unless it is named on the left of an expression in the complementary set of functions. Therefore both sets of functions (forward and inverse) must be formulated using the same consistent set of variable names. This means that if you wish to leave one of the transformations undefined, you must supply dummy expressions which simply name each of the output (or input) variables. For example, you might use:
for the inverse transformation above, which serves to name the input variables but without defining an inverse transformation.
Here, we first calculate three intermediate results (R, ROUT and THETA) and then use these to calculate the final results (XOUT and YOUT). The MathMap knows that only the final two results constitute values for the output variables because its Nout attribute is set to 2. You may define as many intermediate variables in this way as you choose. Having defined a variable, you may then refer to it on the right of any subsequent expressions.
Note that when defining the inverse transformation you may only refer to the output variables XOUT and YOUT. The intermediate variables R, ROUT and THETA (above) are private to the forward transformation and may not be referenced by the inverse transformation. The inverse transformation may, however, define its own private intermediate variables.
A <bad> result (i.e. equal to AST__BAD) is also produced in response to any numerical error (such as division by zero or numerical overflow), or if an invalid argument value is provided to a function or operator.
The following logical operators are available:
The following relational operators are available:
Note that relational operators cannot usefully be used to compare values with the <bad> value (representing missing data), because the result is always <bad>. The ISBAD() function should be used instead.
Note, also, that because logical operators can operate on floating point values, care must be taken to use parentheses in some cases where they would not normally be required in Fortran. For example, the expresssion:
must be written:
to prevent the .NOT. operator from associating with the variable A.
The following bitwise operators are available:
Note that no bit inversion operator is provided. This is
because inverting the bits of a twos-complement fixed point binary
number is equivalent to simply negating it. This differs from the
pure integer case because bits to the right of the binary point are
also inverted. To invert only those bits to the left of the binary
point, use a bitwise exclusive OR with the value -1 (i.e. X-1).
All operators associate from left-to-right, except for unary +, unary -, !, .not. and ** which associate from right-to-left.
AST A Library for Handling World Coordinate Systems in Astronomy