Analysis of betatron motion with a variable polarised undulator magnet