Skip to content

Beam attenuation#35

Open
Dan Henriksen (dihenriksen) wants to merge 33 commits into
mainfrom
beam-attenuation
Open

Beam attenuation#35
Dan Henriksen (dihenriksen) wants to merge 33 commits into
mainfrom
beam-attenuation

Conversation

@dihenriksen

@dihenriksen Dan Henriksen (dihenriksen) commented May 8, 2026

Copy link
Copy Markdown
Contributor

Mainly, this PR creates the ability to attenuate a beam by giving control over a set of attenuators:

  • Made AttenuatorBank, Attenuator, and other helper classes
  • Implemented movable protocol for those classes to control individual attenuators, and to set total attenuation
  • Tests for attenuation functionality

Also fixed various other issues:

  • Ignore test_eiger_async tests for now since they are very broken
  • Update ophyd-async version to match what is in cdi-profile-collection
  • Fix style problems
  • Remove python 3.10 from supported python versions due to compatibility issues with the latest version of ophyd-async

@dihenriksen Dan Henriksen (dihenriksen) marked this pull request as ready for review May 12, 2026 02:55

@jwlodek Jakub Wlodek (jwlodek) left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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.

Comment thread src/cditools/attenuator.py Outdated
Comment thread src/cditools/attenuator.py Outdated
Comment thread src/cditools/attenuator.py Outdated
Comment thread src/cditools/attenuator.py Outdated
Comment thread src/cditools/attenuator.py Outdated
Comment thread .github/workflows/cd.yml Outdated
Comment thread src/cditools/attenuator.py Outdated
Comment thread src/cditools/attenuator.py Outdated
Comment thread src/cditools/attenuator.py Outdated
Comment thread src/cditools/attenuator.py Outdated
Comment thread src/cditools/attenuator.py
Comment thread src/cditools/attenuator.py Outdated
Comment thread src/cditools/attenuator.py Outdated
"""
status = {}
active_attens = []
en = self.photon_energy

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

we are already in an async function here so

Suggested change
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".

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

energy is an ophyd object, so await does not work

Comment thread src/cditools/attenuator.py Outdated
Comment thread src/cditools/attenuator.py Outdated
Comment thread src/cditools/attenuator.py Outdated
def get_egu(self):
return self.energy.egu

async def read(self): # type: ignore[reportUnknownParameterType]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

use async flavor here for access to the hardware.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

energy is a regular ophyd object, not an ophyd-async object.

Comment thread src/cditools/attenuator.py Outdated
Comment thread src/cditools/attenuator.py
…ed xrayutilities to calculate the transmission
added sha back to github action;
properly formatted docstrings; pass in material and thickness to constructor;
added pixi format task;
pass energy into utility methods;
remove property reading energy
removed sorting of available transmissions because we can find the best one in linear time;
also it is easier to read
Co-authored-by: Thomas A Caswell <tcaswell@bnl.gov>
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.

3 participants