For my first mapping I wrote UnitNormMap, a map outputs unit vector and norm relative to a specified center. This can then be used with a 1-dimensional PolyMap to make a radial polynomial map, which can be used to model optical distortion.
I modified a copy of astShiftMap. This required creating the actual .c and .h files, and then updating the following files based on searching for ShiftMap and shiftmap:
- Ast.c (the python interface)
- ast.h
- globals.c
- globals.h
- loader.c
- setup.py
- test.py
The changes are trivial in globals.c, globals.h, loader.c, and setup.py but the others require some care.
Additional changes are needed to support FORTRAN. The manual might also want an update, though it is possible that the reference section is automatically generated.
Furthermore, I modified a fork of PyAST, which contains a distribution of AST, but not its unit tests. PyAST has its own tests, but leaves most of the testing of mappings to AST. I added extensive testing for the new mapping in python, but did not attempt to add C tests.
The changes are here: https://github.com/r-owen/starlink-pyast.git on branch unitnormmap. The new map is being considered for inclusion in AST.
Regarding AST:
Simon Krughoff points out that the null map has 1400 lines of code (perhaps only 700 of which are actual code). This is intimidating. However, AST does provide a mechanism whereby a function written in C can be wrapped as a mapping. The primary documented limitation is that the mapping does not become part of AST, so any transform based on it is not portable. This seems tolerable to me, since we can provide our extensions as part of the LSST software stack.
I propose to implement a radial polynomial (with the center as a parameter) as an AST extension, to get an idea of what is involved.