twod_mapping assumes panels are flat
This means that prediction refinement doesn't work correctly when panels are tilted very much from being flat (thankfully rare).
Migrated issue from Jira, with the following comment:
Assigning to Wolfgang because he's currently working on gradients for his new prediction model ready for adding it to CrystFEL.
We thought about it, and worked out that the problem isn't twod_mapping, but rather the gradients for detector x and y (GPARAM_DETX/GPARAM_DETY) in the functions x_gradient() and y_gradient(). If the x offset of a spot is 10 pixels, we assume that the panel should be moved by 10 pixels. However, that's only true for a perpendicular panel. For a tilted one, there's some trigonometric factor related to 2theta and the panel tilt angle. Wolfgang kindly "volunteered" to work out what it is.