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

Aithre lasershaping #910

Draft
wants to merge 12 commits into
base: main
Choose a base branch
from
Draft

Aithre lasershaping #910

wants to merge 12 commits into from

Conversation

DominicOram
Copy link
Contributor

PR for laser shaping work, makes it easier for people to comment on the code

Checks for reviewer

  • Would the PR title make sense to a scientist on a set of release notes
  • If a new device has been added does it follow the standards
  • If changing the API for a pre-existing device, ensure that any beamlines using this device have updated their Bluesky plans accordingly
  • Have the connection tests for the relevant beamline(s) been run via dodal connect ${BEAMLINE}

Copy link
Contributor Author

@DominicOram DominicOram left a comment

Choose a reason for hiding this comment

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

So the different files used in configuring the OAV are confusing and horrible and a bit of a hold over from GDA, I have written #911 to document them.

I think the long and short of it though is that you only need them if your beam centre/microns per pixel changes with zoom so in your case (I assume) you don't. With the changes I have suggested in the code I can do:

from bluesky import plan_stubs as bps
from bluesky.run_engine import RunEngine
from ophyd_async.core import DeviceCollector

RE = RunEngine()

with DeviceCollector():
    my_oav = OAV("BL03I-DI-OAV-01:", "my_oav")


def take_an_image():
    yield from bps.mv(my_oav.snapshot.directory, "/scratch/")
    yield from bps.mv(my_oav.snapshot.filename, "test_image")
    yield from bps.trigger(my_oav.snapshot, wait=True)


RE(take_an_image())

and I get the snapshot I expect (from i03's OAV).

"beam_centre_y": 1028,
}

class OAV(StandardReadable)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

There's a missing colon here, you can tell at first glance in github because the __init__ below it has no highlighting unlike other functions

Suggested change
class OAV(StandardReadable)
class OAV(StandardReadable):

Comment on lines 21 to 22
def __init__(self, prefix: str, config: OAVConfig, name: str = ""):
self.oav_config = config
Copy link
Contributor Author

Choose a reason for hiding this comment

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

OAVConfig is mainly there to handle how beam centre/microns per pixel changes with zoom. If we don't have a zoom controller here then I'm guessing these are fixed, in which case we can just remove it.

Suggested change
def __init__(self, prefix: str, config: OAVConfig, name: str = ""):
self.oav_config = config
def __init__(self, prefix: str, name: str = ""):

Comment on lines 32 to 35
self.microns_per_pixel_x = laserOAVconfig["microns_per_pixel_x"]
self.microns_per_pixel_y = laserOAVconfig["microns_per_pixel_y"]
self.beam_centre_x = create_hardware_backed_soft_signal(int, lambda: self._get_beam_position("X"))
self.beam_centre_y = create_hardware_backed_soft_signal(int, lambda: self._get_beam_position("Y"))
Copy link
Contributor Author

Choose a reason for hiding this comment

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

In the other OAV we have these as signals as they may change. Signals let you easily monitor things. In the case of a fixed microns/pixel and beam centre they don't have to be signals but I think it's nicer for consistency. Making fixed signals is simpler, you don't need the create_hardware_backed_soft_signal stuff and so can remove _get_beam_position below too:

from ophyd_async.core import soft_signal_r_and_setter

self.microns_per_pixel_x, _ = soft_signal_r_and_setter(float, laserOAVconfig["microns_per_pixel_x"])
self.microns_per_pixel_y, _ = soft_signal_r_and_setter(float, laserOAVconfig["microns_per_pixel_x"])
self.beam_centre_x, _ = soft_signal_r_and_setter(float, laserOAVconfig["beam_centre_x"])
self.beam_centre_y, _ = soft_signal_r_and_setter(float, laserOAVconfig["beam_centre_y"])



# LA18L-DI-OAV-01: is prefix for lab 18 OAV laser shaping
# not sure if I need to use this or just create a new json and use the standard
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think removing the zoom reduces the complexity so much that it makes sense to rewrite it like this. We could probably do some more code re-use where this and the other OAV have a shared parent class or something but we can leave that to another day once it's working.

DominicOram and others added 2 commits November 20, 2024 18:58
- rename oav parameters to include file extension
- typos etc.
Copy link

codecov bot commented Nov 22, 2024

Codecov Report

Attention: Patch coverage is 30.93220% with 163 lines in your changes missing coverage. Please review.

Project coverage is 93.21%. Comparing base (ad6cc0d) to head (de41b06).
Report is 6 commits behind head on main.

Files with missing lines Patch % Lines
...odal/devices/aithre_lasershaping/oav_parameters.py 0.00% 94 Missing ⚠️
src/dodal/devices/aithre_lasershaping/robot.py 61.29% 36 Missing ⚠️
src/dodal/devices/aithre_lasershaping/cameras.py 0.00% 29 Missing ⚠️
...rc/dodal/devices/aithre_lasershaping/goniometer.py 75.00% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #910      +/-   ##
==========================================
- Coverage   95.70%   93.21%   -2.49%     
==========================================
  Files         132      140       +8     
  Lines        5334     5810     +476     
==========================================
+ Hits         5105     5416     +311     
- Misses        229      394     +165     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.


🚨 Try these New Features:

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