Skip to content

Add bumps to commisslib#315

Open
xresende wants to merge 19 commits intomasterfrom
add-bumps-to-commisslib
Open

Add bumps to commisslib#315
xresende wants to merge 19 commits intomasterfrom
add-bumps-to-commisslib

Conversation

@xresende
Copy link
Contributor

No description provided.

@xresende xresende marked this pull request as ready for review January 23, 2026 20:18
@Gabrielrezende-asc
Copy link
Contributor

Some changes still need to be tested during machine studies shifts, but I believe this first version is ready to be merged.

@Gabrielrezende-asc
Copy link
Contributor

Thanks for the review! In our next machine study (Monday), I will use some time to test the scans. After this, some other bugs will be corrected, and I think the class will be ready to be merged

Comment on lines +120 to +128
def do_measurement():
"""Measurement function.

Change this function by an external
function that does the measurement
you want to perform at each bump point.
"""
print('Not a measurement!')
return {}
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't understand. why is this method not implemented?

Copy link
Contributor

Choose a reason for hiding this comment

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

It is because it can be a general measurement, it could be with XBPMS or other things. The user must define it in the script

Comment on lines +155 to +163
def update_reforb(self, refx, refy):
"""Update reforb.

Args:
refx (1d numpy array): Horizontal orbit
refy (1d numpy array): Vertical orbit
"""
self.reforbx = refx
self.reforby = refy
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this shouldn't exist anymore, right?

Comment on lines +194 to +202
def get_sofb_bpm_enbl(self):
"""."""
self._bpmxenbl = _np.copy(self.devices['sofb'].bpmxenbl)
self._bpmyenbl = _np.copy(self.devices['sofb'].bpmyenbl)

def get_fofb_bpm_enbl(self):
"""."""
self._fofb_bpmxenbl = _np.copy(self.devices['fofb'].bpmxenbl)
self._fofb_bpmyenbl = _np.copy(self.devices['fofb'].bpmyenbl)
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't understand. Is this supposed to get an initial state of the enabled list? Shouldn't this run at the beginning of the experiment, instead of at the object initialization? shouldn't this the saved as metadata of the experiment?

Copy link
Contributor

Choose a reason for hiding this comment

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

This represents the initial state of the enabled list. I believe we can store this state during object initialization. I don’t see it as a necessary parameter to include in the experiment metadata, but if you think it should be saved there, I can modify it accordingly.

Comment on lines +214 to +215
sofb.refx = self.params.reforbx
sofb.refy = self.params.reforby
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't this return to the reference orbit both systems had prior to the experiment, instead of the reference orbit used during the experiment?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, it is already doing that. The reference orbit prior to the experiment is stored in the Params class, and it is exactly the one being used here.

)
fofb.bpmxenbl = enblx
fofb.bpmyenbl = enbly
_time.sleep(0.5) # NOTE: For some reason We have to wait here.
Copy link
Contributor

Choose a reason for hiding this comment

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

what happens if you do not wait? isn't it possible to wait for something to happen and then move on? Fixed wait times like this one are not a good practice. We should avoid it.

Copy link
Contributor

Choose a reason for hiding this comment

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

Sometimes the BPM enabled list was not being set correctly. After adding this wait, the issue has not occurred again.

Comment on lines +267 to +273
idcx = idx[:2]
idcy = idx[2:] - 160
dorbx = self.devices['sofb'].orbx - refx
dorby = self.devices['sofb'].orby - refy
dorbx = dorbx[idcx]
dorby = dorby[idcy]
return _np.sqrt(_np.sum(_np.hstack([dorbx, dorby] ** 2)))
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe

Suggested change
idcx = idx[:2]
idcy = idx[2:] - 160
dorbx = self.devices['sofb'].orbx - refx
dorby = self.devices['sofb'].orby - refy
dorbx = dorbx[idcx]
dorby = dorby[idcy]
return _np.sqrt(_np.sum(_np.hstack([dorbx, dorby] ** 2)))
sofb = self.devices['sofb']
ref = np.r_[refx, refy]
orb = np.r_[sofb.orbx, sofb.orby]
dorb = (orb - ref)[idx] ** 2
return _np.sqrt(dorb.sum())

Copy link
Contributor

Choose a reason for hiding this comment

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

Good idea!

dorby = dorby[idcy]
return _np.sqrt(_np.sum(_np.hstack([dorbx, dorby] ** 2)))

def set_orb(self, orbx, orby):
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe set_reforb?

Comment on lines +332 to +340
if self.params.use_fofb:
kick = _np.max((
_np.abs(fofb.kickch_acc),
_np.abs(fofb.kickcv_acc),
))
else:
_ = sofb.correct_orbit_manually(
nr_iters=nr_iters, residue=residue
)
Copy link
Contributor

Choose a reason for hiding this comment

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

I think the meaning of use_fofb is obscure, because it not only controls whether FOFB will be used or not, it is also selecting whether the manual orbit correction with SOFB will be applied. Consider changing the name of the property to something more accurate.

Comment on lines +398 to +400
def save_data(self, fname, overwrite=False, compress=False):
"""."""
return super().save_data(fname, overwrite, compress)
Copy link
Contributor

Choose a reason for hiding this comment

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

Why re-implement this method?

Copy link
Contributor

@fernandohds564 fernandohds564 left a comment

Choose a reason for hiding this comment

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

@Gabrielrezende-asc and I talked offline about some suggestions. I'll wait for a new version for revision.

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.

4 participants