-
Notifications
You must be signed in to change notification settings - Fork 9
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
Add simulated hardware #69
Conversation
Check out this pull request on See visual diffs & provide feedback on Jupyter Notebooks. Powered by ReviewNB |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good overall, but needs some cleanup (details below).
src/blop/agent.py
Outdated
dets: Sequence[Signal] = [], | ||
detectors: Sequence[Signal] = [], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's use immutable defaults, e.g., None
and assign a list later in the __init__
method.
src/blop/agent.py
Outdated
x = self.dofs(active=True).transform(x) | ||
# x = self.dofs(active=True).transform(x) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's remove it and have a docsting explaining x
does not need to be normalized.
src/blop/sim/beamline.py
Outdated
for item in items: | ||
yield item |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Based on linter recommendation for https://github.com/NSLS-II-HEX/hextools/blob/870b1c928746501ca2f8f4404c49d895986c4e2f/src/hextools/germ/ophyd.py#L124:
for item in items: | |
yield item | |
yield from items |
class HDF5Handler(HandlerBase): | ||
specs = {"HDF5"} | ||
|
||
def __init__(self, filename): | ||
self._name = filename | ||
|
||
def __call__(self, frame): | ||
with h5py.File(self._name, "r") as f: | ||
entry = f["/entry/image"] | ||
return entry[frame] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's create an issue to make it compatible with databroker v2.
from . import functions # noqa | ||
|
||
|
||
def get_beam_stats(image, threshold=0.5): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function has a duplicate in src/blop/digestion/__init__.py
. Let's leave just one of them.
Inspired by conversations with some beamline scientists, it would help to have more concrete optimization problems. This adds a lightweight simulation of a beamline mimicking a KB mirror endstation. We may add more examples in the future.