Skip to content

add function to compute emittance from beam#1065

Open
swhite2401 wants to merge 2 commits intomasterfrom
emittance_from_beam
Open

add function to compute emittance from beam#1065
swhite2401 wants to merge 2 commits intomasterfrom
emittance_from_beam

Conversation

@swhite2401
Copy link
Copy Markdown
Contributor

This PR adds a function to compute the emittance of a particule distribution based on the sigma_matrix analysis.

@swhite2401 swhite2401 requested a review from lfarv March 24, 2026 15:35
@swhite2401 swhite2401 added enhancement Python For python AT code labels Mar 24, 2026
@swhite2401 swhite2401 requested a review from kandre2 March 24, 2026 15:36
if sigma_mat is not None:
msg = "beam provided, sigma_matrix ignored in emittance calculation"
warn(AtWarning(msg))
sigma_mat = sigma_matrix(beam=beam.copy())
Copy link
Copy Markdown
Contributor

@lfarv lfarv Mar 29, 2026

Choose a reason for hiding this comment

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

The reveals an inconvenient feature of sigma_matrix. It would be better to replace at line 129:

beam -= orbit.reshape((6, 1))

with

beam = beam - orbit.reshape((6, 1))

Which would avoid that sigma_matrix modifies its input. And avoid the copy() here.

@lfarv
Copy link
Copy Markdown
Contributor

lfarv commented Mar 29, 2026

Apart from that, this looks nice!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement Python For python AT code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants