GSGS does phase retrieval on images given an estimate of the pupil phase (from a non-redundant mask or other interferometric approach), the pupil geometry, and the in-focus image. The code uses a modified Gerchberg-Saxton algorithm that iterates between pupil plane and image plane to measure the pupil phase.