-
Notifications
You must be signed in to change notification settings - Fork 12
Removes/reduces referenece use on i10 IDs #1032
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
base: main
Are you sure you want to change the base?
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #1032 +/- ##
==========================================
- Coverage 97.89% 97.88% -0.02%
==========================================
Files 182 182
Lines 7187 7182 -5
==========================================
- Hits 7036 7030 -6
- Misses 151 152 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
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.
Thanks, I think it's cleaner but have some more comments to make it even more so.
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.
Thanks, couple of comments in code. Additionally, I think polarisation is basically a derived signal. I will do #1077 so that we can use it here as I think it will clean things up a lot.
I think you should be able to use #1078 for the polarisation signal now. Happy to help if it's not obvious how. |
…9-removesreduces-refenece-use-on-i10-ids
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.
Thanks! I think there are still quite a few places where you could be making use of the enum but this is a start. I think using the setter from the other PR will tidy things up a bit though
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.
I haven't reviewed the entire thing yet, but a few comments for now.
""" | ||
note: | ||
I10 has two insertion devices one up(idu) and one down stream(idd). | ||
It is worth noting that the down stream device is slightly longer, |
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.
It is worth noting that the down stream device is slightly longer, | |
It is worth noting that the downstream device is slightly longer, |
self.jaw_phase.user_setpoint_readback, | ||
self.jaw_phase.user_readback, | ||
self.jaw_phase.velocity, | ||
) | ||
|
||
|
||
class Apple2(StandardReadable, Movable): |
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.
Out of scope for this issue, but we should see if we can create a BaseUndulator
device with a minimum set of signals.
_set_pol(value: Pol) -> None | ||
Sets the polarisation and adjusts motor positions based on the current energy. | ||
_read_pol_setpoint(pol: Pol, ...) -> Pol | ||
Reads the polarisation from hardware and updates the setpoint. | ||
_set(value: Apple2Val, energy: float) -> None | ||
Moves the undulator to the specified motor positions and energy. | ||
_get_id_gap_phase(energy: float) -> tuple[float, float] | ||
Converts energy and polarisation to gap and phase motor positions. | ||
_get_poly(new_energy: float, lookup_table: dict) -> np.poly1d |
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.
Nit: Given that these are private methods, I probably wouldn't include them on the docstring here. If I were writing plans which need this device, I'd like to quickly see the public methods available to me
self.jaw_phase.user_setpoint_readback, | ||
self.jaw_phase.user_readback, | ||
self.jaw_phase.velocity, | ||
) | ||
|
||
|
||
class Apple2(StandardReadable, Movable): |
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.
Must: This uses the Movable
protocol so we need to have have a set
function defined. Maybe you can just rename _set
?
"""This change the position of all the motors for a given energy and | ||
polarisation_setpoint""" | ||
|
||
def _read_pol_setpoint( |
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.
nit: name is implying we are only doing a read. I'd prefer something like def _update_pol_setpoint_using_hardware_read
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.
The raw_to_derived
function is for converting raw values to derived values. It seems a bit unexpected for this function to also be changing a setpoint. I'm not too familiar with this device yet though, so I could just be misunderstanding
self, | ||
value: Pol, | ||
) -> None: | ||
# This change the pol setpoint and then change polariastion via set energy. |
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 change the pol setpoint and then change polariastion via set energy. | |
# This changes the pol setpoint and then changes polariastion via set energy. |
f"btm_inner={btm_inner}, btm_outer={btm_outer}, gap={gap}." | ||
) | ||
|
||
if pol != Pol.LH3: |
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.
Would be useful to have a comment here to explain why we handle the Pol.LH3
case differently. Also, would it be useful to error/warn if pol==None
?
from dodal.devices.apple2_undulator import ( | ||
from dodal.log import LOGGER | ||
|
||
# from dodal.beamlines.i10 import pgm |
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.
Should: Remove this line
phase = 0.0 | ||
return polarisation, phase | ||
LOGGER.info("Determined polarisation: LH (Linear Horizontal).") | ||
return Pol("lh"), 0.0 |
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.
Should: use Pol.LH3
instead here
async def test_linear_arbitrary_pol_fail( | ||
mock_linear_arbitrary_angle: LinearArbitraryAngle, | ||
): | ||
mock_linear_arbitrary_angle.id_ref().pol = "lh" | ||
# set_mock_value( |
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.
Should: remove this comment
Fixes #1029 and #1046.
Instructions to reviewer on how to test:
Checks for reviewer
dodal connect ${BEAMLINE}