Tailored thermal stabilisation of type I gratings