Beam attenuation#35
Conversation
…ng tests; ignored eiger_async tests for now so that running tests is somewhat useful
Jakub Wlodek (jwlodek)
left a comment
There was a problem hiding this comment.
Marked some suggestions. Mainly I'd recommend making both device classes Movables and re-work the current methods for changing states into a set method override.
…syncStatus, upgraded version of ophyd-async because of test methods used, and to match what is in cdi-profile-collection
…d-async is incompatible with it
…ot have to be zero-indexed
…ed xrayutilities to calculate the transmission
… bank is the transmission
| """ | ||
| status = {} | ||
| active_attens = [] | ||
| en = self.photon_energy |
There was a problem hiding this comment.
we are already in an async function here so
| en = self.photon_energy | |
| en = await self.energy.readback.value() |
I may be wrong about the exact name, ophyd-async has a verb for "get me the one true number for this or explode".
There was a problem hiding this comment.
energy is an ophyd object, so await does not work
…in material and thickness to constructor; added pixi format task; pass energy into utility methods; remove property reading energy
…st one in linear time; also it is easier to read
| if egu == "KeV": | ||
| photon_energy = photon_energy * 1e3 | ||
| elif egu != "eV": | ||
| msg = "Photon energy units must be eV or KeV" |
There was a problem hiding this comment.
| msg = "Photon energy units must be eV or KeV" | |
| msg = f"Photon energy units must be eV or KeV (not {egu=})" |
| def get_egu(self): | ||
| return self.energy.egu | ||
|
|
||
| async def read(self): # type: ignore[reportUnknownParameterType] |
There was a problem hiding this comment.
This needs a matched describe (unless ophyd async is providing more magic than I think it is)
| """ | ||
| status = {} | ||
| active_attens = [] | ||
| energy = self.get_photon_energy() |
There was a problem hiding this comment.
use async flavor here for access to the hardware.
| active_attens.append(atten) | ||
| transmission = atten.transmission(energy, egu) if is_active else 0 | ||
| status[atten.name] = {"active": is_active, "transmission": transmission} | ||
| status["active_attenuators"] = [a.num for a in active_attens] |
There was a problem hiding this comment.
This is going to be variable length which will give tiled fits (for now). Better to provide either fixed length list of bools or strings "in" and "out".
| coros.append(atten.open()) | ||
| await asyncio.gather(*coros) | ||
|
|
||
| def find_closest_transmission( |
There was a problem hiding this comment.
Check with Garth if we want "closest" or "closest with at least" or "closest with at most" semantics on this. My knee-jerk guess would be "closest with at least" on the logic of if you are cutting the flux down it is because you want to protect something (sample or detector) so it is better to over attenuate than under attenuate.
Mainly, this PR creates the ability to attenuate a beam by giving control over a set of attenuators:
Also fixed various other issues: