Next: Combining Mappings in Parallel
Up: Compound Mappings (CmpMaps)
Previous: Compound Mappings (CmpMaps)

## Combining Mappings in Series

Consider a simple example based on two 2-dimensional coordinate systems. Suppose that to convert from one to the other we must swap the coordinate order and multiply both coordinates by 5, so that the coordinates () transform into (). This can be done in two stages:

1. Apply a PermMap () to swap the coordinate order.

2. Apply a ZoomMap () to multiply both coordinate values by the constant 5.

The PermMap and ZoomMap are then said to operate in series, because they are applied sequentially (c.f. Figure ). We can create a CmpMap that applies these Mappings in series as follows:

```      INCLUDE 'AST_PAR'
INTEGER CMPMAP, PERMMAP, STATUS, ZOOMMAP
INTEGER INPERM( 2 ), OUTPERM( 2 ), CONST( 1 )
DATA INPERM / 1, 2 /
DATA OUTPERM / 1, 2 /

STATUS = 0

...

*  Create the individual Mappings.
PERMMAP = AST_PERMMAP( 2, INPERM, 2, OUTPERM, CONST, ' ', STATUS )
ZOOMMAP = AST_ZOOMMAP( 2, 5.0D0, ' ', STATUS )

*  Combine them in series.
CMPMAP = AST_CMPMAP( PERMMAP, ZOOMMAP, .TRUE., ' ', STATUS )

*  Annul the individual Mapping pointers.
CALL AST_ANNUL( PERMMAP, STATUS )
CALL AST_ANNUL( ZOOMMAP, STATUS )
```

Here, the third argument (.TRUE.) of the constructor function AST_CMPMAP indicates ``in series''.

When used to transform coordinates in the forward direction, the resulting CmpMap will apply the first component Mapping (the PermMap) and then the second one (the ZoomMap). When transforming in the inverse direction, it will apply the second one (in the inverse direction) and then the first one (also in the inverse direction). In general, although not in this particular example, the order in which the two component Mappings are supplied is significant. Clearly, also, the Nout attribute (number of output coordinates) for the first Mapping must equal the Nin attribute (number of input coordinates) for the second one.

Next: Combining Mappings in Parallel
Up: Compound Mappings (CmpMaps)
Previous: Compound Mappings (CmpMaps)

AST A Library for Handling World Coordinate Systems in Astronomy
Starlink User Note 210
R.F. Warren-Smith & D.S. Berry
7th December 2012