Defining a beam using a pupil function