Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DM-12103: Investigate centering for vignetted pupils #289

Merged
merged 1 commit into from Nov 7, 2017

Conversation

jmeyers314
Copy link
Contributor

Adds _centerPupil function and **kwargs to getPupilFactory to
optionally recenter the illuminated portion of a pupil within
a pupil array, similar to what is done in Zemax.

Copy link
Contributor

@mfisherlevine mfisherlevine left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Personally I'd use slightly different indentation in that method for clarity, but I can see what you've done is flake8 compliant, so if you feel strongly that this way is clearer/better you can leave as is. My preference:

    def _centerPupil(self, pupil):
        """Center the illuminated portion of the pupil in array.

        @param[in,out] pupil  Pupil to modify in place
        """
        def center(arr, axis):
            smash = np.sum(arr, axis=axis)
            w = np.where(smash)[0]
            return int(0.5*(np.min(w)+np.max(w)))
        ycenter = center(pupil.illuminated, 0)
        xcenter = center(pupil.illuminated, 1)
        ytarget = pupil.illuminated.shape[0]//2
        xtarget = pupil.illuminated.shape[1]//2
        pupil.illuminated = np.roll(np.roll(pupil.illuminated,
                                            xtarget-xcenter,
                                            axis=0),
                                    ytarget-ycenter,
                                    axis=1)

@mfisherlevine
Copy link
Contributor

Looks good. Just change this commit message to have the same first line as the other one (first word in the imperative and all that), and move this one to be after a line break to make the bulk of the message.

Other than that, and my OOB comment on the indentation about the in the _centerPupil() method I think you're good to go.

Adds _centerPupil function and **kwargs to getPupilFactory to
optionally recenter the illuminated portion of a pupil within
a pupil array, similar to what is done in Zemax.
@jmeyers314 jmeyers314 merged commit a126a4b into master Nov 7, 2017
@ktlim ktlim deleted the tickets/DM-12103 branch August 25, 2018 06:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants