##
Handling Missing (Bad) Coordinate Values

Even when coordinates can, in principle, be transformed in either direction by a MappingMapping, there may still be instances where specific coordinate values cannot be handled. For example, the Mapping may be mathematically intractable (e.g. singular) in certain places, or it may map a subset of one space on to another, so that some points in one space are not represented in the other. Sky projections often show this behaviour, since it is quite common to project only half of the celestial sphere on to two dimensions, omitting points on the opposite side of the sky. There are many other examples.

To indicate when coordinates cannot be transformed, for whatever reason, AST substitutes a special output coordinate value given by the macro AST__BAD (as defined in the “ast.h” header file). Before making use of coordinates generated by any of the AST transformation functions, therefore, you may need to check for the presence of this value.

Because coordinates with the value AST__BAD can be generated in this way, all other AST functions are also capable of recognising this value and handling it appropriately. The coordinate transformation functions do this by propagating any missing input coordinate information through to their output. This means that if you supply coordinates with the value AST__BAD, the returned coordinates are also likely to contain this value. Here, for example, is what happens if you use a ZoomMapZoomMap (with ZoomZoom factor 5) to transform such a set of coordinates:

77#77

The AST__BAD value is represented by the string “1#1bad2#2”. This is a case of “garbage in, garbage out” but at least it's consistent garbage that you can recognise!

Note how the presence of the AST__BAD value in one input dimension does not necessarily result in the loss of information for all output dimensions. Sometimes, such loss will be unavoidable, but in general an attempt is made to preserve information as far as possible. The exact behaviour will depend on the Mapping involved.