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
| 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.
There was a problem hiding this comment.
energy is a regular ophyd object, not an ophyd-async object.
| 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".
There was a problem hiding this comment.
I just deleted this line. Each attenuator is listed individually in the status with the active boolean flag.
| 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.
There was a problem hiding this comment.
Garth said this is not necessary. That you can't be too picky with the attenuators, and always just pick the closest one. It would be easy to add though if we do ever need it.
Co-authored-by: Thomas A Caswell <tcaswell@bnl.gov>
Mainly, this PR creates the ability to attenuate a beam by giving control over a set of attenuators:
Also fixed various other issues: