Skip to content

modularize emittance measurement #263

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Conversation

roussel-ryan
Copy link
Collaborator

  • modify emittance optimization problem to use mean abs error in beamsize space to not prioritize fitting measurements where the beam size is large
  • introduce wrapper and preprocessing functions for calculating emittance from machine units

- introduce wrapper and preprocessing functions for calculating emittance from machine units
@roussel-ryan roussel-ryan requested review from Copilot and nneveu April 25, 2025 21:18
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR modularizes the emittance measurement by updating the optimization metric to use the mean absolute error in beamsize space and introducing wrapper and preprocessing functions to better handle inputs in machine units.

  • Adjusts the optimization error metric in the loss functions for both torch and numpy implementations.
  • Introduces a new compute_emit_bmag_machine_units wrapper and preprocessing function in the data module.
  • Updates the QuadScanEmittance measurement by reducing the wait_time and adding a type validator for beamsize measurements.

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
lcls_tools/common/measurements/emittance_measurement.py Updated imports, wait_time modification, added field validator, and integrated compute_emit_bmag_machine_units in the measurement workflow.
lcls_tools/common/data/emittance.py Revised error metric in the loss functions, added preprocess_inputs, and introduced compute_emit_bmag_machine_units wrapper.
Comments suppressed due to low confidence (2)

lcls_tools/common/data/emittance.py:116

  • The loss function now computes the absolute error between the square roots of the calculated and measured values, effectively working in beamsize space instead of mean square beamsize space. Please update the associated docstring and any related documentation to reflect this change in the error metric.
total_squared_error = (torch.sqrt(amat @ sig) - torch.sqrt(beamsize_squared)).abs().sum()

lcls_tools/common/data/emittance.py:136

  • The numpy loss function now computes the absolute error between the square roots of the computed and measured beam sizes. Consider updating the function documentation to ensure that the new metric is clearly described and matches the intended optimization behavior.
total_squared_error = np.sum(np.abs(np.sqrt(amat @ sig) - np.sqrt(beamsize_squared)))

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.

1 participant