-
Notifications
You must be signed in to change notification settings - Fork 59
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
Lens4escan #1202
Draft
vespos
wants to merge
6
commits into
pcdshub:master
Choose a base branch
from
vespos:lens4escan
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Lens4escan #1202
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
a9b9275
working setup for Yano exp Feb 2024
vespos 13802a2
lens_for_escan not working
vespos de2990e
atol=5 is way too small for self-seeding
vespos b270fb4
Merge branch 'master' into lens4escan
vespos acb1268
Merge branch 'pcdshub:master' into lens4escan
vespos ee3c0b7
check in small changes
vespos File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
from ophyd.device import Component as Cpt | ||
from ophyd.pseudopos import PseudoSingle | ||
|
||
from pcdsdevices.device import ObjectComponent as OCpt | ||
from pcdsdevices.interface import FltMvInterface | ||
from pcdsdevices.pseudopos import (PseudoPositioner, PseudoSingleInterface, | ||
pseudo_position_argument, | ||
real_position_argument) | ||
|
||
|
||
class Lens4EScan(FltMvInterface, PseudoPositioner): | ||
_real = ("mono_energy", "beam_size") | ||
_pseudo = ("energy", ) | ||
|
||
mono_energy = OCpt('{mono_energy}') | ||
beam_size = OCpt('{lens_stack.beam_size}') | ||
|
||
energy = Cpt(PseudoSingleInterface) | ||
|
||
tab_whitelist = ['calc_lens_pos', 'mono_energy', 'stack'] | ||
tab_component_names = True | ||
|
||
def __init__(self, mono_energy, lens_stack, | ||
desired_beamsize=5e-6, | ||
*args, **kwargs): | ||
self.mono = mono_energy | ||
self.stack = lens_stack | ||
self.desired_beamsize = desired_beamsize | ||
super().__init__(*args, **kwargs) | ||
|
||
@pseudo_position_argument | ||
def forward(self, pseudo_pos): | ||
return self.RealPosition(mono_energy=pseudo_pos.energy, | ||
beam_size=self.desired_beamsize) | ||
|
||
@real_position_argument | ||
def inverse(self, real_pos): | ||
return self.PseudoPosition(energy=real_pos.mono_energy) | ||
|
||
@pseudo_position_argument | ||
def move(self, position, *args, **kwargs): | ||
self.stack.energy = position.energy | ||
st = super().move(position, *args, | ||
moved_cb=self.cb_open_beamstop, | ||
**kwargs) | ||
return st | ||
|
||
def calc_lens_pos(self, energy): | ||
""" | ||
Return the expected lens position (x,y,z) for a given energy. | ||
""" | ||
stack_current_energy = self.stack.energy | ||
if self.stack._which_E != 'User': | ||
stack_current_energy = None | ||
self.stack.energy = energy | ||
lens_pos = self.stack.forward(beam_size=self.desired_beamsize) | ||
self.stack.energy = stack_current_energy | ||
return lens_pos | ||
|
||
def cb_open_beamstop(self, obj): | ||
""" | ||
Callback function to open the attenuator or pulse picker at the end of a | ||
move. If the atttenuator is used, this function assumes that the blade #9 | ||
is used to block the beam. | ||
""" | ||
if 'Attenuator' in self.stack._att_obj.__class__.__name__: | ||
self.stack._att_obj.filters[9].remove() | ||
elif 'PulsePicker' in self.stack._att_obj.__class__.__name__: | ||
self.stack._att_obj.open() | ||
return | ||
|
||
def _concurrent_move(self, real_pos, **kwargs): | ||
""" | ||
Try done fix: override the waiting list with the pseudopos parents, | ||
not pseudosingle, since cb is called on the parent in this case. | ||
|
||
This is needed because PseudoSingle does not report the right status, | ||
as they defer the motion to to their parent class (PseudoPositioner). | ||
When building a pseudo-positioner made of PseudoSingles, one needs to | ||
point the _real_waiting to the PseudoSingles' parent class. | ||
""" | ||
for real_axis in self._real: | ||
if isinstance(real_axis, PseudoSingle): | ||
self._real_waiting.append(real_axis.parent) | ||
else: | ||
self._real_waiting_append(real_axis) | ||
|
||
for real, value in zip(self._real, real_pos): | ||
self.log.debug("[concurrent] Moving %s to %s", real.name, value) | ||
real.move(value, wait=False, moved_cb=self._real_finished, **kwargs) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
[2, 0.0002, 4, 0.0005] | ||
null |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Note to self: to check again