This function is quite specific since many PSFs might not be circularly symmetric. I'll review the rest of the code first, but then we can always see if there is a more general way to deal with this.