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

bugfixes from run #213

Merged
merged 3 commits into from
Nov 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lcls_tools/common/devices/screen.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def image(self) -> np.ndarray:
the camera associated with this screen
"""
return self.controls_information.PVs.image.get(as_numpy=True).reshape(
self.n_rows, self.n_columns
self.n_columns, self.n_rows
Copy link
Member

Choose a reason for hiding this comment

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

How did this mistake get caught? I think I'm remembering this might not be the case for all cameras. Will approve for now and check with Courtney.

)

@property
Expand Down
11 changes: 5 additions & 6 deletions lcls_tools/common/measurements/emittance_measurement.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ class QuadScanEmittance(Measurement):
@field_validator("rmat")
def validate_rmat(cls, v, info):
assert v.shape == (4, 4)
return v

def measure(self):
"""Returns the emittance, BMAG, x_rms and y_rms
Expand All @@ -58,7 +59,7 @@ def measure(self):

# get transport matrix and design twiss values from meme
# TODO: get settings from arbitrary methods (ie. not meme)
if self.rmat is None and self.twiss is None:
if self.rmat is None and self.design_twiss is None:
optics = get_optics(
self.magnet_name,
self.device_measurement.device.name,
Expand All @@ -85,20 +86,18 @@ def measure(self):
kmod = bdes_to_kmod(self.energy, magnet_length, np.array(self.scan_values))

# compute emittance and bmag
emittance, bmag, _, _ = compute_emit_bmag(
results = compute_emit_bmag(
k=kmod,
beamsize_squared=beamsize_squared,
q_len=magnet_length,
rmat=rmat,
twiss_design=twiss_betas_alphas,
)

results = {
"emittance": emittance,
"BMAG": bmag,
results.update({
"x_rms": self.beam_sizes["x_rms"],
"y_rms": self.beam_sizes["y_rms"]
}
})

return results

Expand Down