From efd16e88e0f5fe7c7b79494248d35f06963d1381 Mon Sep 17 00:00:00 2001 From: Vincent Esposito Date: Sun, 21 Jan 2024 16:28:03 -0800 Subject: [PATCH 01/11] add ACR status option for CCM energy moves --- pcdsdevices/ccm.py | 46 +++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 45 insertions(+), 1 deletion(-) diff --git a/pcdsdevices/ccm.py b/pcdsdevices/ccm.py index b28bcd473c2..623180adfbc 100644 --- a/pcdsdevices/ccm.py +++ b/pcdsdevices/ccm.py @@ -773,6 +773,41 @@ def inverse(self, real_pos: namedtuple) -> namedtuple: return self.PseudoPosition(energy=energy) +class CCMEnergyWithACRStatus(CCMEnergyWithVernier): + """ + CCM energy motor and ACR beam energy request with status. + Note that in this cae vernier indicates any ways that ACR will act on the + photon energy request. This includes the Vernier, but can also lead to + motion of the undulators or the K. + + Parameters + ---------- + prefix : str + The PV prefix of the Alio motor, e.g. XPP:MON:MPZ:07A + hutch : str, optional + The hutch we're in. This informs us as to which vernier + PVs to write to. If omitted, we can guess this from the + prefix. + acr_status_sufix : str + Prefix to the SIOC PV that ACR uses to report the move status. + For HXR this usually is 'AO805'. + """ + vernier = FCpt(BeamEnergyRequest, '{hutch}', + acr_status_suffix='AO805', + kind='normal', + doc='Requests ACR to move the energy.') + + def __init__( + self, + prefix: str, + hutch: typing.Optional[str] = None, + acr_status_suffix='AO805', + **kwargs + ): + self.acr_status_suffix = acr_status_suffix + super().__init__(prefix, **kwargs) + + class CCMX(SyncAxis): """ Combined motion of the CCM X motors. @@ -903,11 +938,20 @@ class CCM(BaseInterface, GroupDevice, LightpathMixin, CCMConstantsMixin): energy_with_vernier = Cpt( CCMEnergyWithVernier, '', kind='normal', doc=( - 'PsuedoPositioner that moves the alio in ' + 'PseudoPositioner that moves the alio in ' 'terms of the calculated CCM energy while ' 'also requesting a vernier move.' ), ) + energy_with_acr_status = Cpt( + CCMEnergyWithACRStatus, '', kind='normal', + doc=( + 'PseudoPositioner that moves the alio in ' + 'terms of the calculated CCM energy while ' + 'also requesting an energy change to ACR. ' + 'This will wait on ACR to complete the move.' + ), + ) alio = UCpt(CCMAlio, kind='normal', doc='The motor that rotates the CCM crystal.') From 2e2b3440519b464e026b1fb69509b13033e5cf97 Mon Sep 17 00:00:00 2001 From: vespos <42768134+vespos@users.noreply.github.com> Date: Tue, 30 Jan 2024 11:13:48 -0800 Subject: [PATCH 02/11] Update pcdsdevices/ccm.py Co-authored-by: Robert Tang-Kong <35379409+tangkong@users.noreply.github.com> --- pcdsdevices/ccm.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pcdsdevices/ccm.py b/pcdsdevices/ccm.py index 623180adfbc..29745b6d55d 100644 --- a/pcdsdevices/ccm.py +++ b/pcdsdevices/ccm.py @@ -776,7 +776,7 @@ def inverse(self, real_pos: namedtuple) -> namedtuple: class CCMEnergyWithACRStatus(CCMEnergyWithVernier): """ CCM energy motor and ACR beam energy request with status. - Note that in this cae vernier indicates any ways that ACR will act on the + Note that in this case vernier indicates any ways that ACR will act on the photon energy request. This includes the Vernier, but can also lead to motion of the undulators or the K. From 6047e1c7695f08d51eeec7de1feebd5e7feed5ed Mon Sep 17 00:00:00 2001 From: Vincent Esposito Date: Tue, 27 Feb 2024 11:50:26 -0800 Subject: [PATCH 03/11] default to bunch=2 for acr wait status: default use case for requesting vernier (not wait) and K (wait) changes --- pcdsdevices/beam_stats.py | 3 +++ pcdsdevices/ccm.py | 19 ++++++++++++++++--- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/pcdsdevices/beam_stats.py b/pcdsdevices/beam_stats.py index 8966b393424..4f963e7bf5d 100644 --- a/pcdsdevices/beam_stats.py +++ b/pcdsdevices/beam_stats.py @@ -102,6 +102,7 @@ class BeamEnergyRequest(FltMvInterface, Device, PositionerBase): EpicsSignal, '{prefix}:USER:MCC:EPHOT{line_text}:SET{bunch}', kind='hinted', + add_prefix=('suffix', 'write_pv', 'line_text', 'bunch'), doc=( 'The setpoint PV that acr listens on to update the ' 'vernier or undulator PVs as appropriate.' @@ -111,6 +112,7 @@ class BeamEnergyRequest(FltMvInterface, Device, PositionerBase): EpicsSignal, '{prefix}:USER:MCC:EPHOT{line_text}:REF{bunch}', kind='normal', + add_prefix=('suffix', 'write_pv', 'line_text', 'bunch'), doc=( 'A reference PV for the photon energy at the nominal ' 'position of the vernier or undulator.' @@ -181,6 +183,7 @@ class BeamEnergyRequestACRWait(BeamEnergyRequest, PVPositioner): EpicsSignal, 'SIOC:SYS0:ML07:{acr_status_suffix}', kind='normal', + add_prefix=('suffix', 'write_pv', 'acr_status_suffix'), doc=( 'PV that is 0 while the motors are moving and 1 when ACR is ' 'ready for a new request. ACR can pick which of these PVs ' diff --git a/pcdsdevices/ccm.py b/pcdsdevices/ccm.py index 623180adfbc..f5bddd61a64 100644 --- a/pcdsdevices/ccm.py +++ b/pcdsdevices/ccm.py @@ -793,7 +793,9 @@ class CCMEnergyWithACRStatus(CCMEnergyWithVernier): For HXR this usually is 'AO805'. """ vernier = FCpt(BeamEnergyRequest, '{hutch}', - acr_status_suffix='AO805', + bunch='{bunch}', + acr_status_suffix='{acr_status_suffix}', + add_prefix=('suffix', 'write_pv', 'bunch', 'acr_status_suffix'), kind='normal', doc='Requests ACR to move the energy.') @@ -802,9 +804,11 @@ def __init__( prefix: str, hutch: typing.Optional[str] = None, acr_status_suffix='AO805', + bunch=2, **kwargs ): self.acr_status_suffix = acr_status_suffix + self.bunch = bunch super().__init__(prefix, **kwargs) @@ -927,6 +931,11 @@ class CCM(BaseInterface, GroupDevice, LightpathMixin, CCMConstantsMixin): The prefix for the north upstream ccm y translation motor (y2). y_up_south_prefix : str, required keyword The prefix for the south upstream ccm y translation motor (y3). + acr_status_bunch : int + The bunch index for the energy request PV in the case of the acr status + wait. Default: 2. + acr_status_suffix : str + The suffix for the ACR status energy change move. Default to 'AO805' """ energy = Cpt( CCMEnergy, '', kind='hinted', @@ -943,8 +952,10 @@ class CCM(BaseInterface, GroupDevice, LightpathMixin, CCMConstantsMixin): 'also requesting a vernier move.' ), ) - energy_with_acr_status = Cpt( - CCMEnergyWithACRStatus, '', kind='normal', + energy_with_acr_status = FCpt( + CCMEnergyWithACRStatus, '{prefix}', kind='normal', + acr_status_suffix='{acr_status_suffix}', + add_prefix=('suffix', 'write_pv', 'acr_status_suffix'), doc=( 'PseudoPositioner that moves the alio in ' 'terms of the calculated CCM energy while ' @@ -1001,6 +1012,8 @@ def __init__( self._in_pos = in_pos self._out_pos = out_pos prefix = prefix or self.unrelated_prefixes['alio_prefix'] + self.acr_status_suffix = kwargs.get('acr_status_suffix', 'AO805') + self.acr_status_bunch = kwargs.get('acr_status_suffix', 2) super().__init__(prefix, **kwargs) # Aliases: defined by the scientists From defdc272fbdaf1ea526f309a7551fdac34c75f09 Mon Sep 17 00:00:00 2001 From: Vincent Esposito Date: Tue, 27 Feb 2024 12:22:20 -0800 Subject: [PATCH 04/11] rename things to be more in line with use cases --- pcdsdevices/beam_stats.py | 24 +++++++++++++++--------- pcdsdevices/ccm.py | 29 +++++++++++++++-------------- 2 files changed, 30 insertions(+), 23 deletions(-) diff --git a/pcdsdevices/beam_stats.py b/pcdsdevices/beam_stats.py index 4f963e7bf5d..e476e889f84 100644 --- a/pcdsdevices/beam_stats.py +++ b/pcdsdevices/beam_stats.py @@ -89,9 +89,9 @@ class BeamEnergyRequest(FltMvInterface, Device, PositionerBase): in them, the L line PVs just have "EPHOT". This will default to the line associated with the prefix hutch name, or to L line failing that. - bunch : int, optional - Whether to move the first bunch (1) or the second bunch (2). This is - only relevant for 2-color mode. Defaults to bunch 1. + pv_index : int, optional + Whether to move the first PV (1) or the second PV (2). This is relevant + 2-color mode or when scanning combined K and Vernier. Defaults to 1. acr_status_suffix : str, optional If provided, we'll wait on the ACR PV specified by @@ -100,9 +100,11 @@ class BeamEnergyRequest(FltMvInterface, Device, PositionerBase): """ setpoint = FCpt( EpicsSignal, - '{prefix}:USER:MCC:EPHOT{line_text}:SET{bunch}', + # '{prefix}:USER:MCC:EPHOT{line_text}:SET{bunch}', + '{prefix}:USER:MCC:EPHOT{line_text}:SET{pv_index}', kind='hinted', - add_prefix=('suffix', 'write_pv', 'line_text', 'bunch'), + # add_prefix=('suffix', 'write_pv', 'line_text', 'bunch'), + add_prefix=('suffix', 'write_pv', 'line_text', 'pv_index'), doc=( 'The setpoint PV that acr listens on to update the ' 'vernier or undulator PVs as appropriate.' @@ -110,9 +112,11 @@ class BeamEnergyRequest(FltMvInterface, Device, PositionerBase): ) ref = FCpt( EpicsSignal, - '{prefix}:USER:MCC:EPHOT{line_text}:REF{bunch}', + # '{prefix}:USER:MCC:EPHOT{line_text}:REF{bunch}', + '{prefix}:USER:MCC:EPHOT{line_text}:REF{pv_index}', kind='normal', - add_prefix=('suffix', 'write_pv', 'line_text', 'bunch'), + # add_prefix=('suffix', 'write_pv', 'line_text', 'bunch'), + add_prefix=('suffix', 'write_pv', 'line_text', 'pv_index'), doc=( 'A reference PV for the photon energy at the nominal ' 'position of the vernier or undulator.' @@ -146,12 +150,14 @@ def __init__( *, name: str, line: Optional[str] = None, - bunch: int = 1, + # bunch: int = 1, + pv_index: int = 1, acr_status_suffix: Optional[str] = None, **kwargs ): self.line_text = self.line_text_dict.get(line or prefix, '') - self.bunch = bunch + # self.bunch = bunch + self.pv_index = pv_index self.acr_status_suffix = acr_status_suffix super().__init__(prefix, name=name, **kwargs) diff --git a/pcdsdevices/ccm.py b/pcdsdevices/ccm.py index 09d91833705..ab6136c55f4 100644 --- a/pcdsdevices/ccm.py +++ b/pcdsdevices/ccm.py @@ -722,8 +722,8 @@ class CCMEnergyWithVernier(CCMEnergy): PVs to write to. If omitted, we can guess this from the prefix. """ - vernier = FCpt(BeamEnergyRequest, '{hutch}', kind='normal', - doc='Requests ACR to move the Vernier.') + acr_energy = FCpt(BeamEnergyRequest, '{hutch}', kind='normal', + doc='Requests ACR to move the Vernier.') # These are duplicate warnings with main energy motor _enable_warn_constants: bool = False @@ -759,7 +759,7 @@ def forward(self, pseudo_pos: namedtuple) -> namedtuple: energy = pseudo_pos.energy alio = self.energy_to_alio(energy) vernier = energy * 1000 - return self.RealPosition(alio=alio, vernier=vernier) + return self.RealPosition(alio=alio, acr_energy=vernier) def inverse(self, real_pos: namedtuple) -> namedtuple: """ @@ -792,23 +792,24 @@ class CCMEnergyWithACRStatus(CCMEnergyWithVernier): Prefix to the SIOC PV that ACR uses to report the move status. For HXR this usually is 'AO805'. """ - vernier = FCpt(BeamEnergyRequest, '{hutch}', - bunch='{bunch}', - acr_status_suffix='{acr_status_suffix}', - add_prefix=('suffix', 'write_pv', 'bunch', 'acr_status_suffix'), - kind='normal', - doc='Requests ACR to move the energy.') + acr_energy = FCpt(BeamEnergyRequest, '{hutch}', + pv_index='{pv_index}', + acr_status_suffix='{acr_status_suffix}', + add_prefix=('suffix', 'write_pv', 'pv_index', + 'acr_status_suffix'), + kind='normal', + doc='Requests ACR to move the energy.') def __init__( self, prefix: str, hutch: typing.Optional[str] = None, acr_status_suffix='AO805', - bunch=2, + pv_index=2, **kwargs ): self.acr_status_suffix = acr_status_suffix - self.bunch = bunch + self.pv_index = pv_index super().__init__(prefix, **kwargs) @@ -931,8 +932,8 @@ class CCM(BaseInterface, GroupDevice, LightpathMixin, CCMConstantsMixin): The prefix for the north upstream ccm y translation motor (y2). y_up_south_prefix : str, required keyword The prefix for the south upstream ccm y translation motor (y3). - acr_status_bunch : int - The bunch index for the energy request PV in the case of the acr status + acr_status_pv_index : int + The index for the energy request PV in the case of the acr status wait. Default: 2. acr_status_suffix : str The suffix for the ACR status energy change move. Default to 'AO805' @@ -1013,7 +1014,7 @@ def __init__( self._out_pos = out_pos prefix = prefix or self.unrelated_prefixes['alio_prefix'] self.acr_status_suffix = kwargs.get('acr_status_suffix', 'AO805') - self.acr_status_bunch = kwargs.get('acr_status_suffix', 2) + self.acr_status_pv_index = kwargs.get('acr_status_suffix', 2) super().__init__(prefix, **kwargs) # Aliases: defined by the scientists From dc380fc5b36731e80716316cf9e7022bbc19870c Mon Sep 17 00:00:00 2001 From: Vincent Esposito Date: Tue, 27 Feb 2024 12:40:21 -0800 Subject: [PATCH 05/11] fix ccm test --- pcdsdevices/tests/test_ccm.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/pcdsdevices/tests/test_ccm.py b/pcdsdevices/tests/test_ccm.py index a4f590764c6..a8ac0dd9524 100644 --- a/pcdsdevices/tests/test_ccm.py +++ b/pcdsdevices/tests/test_ccm.py @@ -86,7 +86,7 @@ def init_pos(mot, pos=0): fake_ccm.alio.set(SAMPLE_ALIO) fake_ccm.energy.alio.set(SAMPLE_ALIO) fake_ccm.energy_with_vernier.alio.set(SAMPLE_ALIO) - fake_ccm.energy_with_vernier.vernier.setpoint.sim_put(0) + fake_ccm.energy_with_vernier.acr_energy.setpoint.sim_put(0) return fake_ccm @@ -165,26 +165,26 @@ def test_vernier(fake_ccm): # Moving with vernier should move the energy request motor too pseudopos.move(7, wait=False) assert np.isclose(pseudopos.energy.position, 7) - assert pseudopos.vernier.position == 7000 + assert pseudopos.acr_energy.position == 7000 pseudopos.move(8, wait=False) assert np.isclose(pseudopos.energy.position, 8) - assert pseudopos.vernier.position == 8000 + assert pseudopos.acr_energy.position == 8000 pseudopos.move(9, wait=False) assert np.isclose(pseudopos.energy.position, 9) - assert pseudopos.vernier.position == 9000 + assert pseudopos.acr_energy.position == 9000 # Small moves (less than 30eV) should be skipped on the energy request pseudopos.move(9.001, wait=False) assert np.isclose(pseudopos.energy.position, 9.001) - assert pseudopos.vernier.position == 9000 + assert pseudopos.acr_energy.position == 9000 # Unless we set the option for not skipping them - pseudopos.vernier.skip_small_moves = False + pseudopos.acr_energy.skip_small_moves = False pseudopos.move(9.002, wait=False) assert np.isclose(pseudopos.energy.position, 9.002) - assert pseudopos.vernier.position == 9002 + assert pseudopos.acr_energy.position == 9002 @pytest.mark.timeout(5) From 831a62f82c412e3249d7bf9996073180fabc4f81 Mon Sep 17 00:00:00 2001 From: Vincent Esposito Date: Tue, 27 Feb 2024 13:45:29 -0800 Subject: [PATCH 06/11] deprecate bunch kwarg and fix beam_stats tests. --- pcdsdevices/beam_stats.py | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/pcdsdevices/beam_stats.py b/pcdsdevices/beam_stats.py index e476e889f84..7bb48c2a561 100644 --- a/pcdsdevices/beam_stats.py +++ b/pcdsdevices/beam_stats.py @@ -35,6 +35,19 @@ def __init__(self, prefix='', name='beam_stats', **kwargs): super().__init__(prefix=prefix, name=name, **kwargs) +def re_arg(kwarg_map): + def decorator(func): + def wrapped(*args, **kwargs): + new_kwargs = {} + for k, v in kwargs.items(): + if k in kwarg_map: + print(f"DEPRECATION WARNING: keyword argument '{k}' is no longer valid. Use '{kwarg_map[k]}' instead.") + new_kwargs[kwarg_map.get(k, k)] = v + return func(*args, **new_kwargs) + return wrapped + return decorator + + class BeamEnergyRequest(FltMvInterface, Device, PositionerBase): """ Positioner to request beam color changes from ACR in eV. @@ -100,10 +113,8 @@ class BeamEnergyRequest(FltMvInterface, Device, PositionerBase): """ setpoint = FCpt( EpicsSignal, - # '{prefix}:USER:MCC:EPHOT{line_text}:SET{bunch}', '{prefix}:USER:MCC:EPHOT{line_text}:SET{pv_index}', kind='hinted', - # add_prefix=('suffix', 'write_pv', 'line_text', 'bunch'), add_prefix=('suffix', 'write_pv', 'line_text', 'pv_index'), doc=( 'The setpoint PV that acr listens on to update the ' @@ -112,10 +123,8 @@ class BeamEnergyRequest(FltMvInterface, Device, PositionerBase): ) ref = FCpt( EpicsSignal, - # '{prefix}:USER:MCC:EPHOT{line_text}:REF{bunch}', '{prefix}:USER:MCC:EPHOT{line_text}:REF{pv_index}', kind='normal', - # add_prefix=('suffix', 'write_pv', 'line_text', 'bunch'), add_prefix=('suffix', 'write_pv', 'line_text', 'pv_index'), doc=( 'A reference PV for the photon energy at the nominal ' @@ -144,19 +153,18 @@ def __new__( return super().__new__(BeamEnergyRequestNoWait) return super().__new__(BeamEnergyRequestACRWait) + @re_arg({"bunch": "pv_index"}) def __init__( self, prefix: str, *, name: str, line: Optional[str] = None, - # bunch: int = 1, pv_index: int = 1, acr_status_suffix: Optional[str] = None, **kwargs ): self.line_text = self.line_text_dict.get(line or prefix, '') - # self.bunch = bunch self.pv_index = pv_index self.acr_status_suffix = acr_status_suffix super().__init__(prefix, name=name, **kwargs) From fd06c9b30a0180a98074d99ed91074412e22e07d Mon Sep 17 00:00:00 2001 From: Vincent Esposito Date: Tue, 27 Feb 2024 13:57:28 -0800 Subject: [PATCH 07/11] acutally commit the test changes... --- pcdsdevices/tests/test_beam_stats.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pcdsdevices/tests/test_beam_stats.py b/pcdsdevices/tests/test_beam_stats.py index ccdce425b12..26c6e578b3c 100644 --- a/pcdsdevices/tests/test_beam_stats.py +++ b/pcdsdevices/tests/test_beam_stats.py @@ -107,14 +107,14 @@ def test_beam_energy_request_args(): 'TST', name='tst_k1_request', line='k', - bunch=1, + pv_index=1, ) assert tst_k1_request.setpoint.pvname == 'TST:USER:MCC:EPHOTK:SET1' tst_l2_request = BeamEnergyRequest( 'TST', name='tst_l2_request', line='L', - bunch=2, + pv_index=2, ) assert tst_l2_request.setpoint.pvname == 'TST:USER:MCC:EPHOT:SET2' # let's test the class splitting here too From 8bea9a299b3ad5b1ed570c3bfbe82496a3409c56 Mon Sep 17 00:00:00 2001 From: Vincent Esposito Date: Thu, 29 Feb 2024 23:36:05 -0800 Subject: [PATCH 08/11] atol=5 is way too big for self-seed --- pcdsdevices/beam_stats.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pcdsdevices/beam_stats.py b/pcdsdevices/beam_stats.py index 7bb48c2a561..52d7cf8917b 100644 --- a/pcdsdevices/beam_stats.py +++ b/pcdsdevices/beam_stats.py @@ -177,7 +177,7 @@ class BeamEnergyRequestNoWait(BeamEnergyRequest, PVPositionerDone): It will report done immediately and ignore moves that are smaller than atol. """ - atol = 5 + atol = 0.5 # All done-related functionality is inherited from PVPositionerDone # Just implement skip_small_moves's default From 8ac6f0ff12ee94c5e23959eff4e0b178ee787692 Mon Sep 17 00:00:00 2001 From: Vincent Esposito Date: Wed, 6 Mar 2024 16:10:06 -0800 Subject: [PATCH 09/11] move re_args to utils.py --- pcdsdevices/beam_stats.py | 14 +------------- pcdsdevices/ccm.py | 5 +++-- pcdsdevices/utils.py | 21 +++++++++++++++++++++ 3 files changed, 25 insertions(+), 15 deletions(-) diff --git a/pcdsdevices/beam_stats.py b/pcdsdevices/beam_stats.py index 52d7cf8917b..a3639b024ae 100644 --- a/pcdsdevices/beam_stats.py +++ b/pcdsdevices/beam_stats.py @@ -12,6 +12,7 @@ from .interface import BaseInterface, FltMvInterface from .pv_positioner import PVPositionerDone from .signal import AvgSignal +from .utils import re_arg logger = logging.getLogger(__name__) @@ -35,19 +36,6 @@ def __init__(self, prefix='', name='beam_stats', **kwargs): super().__init__(prefix=prefix, name=name, **kwargs) -def re_arg(kwarg_map): - def decorator(func): - def wrapped(*args, **kwargs): - new_kwargs = {} - for k, v in kwargs.items(): - if k in kwarg_map: - print(f"DEPRECATION WARNING: keyword argument '{k}' is no longer valid. Use '{kwarg_map[k]}' instead.") - new_kwargs[kwarg_map.get(k, k)] = v - return func(*args, **new_kwargs) - return wrapped - return decorator - - class BeamEnergyRequest(FltMvInterface, Device, PositionerBase): """ Positioner to request beam color changes from ACR in eV. diff --git a/pcdsdevices/ccm.py b/pcdsdevices/ccm.py index ab6136c55f4..3d843be422e 100644 --- a/pcdsdevices/ccm.py +++ b/pcdsdevices/ccm.py @@ -995,8 +995,9 @@ class CCM(BaseInterface, GroupDevice, LightpathMixin, CCMConstantsMixin): lightpath_cpts = ['x.up.user_readback'] tab_whitelist = ['x1', 'x2', 'y1', 'y2', 'y3', 'E', 'E_Vernier', - 'th2fine', 'alio2E', 'E2alio', 'alio', 'home', - 'kill', 'insert', 'remove', 'inserted', 'removed'] + 'energy_with_acr_status', 'th2fine', 'alio2E', 'E2alio', + 'alio', 'home', 'kill', 'insert', 'remove', 'inserted', + 'removed'] _in_pos: float _out_pos: float diff --git a/pcdsdevices/utils.py b/pcdsdevices/utils.py index adaf04b5566..15acee1efe6 100644 --- a/pcdsdevices/utils.py +++ b/pcdsdevices/utils.py @@ -53,6 +53,27 @@ minus = '-' +def re_arg(kwarg_map): + """ + Decorator to redefine a kwarg to a function, while still supporting the old kwarg, and warning the end user. + + Usage: + @re_arg({"new_kwarg": "old_kwarg"}) + def myfunc(*args, new_kwarg=, **kwargs): + ... + """ + def decorator(func): + def wrapped(*args, **kwargs): + new_kwargs = {} + for k, v in kwargs.items(): + if k in kwarg_map: + print(f"DEPRECATION WARNING: keyword argument '{k}' is no longer valid. Use '{kwarg_map[k]}' instead.") + new_kwargs[kwarg_map.get(k, k)] = v + return func(*args, **new_kwargs) + return wrapped + return decorator + + def is_input(): """ Utility to check if there is input available. From 0ceae5a46e52843c2a13c2c977bde0121010d819 Mon Sep 17 00:00:00 2001 From: Vincent Esposito Date: Wed, 6 Mar 2024 16:49:47 -0800 Subject: [PATCH 10/11] fix ccm test --- pcdsdevices/tests/test_ccm.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pcdsdevices/tests/test_ccm.py b/pcdsdevices/tests/test_ccm.py index a8ac0dd9524..254948525a0 100644 --- a/pcdsdevices/tests/test_ccm.py +++ b/pcdsdevices/tests/test_ccm.py @@ -176,8 +176,8 @@ def test_vernier(fake_ccm): assert pseudopos.acr_energy.position == 9000 # Small moves (less than 30eV) should be skipped on the energy request - pseudopos.move(9.001, wait=False) - assert np.isclose(pseudopos.energy.position, 9.001) + pseudopos.move(9.0001, wait=False) + assert np.isclose(pseudopos.energy.position, 9.0001) assert pseudopos.acr_energy.position == 9000 # Unless we set the option for not skipping them From ad0514b648eebdd42691d8e4befc1ab0ca4a117e Mon Sep 17 00:00:00 2001 From: Vincent Esposito Date: Wed, 6 Mar 2024 17:02:49 -0800 Subject: [PATCH 11/11] pre-release notes --- ...ACR_status_option_for_CCM_energy_moves.rst | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 docs/source/upcoming_release_notes/1194-Add_ACR_status_option_for_CCM_energy_moves.rst diff --git a/docs/source/upcoming_release_notes/1194-Add_ACR_status_option_for_CCM_energy_moves.rst b/docs/source/upcoming_release_notes/1194-Add_ACR_status_option_for_CCM_energy_moves.rst new file mode 100644 index 00000000000..c44dac6fbbd --- /dev/null +++ b/docs/source/upcoming_release_notes/1194-Add_ACR_status_option_for_CCM_energy_moves.rst @@ -0,0 +1,34 @@ +1194 Add ACR status option for CCM energy moves +################# + +API Breaks +---------- +- N/A + +Features +-------- +- N/A + +Device Updates +-------------- +- Add a CCMEnergyWithACRStatus class to ccm.py +- Add a energy_with_acr_status instance to CCM +- Update BeamEnergyRequest argument from bunch to pv_index to better reflect the broader use cases. + A backward compatible warning is now returned if the old bunch kwarg is used. +- Update atol in BeamEnergyRequestNoWait to 0.5 (was 5). This is needed for self-seeding + +New Devices +----------- +- Add a convenience decorator to re-arg a function in utils.py + +Bugfixes +-------- +- N/A + +Maintenance +----------- +- N/A + +Contributors +------------ +- vespos