Compensation for the setup instability in ptychographic imaging