An undulator includes a periodic arrangement of magnets to produce a
periodic spatial magnetic field distribution in a magnetic gap defined by
the magnets. The undulator further includes a temperature-compensating
material selectively arranged to compensate for a temperature-dependent
change in the magnetic field of the undulator. The change may be in the
strength of the magnetic field, or in the position of the magnetic field
centerline. According to one aspect of the invention, the
temperature-compensating material is movably arranged, so as to fine tune
its compensation effect after it is initially arranged. Alternatively or
additionally, the amount of temperature-compensating material may be
adjusted to fine tune its compensation effect after it is initially
arranged.