diff --git a/examples/other_examples/ORM_Tango_server/ORM.py b/examples/other_examples/ORM_Tango_server/ORM.py index 186476af..fe686076 100644 --- a/examples/other_examples/ORM_Tango_server/ORM.py +++ b/examples/other_examples/ORM_Tango_server/ORM.py @@ -102,8 +102,8 @@ def orbit_callback(self, action: int, cdata): def orm_run(self): # On design sleep 10ms to allow thread schedule - self.SR.design.orm.measure(callback=orbit_callback, sleep_between_meas=0.01) - self.orm_data = self.SR.design.orm.get() + self.SR.design.tool.orm.measure(callback=orbit_callback, sleep_between_meas=0.01) + self.orm_data = self.SR.design.tool.orm.get() self.set_status(f"Ready to scan: {self.ConfigFileName}") self.set_state(DevState.ON) diff --git a/examples/use_cases/01-tune_correction.ipynb b/examples/use_cases/01-tune_correction.ipynb index dfba75bb..cf6e3471 100644 --- a/examples/use_cases/01-tune_correction.ipynb +++ b/examples/use_cases/01-tune_correction.ipynb @@ -282,83 +282,15 @@ "cell_type": "markdown", "id": "04431246", "metadata": {}, - "source": [ - "### Standard tune correction tool\n", - "\n", - "`SR.tune` is the `DEFAULT_TUNE_CORRECTION` tool. `SR.trm` is the `DEFAULT_TUNE_RESPONSE_MATRIX` tool.\n", - "\n", - "Before correcting the tune you need a response matrix. It can be measured (below) or loaded from a previously saved file." - ] + "source": "### Standard tune correction tool\n\n`SR.tool.tune` is the `DEFAULT_TUNE_CORRECTION` tool. `SR.tool.trm` is the `DEFAULT_TUNE_RESPONSE_MATRIX` tool.\n\nBefore correcting the tune you need a response matrix. It can be measured (below) or loaded from a previously saved file." }, { "cell_type": "code", - "execution_count": 8, + "execution_count": null, "id": "5c57ef30", "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "Tune(quad_array_name='QForTune', betatron_tune_name='BETATRON_TUNE', response_matrix=array([[ 0.17853128, 0.17890919, 0.17917984, 0.17843061, 0.17932054,\n", - " 0.17884878, 0.1786898 , 0.17950221, 0.17836418, 0.1790288 ,\n", - " 0.17907229, 0.17845344, 0.17936885, 0.1787317 , 0.17880339,\n", - " 0.1793422 , 0.17843576, 0.17914062, 0.17895506, 0.17850485,\n", - " 0.15843663, 0.1575313 , 0.15237977, 0.15250702, 0.17830408,\n", - " 0.17955648, 0.1784584 , 0.17880469, 0.17936621, 0.17824945,\n", - " 0.17941811, 0.17905372, 0.17841113, 0.17957284, 0.17835113,\n", - " 0.17897118, 0.17923226, 0.17825399, 0.17950825, 0.17876573,\n", - " 0.17866201, 0.17954684, 0.17827911, 0.17925585, 0.17897151,\n", - " 0.17830041, 0.17956082, 0.17873061, 0.17871689, 0.17948152,\n", - " 0.15577439, 0.15662709, 0.178933 , 0.17847488, 0.17937198,\n", - " 0.17881763, 0.17874021, 0.17931638, 0.17843723, 0.17929549,\n", - " 0.17880609, 0.17853484, 0.59082023, 0.59180433, 0.59274339,\n", - " 0.59079241, 0.59387998, 0.59265135, 0.59209988, 0.59391444,\n", - " 0.59072413, 0.59219559, 0.59234655, 0.59073497, 0.59391106,\n", - " 0.59225191, 0.59250056, 0.59390362, 0.59075881, 0.59259427,\n", - " 0.5919504 , 0.59077803, 0.52411485, 0.52163044, 0.50248335,\n", - " 0.50266086, 0.59115919, 0.59419444, 0.59038465, 0.59128648,\n", - " 0.59323464, 0.59032653, 0.59438116, 0.59313174, 0.59165988,\n", - " 0.5944257 , 0.59018699, 0.59180163, 0.59270748, 0.59015999,\n", - " 0.59451179, 0.5925782 , 0.59221837, 0.59452251, 0.59012406,\n", - " 0.59236712, 0.59213945, 0.59013148, 0.59450445, 0.59204248,\n", - " 0.59275305, 0.59448392, 0.51467256, 0.51681741, 0.59219055,\n", - " 0.59076114, 0.59387372, 0.59213029, 0.59261978, 0.59385979,\n", - " 0.59080955, 0.59274399, 0.59180476, 0.59083819],\n", - " [-1.26055967, -1.26031469, -1.2598023 , -1.26083158, -1.25981216,\n", - " -1.26160634, -1.26143231, -1.25920552, -1.26001143, -1.26105243,\n", - " -1.26026455, -1.26115601, -1.26145837, -1.25972946, -1.26035568,\n", - " -1.26035017, -1.25972691, -1.26145864, -1.2611518 , -1.26026992,\n", - " -1.28718859, -1.28580227, -1.29551207, -1.29591315, -1.26023455,\n", - " -1.26119118, -1.2611013 , -1.26019174, -1.26077014, -1.26007772,\n", - " -1.25987122, -1.260857 , -1.2609502 , -1.26075456, -1.26134921,\n", - " -1.25965397, -1.25996982, -1.26071455, -1.25976978, -1.26108183,\n", - " -1.26034272, -1.26107775, -1.26118967, -1.25922595, -1.25959951,\n", - " -1.26157551, -1.26072113, -1.26058879, -1.26193197, -1.25939288,\n", - " -1.28878699, -1.28913722, -1.26030408, -1.26116608, -1.26092241,\n", - " -1.25960761, -1.2599948 , -1.26128422, -1.26055622, -1.26012439,\n", - " -1.26052166, -1.2609009 , -0.49429912, -0.49420118, -0.49402884,\n", - " -0.49444032, -0.49392715, -0.49464442, -0.49464248, -0.49384803,\n", - " -0.4940031 , -0.49450349, -0.49410766, -0.49446404, -0.49461625,\n", - " -0.49392508, -0.49424032, -0.49423811, -0.49392437, -0.49461667,\n", - " -0.4944622 , -0.49410966, -0.49580432, -0.4952599 , -0.49584758,\n", - " -0.49606291, -0.49405329, -0.49450455, -0.4944593 , -0.49409569,\n", - " -0.49438685, -0.49411004, -0.49400608, -0.49449611, -0.4942921 ,\n", - " -0.49429813, -0.49459747, -0.49391976, -0.49407876, -0.49437648,\n", - " -0.49398646, -0.49451098, -0.49413892, -0.49443276, -0.49457543,\n", - " -0.49388618, -0.49382348, -0.49469773, -0.49426765, -0.49431067,\n", - " -0.49473566, -0.49380506, -0.49553592, -0.49574219, -0.49407224,\n", - " -0.4944902 , -0.4944531 , -0.49402325, -0.49396739, -0.49456722,\n", - " -0.49428634, -0.49420954, -0.49415863, -0.49439461]]), _tm=BetatronTuneMonitor(tune_h='srdiag/beam-tune/main/Qh', tune_v='srdiag/beam-tune/main/Qv', name='BETATRON_TUNE'), _quads=[Quadrupole(peer='Simulator:design', name='QD2E-C04', model_name='QD2E-C04', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QD2A-C05', model_name='QD2A-C05', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QD2E-C05', model_name='QD2E-C05', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QD2A-C06', model_name='QD2A-C06', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QD2E-C06', model_name='QD2E-C06', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QD2A-C07', model_name='QD2A-C07', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QD2E-C07', model_name='QD2E-C07', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QD2A-C08', model_name='QD2A-C08', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QD2E-C08', model_name='QD2E-C08', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QD2A-C09', model_name='QD2A-C09', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QD2E-C09', model_name='QD2E-C09', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QD2A-C10', model_name='QD2A-C10', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QD2E-C10', model_name='QD2E-C10', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QD2A-C11', model_name='QD2A-C11', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QD2E-C11', model_name='QD2E-C11', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QD2A-C12', model_name='QD2A-C12', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QD2E-C12', model_name='QD2E-C12', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QD2A-C13', model_name='QD2A-C13', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QD2E-C13', model_name='QD2E-C13', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QD2A-C14', model_name='QD2A-C14', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QD2E-C14', model_name='QD2E-C14', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QD2A-C15', model_name='QD2A-C15', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QD2E-C15', model_name='QD2E-C15', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QD2A-C16', model_name='QD2A-C16', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QD2E-C16', model_name='QD2E-C16', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QD2A-C17', model_name='QD2A-C17', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QD2E-C17', model_name='QD2E-C17', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QD2A-C18', model_name='QD2A-C18', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QD2E-C18', model_name='QD2E-C18', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QD2A-C19', model_name='QD2A-C19', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QD2E-C19', model_name='QD2E-C19', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QD2A-C20', model_name='QD2A-C20', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QD2E-C20', model_name='QD2E-C20', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QD2A-C21', model_name='QD2A-C21', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QD2E-C21', model_name='QD2E-C21', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QD2A-C22', model_name='QD2A-C22', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QD2E-C22', model_name='QD2E-C22', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QD2A-C23', model_name='QD2A-C23', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QD2E-C23', model_name='QD2E-C23', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QD2A-C24', model_name='QD2A-C24', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QD2E-C24', model_name='QD2E-C24', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QD2A-C25', model_name='QD2A-C25', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QD2E-C25', model_name='QD2E-C25', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QD2A-C26', model_name='QD2A-C26', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QD2E-C26', model_name='QD2E-C26', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QD2A-C27', model_name='QD2A-C27', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QD2E-C27', model_name='QD2E-C27', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QD2A-C28', model_name='QD2A-C28', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QD2E-C28', model_name='QD2E-C28', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QD2A-C29', model_name='QD2A-C29', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QD2E-C29', model_name='QD2E-C29', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QD2A-C30', model_name='QD2A-C30', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QD2E-C30', model_name='QD2E-C30', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QD2A-C31', model_name='QD2A-C31', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QD2E-C31', model_name='QD2E-C31', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QD2A-C32', model_name='QD2A-C32', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QD2E-C32', model_name='QD2E-C32', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QD2A-C01', model_name='QD2A-C01', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QD2E-C01', model_name='QD2E-C01', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QD2A-C02', model_name='QD2A-C02', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QD2E-C02', model_name='QD2E-C02', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QD2A-C03', model_name='QD2A-C03', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QF1E-C04', model_name='QF1E-C04', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QF1A-C05', model_name='QF1A-C05', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QF1E-C05', model_name='QF1E-C05', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QF1A-C06', model_name='QF1A-C06', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QF1E-C06', model_name='QF1E-C06', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QF1A-C07', model_name='QF1A-C07', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QF1E-C07', model_name='QF1E-C07', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QF1A-C08', model_name='QF1A-C08', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QF1E-C08', model_name='QF1E-C08', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QF1A-C09', model_name='QF1A-C09', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QF1E-C09', model_name='QF1E-C09', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QF1A-C10', model_name='QF1A-C10', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QF1E-C10', model_name='QF1E-C10', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QF1A-C11', model_name='QF1A-C11', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QF1E-C11', model_name='QF1E-C11', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QF1A-C12', model_name='QF1A-C12', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QF1E-C12', model_name='QF1E-C12', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QF1A-C13', model_name='QF1A-C13', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QF1E-C13', model_name='QF1E-C13', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QF1A-C14', model_name='QF1A-C14', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QF1E-C14', model_name='QF1E-C14', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QF1A-C15', model_name='QF1A-C15', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QF1E-C15', model_name='QF1E-C15', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QF1A-C16', model_name='QF1A-C16', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QF1E-C16', model_name='QF1E-C16', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QF1A-C17', model_name='QF1A-C17', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QF1E-C17', model_name='QF1E-C17', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QF1A-C18', model_name='QF1A-C18', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QF1E-C18', model_name='QF1E-C18', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QF1A-C19', model_name='QF1A-C19', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QF1E-C19', model_name='QF1E-C19', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QF1A-C20', model_name='QF1A-C20', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QF1E-C20', model_name='QF1E-C20', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QF1A-C21', model_name='QF1A-C21', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QF1E-C21', model_name='QF1E-C21', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QF1A-C22', model_name='QF1A-C22', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QF1E-C22', model_name='QF1E-C22', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QF1A-C23', model_name='QF1A-C23', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QF1E-C23', model_name='QF1E-C23', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QF1A-C24', model_name='QF1A-C24', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QF1E-C24', model_name='QF1E-C24', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QF1A-C25', model_name='QF1A-C25', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QF1E-C25', model_name='QF1E-C25', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QF1A-C26', model_name='QF1A-C26', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QF1E-C26', model_name='QF1E-C26', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QF1A-C27', model_name='QF1A-C27', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QF1E-C27', model_name='QF1E-C27', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QF1A-C28', model_name='QF1A-C28', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QF1E-C28', model_name='QF1E-C28', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QF1A-C29', model_name='QF1A-C29', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QF1E-C29', model_name='QF1E-C29', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QF1A-C30', model_name='QF1A-C30', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QF1E-C30', model_name='QF1E-C30', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QF1A-C31', model_name='QF1A-C31', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QF1E-C31', model_name='QF1E-C31', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QF1A-C32', model_name='QF1A-C32', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QF1E-C32', model_name='QF1E-C32', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QF1A-C01', model_name='QF1A-C01', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QF1E-C01', model_name='QF1E-C01', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QF1A-C02', model_name='QF1A-C02', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QF1E-C02', model_name='QF1E-C02', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QF1A-C03', model_name='QF1A-C03', magnet_model=LinearMagnetModel)], name='DEFAULT_TUNE_CORRECTION')" - ] - }, - "execution_count": 8, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "SR.tune # string representation" - ] + "outputs": [], + "source": "SR.tool.tune # string representation" }, { "cell_type": "markdown", @@ -391,142 +323,25 @@ }, { "cell_type": "code", - "execution_count": 10, + "execution_count": null, "id": "c81cdb05", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Response matrix loaded.\n" - ] - }, - { - "data": { - "text/plain": [ - "TuneResponseMatrix(quad_array_name='QForTune', betatron_tune_name='BETATRON_TUNE', quad_delta=0.0001, n_step=1, sleep_between_step=0.0, n_avg_meas=1, sleep_between_meas=0.0, name='DEFAULT_TUNE_RESPONSE_MATRIX')" - ] - }, - "execution_count": 10, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "if SR.tune.response_matrix is None:\n", - " SR.trm.measure(sleep_between_step=wait_time, callback=tune_callback)\n", - " SR.trm.save(CONFIG_DIR / \"trm.json\")\n", - "\n", - "SR.tune.load(CONFIG_DIR / \"trm.json\")\n", - "print(\"Response matrix loaded.\")\n", - "SR.trm # string representation" - ] + "outputs": [], + "source": "if SR.tool.tune.response_matrix is None:\n SR.tool.trm.measure(sleep_between_step=wait_time, callback=tune_callback)\n SR.tool.trm.save(CONFIG_DIR / \"trm.json\")\n\nSR.tool.tune.load(CONFIG_DIR / \"trm.json\")\nprint(\"Response matrix loaded.\")\nSR.tool.trm # string representation" }, { "cell_type": "markdown", "id": "ef7d7ce4", "metadata": {}, - "source": [ - "#### Correcting the tune\n", - "\n", - "`SR.tune.set([qx, qy])` runs the correction iteratively. The `iter` parameter controls the number of iterations and `wait_time` the settling time between each iteration." - ] + "source": "#### Correcting the tune\n\n`SR.tool.tune.set([qx, qy])` runs the correction iteratively. The `iter` parameter controls the number of iterations and `wait_time` the settling time between each iteration." }, { "cell_type": "code", - "execution_count": 11, + "execution_count": null, "id": "6b8bcf91", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Tune before correction: [0.16000001 0.33999986]\n", - "\n", - "Setting tune to [0.19, 0.28]\n", - "Tune after correction: [0.19 0.28]\n", - "\n", - "Setting tune to [0.21, 0.3]\n", - "Tune after correction: [0.21 0.3 ]\n" - ] - }, - { - "data": { - "text/plain": [ - "Tune(quad_array_name='QForTune', betatron_tune_name='BETATRON_TUNE', response_matrix=array([[ 0.17853128, 0.17890919, 0.17917984, 0.17843061, 0.17932054,\n", - " 0.17884878, 0.1786898 , 0.17950221, 0.17836418, 0.1790288 ,\n", - " 0.17907229, 0.17845344, 0.17936885, 0.1787317 , 0.17880339,\n", - " 0.1793422 , 0.17843576, 0.17914062, 0.17895506, 0.17850485,\n", - " 0.15843663, 0.1575313 , 0.15237977, 0.15250702, 0.17830408,\n", - " 0.17955648, 0.1784584 , 0.17880469, 0.17936621, 0.17824945,\n", - " 0.17941811, 0.17905372, 0.17841113, 0.17957284, 0.17835113,\n", - " 0.17897118, 0.17923226, 0.17825399, 0.17950825, 0.17876573,\n", - " 0.17866201, 0.17954684, 0.17827911, 0.17925585, 0.17897151,\n", - " 0.17830041, 0.17956082, 0.17873061, 0.17871689, 0.17948152,\n", - " 0.15577439, 0.15662709, 0.178933 , 0.17847488, 0.17937198,\n", - " 0.17881763, 0.17874021, 0.17931638, 0.17843723, 0.17929549,\n", - " 0.17880609, 0.17853484, 0.59082023, 0.59180433, 0.59274339,\n", - " 0.59079241, 0.59387998, 0.59265135, 0.59209988, 0.59391444,\n", - " 0.59072413, 0.59219559, 0.59234655, 0.59073497, 0.59391106,\n", - " 0.59225191, 0.59250056, 0.59390362, 0.59075881, 0.59259427,\n", - " 0.5919504 , 0.59077803, 0.52411485, 0.52163044, 0.50248335,\n", - " 0.50266086, 0.59115919, 0.59419444, 0.59038465, 0.59128648,\n", - " 0.59323464, 0.59032653, 0.59438116, 0.59313174, 0.59165988,\n", - " 0.5944257 , 0.59018699, 0.59180163, 0.59270748, 0.59015999,\n", - " 0.59451179, 0.5925782 , 0.59221837, 0.59452251, 0.59012406,\n", - " 0.59236712, 0.59213945, 0.59013148, 0.59450445, 0.59204248,\n", - " 0.59275305, 0.59448392, 0.51467256, 0.51681741, 0.59219055,\n", - " 0.59076114, 0.59387372, 0.59213029, 0.59261978, 0.59385979,\n", - " 0.59080955, 0.59274399, 0.59180476, 0.59083819],\n", - " [-1.26055967, -1.26031469, -1.2598023 , -1.26083158, -1.25981216,\n", - " -1.26160634, -1.26143231, -1.25920552, -1.26001143, -1.26105243,\n", - " -1.26026455, -1.26115601, -1.26145837, -1.25972946, -1.26035568,\n", - " -1.26035017, -1.25972691, -1.26145864, -1.2611518 , -1.26026992,\n", - " -1.28718859, -1.28580227, -1.29551207, -1.29591315, -1.26023455,\n", - " -1.26119118, -1.2611013 , -1.26019174, -1.26077014, -1.26007772,\n", - " -1.25987122, -1.260857 , -1.2609502 , -1.26075456, -1.26134921,\n", - " -1.25965397, -1.25996982, -1.26071455, -1.25976978, -1.26108183,\n", - " -1.26034272, -1.26107775, -1.26118967, -1.25922595, -1.25959951,\n", - " -1.26157551, -1.26072113, -1.26058879, -1.26193197, -1.25939288,\n", - " -1.28878699, -1.28913722, -1.26030408, -1.26116608, -1.26092241,\n", - " -1.25960761, -1.2599948 , -1.26128422, -1.26055622, -1.26012439,\n", - " -1.26052166, -1.2609009 , -0.49429912, -0.49420118, -0.49402884,\n", - " -0.49444032, -0.49392715, -0.49464442, -0.49464248, -0.49384803,\n", - " -0.4940031 , -0.49450349, -0.49410766, -0.49446404, -0.49461625,\n", - " -0.49392508, -0.49424032, -0.49423811, -0.49392437, -0.49461667,\n", - " -0.4944622 , -0.49410966, -0.49580432, -0.4952599 , -0.49584758,\n", - " -0.49606291, -0.49405329, -0.49450455, -0.4944593 , -0.49409569,\n", - " -0.49438685, -0.49411004, -0.49400608, -0.49449611, -0.4942921 ,\n", - " -0.49429813, -0.49459747, -0.49391976, -0.49407876, -0.49437648,\n", - " -0.49398646, -0.49451098, -0.49413892, -0.49443276, -0.49457543,\n", - " -0.49388618, -0.49382348, -0.49469773, -0.49426765, -0.49431067,\n", - " -0.49473566, -0.49380506, -0.49553592, -0.49574219, -0.49407224,\n", - " -0.4944902 , -0.4944531 , -0.49402325, -0.49396739, -0.49456722,\n", - " -0.49428634, -0.49420954, -0.49415863, -0.49439461]]), _tm=BetatronTuneMonitor(tune_h='srdiag/beam-tune/main/Qh', tune_v='srdiag/beam-tune/main/Qv', name='BETATRON_TUNE'), _quads=[Quadrupole(peer='Simulator:design', name='QD2E-C04', model_name='QD2E-C04', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QD2A-C05', model_name='QD2A-C05', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QD2E-C05', model_name='QD2E-C05', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QD2A-C06', model_name='QD2A-C06', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QD2E-C06', model_name='QD2E-C06', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QD2A-C07', model_name='QD2A-C07', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QD2E-C07', model_name='QD2E-C07', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QD2A-C08', model_name='QD2A-C08', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QD2E-C08', model_name='QD2E-C08', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QD2A-C09', model_name='QD2A-C09', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QD2E-C09', model_name='QD2E-C09', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QD2A-C10', model_name='QD2A-C10', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QD2E-C10', model_name='QD2E-C10', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QD2A-C11', model_name='QD2A-C11', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QD2E-C11', model_name='QD2E-C11', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QD2A-C12', model_name='QD2A-C12', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QD2E-C12', model_name='QD2E-C12', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QD2A-C13', model_name='QD2A-C13', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QD2E-C13', model_name='QD2E-C13', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QD2A-C14', model_name='QD2A-C14', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QD2E-C14', model_name='QD2E-C14', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QD2A-C15', model_name='QD2A-C15', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QD2E-C15', model_name='QD2E-C15', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QD2A-C16', model_name='QD2A-C16', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QD2E-C16', model_name='QD2E-C16', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QD2A-C17', model_name='QD2A-C17', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QD2E-C17', model_name='QD2E-C17', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QD2A-C18', model_name='QD2A-C18', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QD2E-C18', model_name='QD2E-C18', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QD2A-C19', model_name='QD2A-C19', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QD2E-C19', model_name='QD2E-C19', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QD2A-C20', model_name='QD2A-C20', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QD2E-C20', model_name='QD2E-C20', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QD2A-C21', model_name='QD2A-C21', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QD2E-C21', model_name='QD2E-C21', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QD2A-C22', model_name='QD2A-C22', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QD2E-C22', model_name='QD2E-C22', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QD2A-C23', model_name='QD2A-C23', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QD2E-C23', model_name='QD2E-C23', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QD2A-C24', model_name='QD2A-C24', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QD2E-C24', model_name='QD2E-C24', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QD2A-C25', model_name='QD2A-C25', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QD2E-C25', model_name='QD2E-C25', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QD2A-C26', model_name='QD2A-C26', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QD2E-C26', model_name='QD2E-C26', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QD2A-C27', model_name='QD2A-C27', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QD2E-C27', model_name='QD2E-C27', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QD2A-C28', model_name='QD2A-C28', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QD2E-C28', model_name='QD2E-C28', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QD2A-C29', model_name='QD2A-C29', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QD2E-C29', model_name='QD2E-C29', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QD2A-C30', model_name='QD2A-C30', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QD2E-C30', model_name='QD2E-C30', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QD2A-C31', model_name='QD2A-C31', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QD2E-C31', model_name='QD2E-C31', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QD2A-C32', model_name='QD2A-C32', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QD2E-C32', model_name='QD2E-C32', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QD2A-C01', model_name='QD2A-C01', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QD2E-C01', model_name='QD2E-C01', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QD2A-C02', model_name='QD2A-C02', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QD2E-C02', model_name='QD2E-C02', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QD2A-C03', model_name='QD2A-C03', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QF1E-C04', model_name='QF1E-C04', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QF1A-C05', model_name='QF1A-C05', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QF1E-C05', model_name='QF1E-C05', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QF1A-C06', model_name='QF1A-C06', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QF1E-C06', model_name='QF1E-C06', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QF1A-C07', model_name='QF1A-C07', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QF1E-C07', model_name='QF1E-C07', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QF1A-C08', model_name='QF1A-C08', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QF1E-C08', model_name='QF1E-C08', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QF1A-C09', model_name='QF1A-C09', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QF1E-C09', model_name='QF1E-C09', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QF1A-C10', model_name='QF1A-C10', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QF1E-C10', model_name='QF1E-C10', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QF1A-C11', model_name='QF1A-C11', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QF1E-C11', model_name='QF1E-C11', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QF1A-C12', model_name='QF1A-C12', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QF1E-C12', model_name='QF1E-C12', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QF1A-C13', model_name='QF1A-C13', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QF1E-C13', model_name='QF1E-C13', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QF1A-C14', model_name='QF1A-C14', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QF1E-C14', model_name='QF1E-C14', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QF1A-C15', model_name='QF1A-C15', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QF1E-C15', model_name='QF1E-C15', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QF1A-C16', model_name='QF1A-C16', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QF1E-C16', model_name='QF1E-C16', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QF1A-C17', model_name='QF1A-C17', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QF1E-C17', model_name='QF1E-C17', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QF1A-C18', model_name='QF1A-C18', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QF1E-C18', model_name='QF1E-C18', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QF1A-C19', model_name='QF1A-C19', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QF1E-C19', model_name='QF1E-C19', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QF1A-C20', model_name='QF1A-C20', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QF1E-C20', model_name='QF1E-C20', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QF1A-C21', model_name='QF1A-C21', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QF1E-C21', model_name='QF1E-C21', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QF1A-C22', model_name='QF1A-C22', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QF1E-C22', model_name='QF1E-C22', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QF1A-C23', model_name='QF1A-C23', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QF1E-C23', model_name='QF1E-C23', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QF1A-C24', model_name='QF1A-C24', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QF1E-C24', model_name='QF1E-C24', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QF1A-C25', model_name='QF1A-C25', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QF1E-C25', model_name='QF1E-C25', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QF1A-C26', model_name='QF1A-C26', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QF1E-C26', model_name='QF1E-C26', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QF1A-C27', model_name='QF1A-C27', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QF1E-C27', model_name='QF1E-C27', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QF1A-C28', model_name='QF1A-C28', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QF1E-C28', model_name='QF1E-C28', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QF1A-C29', model_name='QF1A-C29', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QF1E-C29', model_name='QF1E-C29', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QF1A-C30', model_name='QF1A-C30', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QF1E-C30', model_name='QF1E-C30', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QF1A-C31', model_name='QF1A-C31', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QF1E-C31', model_name='QF1E-C31', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QF1A-C32', model_name='QF1A-C32', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QF1E-C32', model_name='QF1E-C32', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QF1A-C01', model_name='QF1A-C01', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QF1E-C01', model_name='QF1E-C01', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QF1A-C02', model_name='QF1A-C02', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QF1E-C02', model_name='QF1E-C02', magnet_model=LinearMagnetModel), Quadrupole(peer='Simulator:design', name='QF1A-C03', model_name='QF1A-C03', magnet_model=LinearMagnetModel)], name='DEFAULT_TUNE_CORRECTION')" - ] - }, - "execution_count": 11, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "print(f\"Tune before correction: {SR.tune.readback()}\")\n", - "\n", - "qx, qy = 0.19, 0.28\n", - "print(f\"\\nSetting tune to [{qx}, {qy}]\")\n", - "SR.tune.set([qx, qy], iter=10, wait_time=wait_time)\n", - "print(f\"Tune after correction: {SR.tune.readback()}\")\n", - "\n", - "qx, qy = 0.21, 0.30\n", - "print(f\"\\nSetting tune to [{qx}, {qy}]\")\n", - "SR.tune.set([qx, qy], iter=10, wait_time=wait_time)\n", - "print(f\"Tune after correction: {SR.tune.readback()}\")\n", - "\n", - "SR.tune # string representation" - ] + "outputs": [], + "source": "print(f\"Tune before correction: {SR.tool.tune.readback()}\")\n\nqx, qy = 0.19, 0.28\nprint(f\"\\nSetting tune to [{qx}, {qy}]\")\nSR.tool.tune.set([qx, qy], iter=10, wait_time=wait_time)\nprint(f\"Tune after correction: {SR.tool.tune.readback()}\")\n\nqx, qy = 0.21, 0.30\nprint(f\"\\nSetting tune to [{qx}, {qy}]\")\nSR.tool.tune.set([qx, qy], iter=10, wait_time=wait_time)\nprint(f\"Tune after correction: {SR.tool.tune.readback()}\")\n\nSR.tool.tune # string representation" }, { "cell_type": "code", diff --git a/examples/use_cases/01-tune_correction.py b/examples/use_cases/01-tune_correction.py index d77cb367..fc84e929 100644 --- a/examples/use_cases/01-tune_correction.py +++ b/examples/use_cases/01-tune_correction.py @@ -112,14 +112,14 @@ # ### Standard tune correction tool # -# `SR.tune` is the `DEFAULT_TUNE_CORRECTION` tool. `SR.trm` is the `DEFAULT_TUNE_RESPONSE_MATRIX` tool. +# `SR.tool.tune` is the `DEFAULT_TUNE_CORRECTION` tool. `SR.tool.trm` is the `DEFAULT_TUNE_RESPONSE_MATRIX` tool. # # Before correcting the tune you need a response matrix. It can be measured (below) or loaded from a previously saved file. # In[7]: -print(SR.tune) # string representation +print(SR.tool.tune) # string representation # #### Measuring the tune response matrix @@ -145,36 +145,36 @@ def tune_callback(action: int, cb_data: dict): # In[9]: -if SR.tune.response_matrix is None: - SR.trm.measure(sleep_between_step=wait_time, callback=tune_callback) - SR.trm.save(CONFIG_DIR / "trm.json") +if SR.tool.tune.response_matrix is None: + SR.tool.trm.measure(sleep_between_step=wait_time, callback=tune_callback) + SR.tool.trm.save(CONFIG_DIR / "trm.json") -SR.tune.load(CONFIG_DIR / "trm.json") +SR.tool.tune.load(CONFIG_DIR / "trm.json") print("Response matrix loaded.") -print(SR.trm) # string representation +print(SR.tool.trm) # string representation # #### Correcting the tune # -# `SR.tune.set([qx, qy])` runs the correction iteratively. The `iter` parameter controls +# `SR.tool.tune.set([qx, qy])` runs the correction iteratively. The `iter` parameter controls # the number of iterations and `wait_time` the settling time between each iteration. # In[10]: -print(f"Tune before correction: {SR.tune.readback()}") +print(f"Tune before correction: {SR.tool.tune.readback()}") qx, qy = 0.19, 0.28 print(f"\nSetting tune to [{qx}, {qy}]") -SR.tune.set([qx, qy], iter=10, wait_time=wait_time) -print(f"Tune after correction: {SR.tune.readback()}") +SR.tool.tune.set([qx, qy], iter=10, wait_time=wait_time) +print(f"Tune after correction: {SR.tool.tune.readback()}") qx, qy = 0.21, 0.30 print(f"\nSetting tune to [{qx}, {qy}]") -SR.tune.set([qx, qy], iter=10, wait_time=wait_time) -print(f"Tune after correction: {SR.tune.readback()}") +SR.tool.tune.set([qx, qy], iter=10, wait_time=wait_time) +print(f"Tune after correction: {SR.tool.tune.readback()}") -print(SR.tune) # string representation +print(SR.tool.tune) # string representation # In[ ]: diff --git a/examples/use_cases/03-orbit_correction.ipynb b/examples/use_cases/03-orbit_correction.ipynb index 58cad3cc..9121fd64 100644 --- a/examples/use_cases/03-orbit_correction.ipynb +++ b/examples/use_cases/03-orbit_correction.ipynb @@ -195,140 +195,23 @@ "cell_type": "markdown", "id": "808334df", "metadata": {}, - "source": [ - "### Orbit response matrix\n", - "\n", - "The ORM can be saved in multiple formats. Load it into `SR.orbit` before correcting." - ] + "source": "### Orbit response matrix\n\nThe ORM can be saved in multiple formats. Load it into `SR.tool.orbit` before correcting." }, { "cell_type": "code", - "execution_count": 7, + "execution_count": null, "id": "33636af2", "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "OrbitResponseMatrix(bpm_array_name='BPM', hcorr_array_name='HCorr', vcorr_array_name='VCorr', corrector_delta=1e-06, n_step=1, sleep_between_step=0.0, n_avg_meas=1, sleep_between_meas=0.0, name='DEFAULT_ORBIT_RESPONSE_MATRIX')" - ] - }, - "execution_count": 7, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "SR.orm # string representation" - ] + "outputs": [], + "source": "SR.tool.orm # string representation" }, { "cell_type": "code", "execution_count": null, "id": "3f9dcb18", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "14 Sep 2026, 15:10:12 | INFO | Measuring correctors from the default arrays: HCorr and VCorr.\n", - "14 Sep 2026, 15:10:14 | INFO | Measured response of SH1A-C04-H.\n", - "14 Sep 2026, 15:10:16 | INFO | Measured response of SJ1A-C04-H.\n", - "14 Sep 2026, 15:10:17 | INFO | Measured response of SJ2A-C04-H.\n", - "14 Sep 2026, 15:10:18 | INFO | Measured response of SJ1B-C04-H.\n", - "14 Sep 2026, 15:10:19 | INFO | Measured response of SH2B-C04-H.\n", - "14 Sep 2026, 15:10:21 | INFO | Measured response of SJ1D-C04-H.\n", - "14 Sep 2026, 15:10:22 | INFO | Measured response of SJ2E-C04-H.\n", - "14 Sep 2026, 15:10:23 | INFO | Measured response of SJ1E-C04-H.\n", - "14 Sep 2026, 15:10:24 | INFO | Measured response of SH3E-C04-H.\n", - "14 Sep 2026, 15:10:26 | INFO | Measured response of SH1A-C05-H.\n", - "14 Sep 2026, 15:10:27 | INFO | Measured response of SD1A-C05-H.\n", - "14 Sep 2026, 15:10:28 | INFO | Measured response of SF2A-C05-H.\n", - "14 Sep 2026, 15:10:29 | INFO | Measured response of SD1B-C05-H.\n", - "14 Sep 2026, 15:10:31 | INFO | Measured response of SH2B-C05-H.\n", - "14 Sep 2026, 15:10:32 | INFO | Measured response of SD1D-C05-H.\n", - "14 Sep 2026, 15:10:33 | INFO | Measured response of SF2E-C05-H.\n", - "14 Sep 2026, 15:10:34 | INFO | Measured response of SD1E-C05-H.\n", - "14 Sep 2026, 15:10:36 | INFO | Measured response of SH3E-C05-H.\n", - "14 Sep 2026, 15:10:37 | INFO | Measured response of SH1A-C06-H.\n", - "14 Sep 2026, 15:10:38 | INFO | Measured response of SD1A-C06-H.\n", - "14 Sep 2026, 15:10:39 | INFO | Measured response of SF2A-C06-H.\n", - "14 Sep 2026, 15:10:41 | INFO | Measured response of SD1B-C06-H.\n", - "14 Sep 2026, 15:10:42 | INFO | Measured response of SH2B-C06-H.\n", - "14 Sep 2026, 15:10:43 | INFO | Measured response of SD1D-C06-H.\n", - "14 Sep 2026, 15:10:44 | INFO | Measured response of SF2E-C06-H.\n", - "14 Sep 2026, 15:10:45 | INFO | Measured response of SD1E-C06-H.\n", - "14 Sep 2026, 15:10:47 | INFO | Measured response of SH3E-C06-H.\n", - "14 Sep 2026, 15:10:48 | INFO | Measured response of SH1A-C07-H.\n", - "14 Sep 2026, 15:10:49 | INFO | Measured response of SD1A-C07-H.\n", - "14 Sep 2026, 15:10:50 | INFO | Measured response of SF2A-C07-H.\n", - "14 Sep 2026, 15:10:52 | INFO | Measured response of SD1B-C07-H.\n", - "14 Sep 2026, 15:10:53 | INFO | Measured response of SH2B-C07-H.\n", - "14 Sep 2026, 15:10:54 | INFO | Measured response of SD1D-C07-H.\n", - "14 Sep 2026, 15:10:55 | INFO | Measured response of SF2E-C07-H.\n", - "14 Sep 2026, 15:10:56 | INFO | Measured response of SD1E-C07-H.\n", - "14 Sep 2026, 15:10:57 | INFO | Measured response of SH3E-C07-H.\n", - "14 Sep 2026, 15:10:59 | INFO | Measured response of SH1A-C08-H.\n", - "14 Sep 2026, 15:11:00 | INFO | Measured response of SD1A-C08-H.\n", - "14 Sep 2026, 15:11:01 | INFO | Measured response of SF2A-C08-H.\n", - "14 Sep 2026, 15:11:02 | INFO | Measured response of SD1B-C08-H.\n", - "14 Sep 2026, 15:11:04 | INFO | Measured response of SH2B-C08-H.\n", - "14 Sep 2026, 15:11:05 | INFO | Measured response of SD1D-C08-H.\n", - "14 Sep 2026, 15:11:06 | INFO | Measured response of SF2E-C08-H.\n", - "14 Sep 2026, 15:11:07 | INFO | Measured response of SD1E-C08-H.\n", - "14 Sep 2026, 15:11:08 | INFO | Measured response of SH3E-C08-H.\n", - "14 Sep 2026, 15:11:10 | INFO | Measured response of SH1A-C09-H.\n", - "14 Sep 2026, 15:11:11 | INFO | Measured response of SD1A-C09-H.\n", - "14 Sep 2026, 15:11:12 | INFO | Measured response of SF2A-C09-H.\n", - "14 Sep 2026, 15:11:13 | INFO | Measured response of SD1B-C09-H.\n", - "14 Sep 2026, 15:11:14 | INFO | Measured response of SH2B-C09-H.\n", - "14 Sep 2026, 15:11:16 | INFO | Measured response of SD1D-C09-H.\n", - "14 Sep 2026, 15:11:17 | INFO | Measured response of SF2E-C09-H.\n", - "14 Sep 2026, 15:11:18 | INFO | Measured response of SD1E-C09-H.\n", - "14 Sep 2026, 15:11:19 | INFO | Measured response of SH3E-C09-H.\n", - "14 Sep 2026, 15:11:21 | INFO | Measured response of SH1A-C10-H.\n", - "14 Sep 2026, 15:11:22 | INFO | Measured response of SD1A-C10-H.\n", - "14 Sep 2026, 15:11:23 | INFO | Measured response of SF2A-C10-H.\n", - "14 Sep 2026, 15:11:24 | INFO | Measured response of SD1B-C10-H.\n", - "14 Sep 2026, 15:11:26 | INFO | Measured response of SH2B-C10-H.\n", - "14 Sep 2026, 15:11:27 | INFO | Measured response of SD1D-C10-H.\n", - "14 Sep 2026, 15:11:28 | INFO | Measured response of SF2E-C10-H.\n", - "14 Sep 2026, 15:11:29 | INFO | Measured response of SD1E-C10-H.\n", - "14 Sep 2026, 15:11:31 | INFO | Measured response of SH3E-C10-H.\n", - "14 Sep 2026, 15:11:32 | INFO | Measured response of SH1A-C11-H.\n", - "14 Sep 2026, 15:11:33 | INFO | Measured response of SD1A-C11-H.\n", - "14 Sep 2026, 15:11:34 | INFO | Measured response of SF2A-C11-H.\n", - "14 Sep 2026, 15:11:35 | INFO | Measured response of SD1B-C11-H.\n", - "14 Sep 2026, 15:11:37 | INFO | Measured response of SH2B-C11-H.\n", - "14 Sep 2026, 15:11:38 | INFO | Measured response of SD1D-C11-H.\n", - "14 Sep 2026, 15:11:39 | INFO | Measured response of SF2E-C11-H.\n", - "14 Sep 2026, 15:11:40 | INFO | Measured response of SD1E-C11-H.\n", - "14 Sep 2026, 15:11:41 | INFO | Measured response of SH3E-C11-H.\n", - "14 Sep 2026, 15:11:43 | INFO | Measured response of SH1A-C12-H.\n", - "14 Sep 2026, 15:11:44 | INFO | Measured response of SD1A-C12-H.\n", - "14 Sep 2026, 15:11:45 | INFO | Measured response of SF2A-C12-H.\n", - "14 Sep 2026, 15:11:46 | INFO | Measured response of SD1B-C12-H.\n", - "14 Sep 2026, 15:11:47 | INFO | Measured response of SH2B-C12-H.\n", - "14 Sep 2026, 15:11:49 | INFO | Measured response of SD1D-C12-H.\n", - "14 Sep 2026, 15:11:50 | INFO | Measured response of SF2E-C12-H.\n", - "14 Sep 2026, 15:11:51 | INFO | Measured response of SD1E-C12-H.\n", - "14 Sep 2026, 15:11:52 | INFO | Measured response of SH3E-C12-H.\n", - "14 Sep 2026, 15:11:54 | INFO | Measured response of SH1A-C13-H.\n", - "14 Sep 2026, 15:11:55 | INFO | Measured response of SD1A-C13-H.\n", - "14 Sep 2026, 15:11:56 | INFO | Measured response of SF2A-C13-H.\n" - ] - } - ], - "source": [ - "SR.orm.measure(sleep_between_step=wait_time)\n", - "SR.orm.save(CONFIG_DIR / \"orm.json\")\n", - "SR.orm.save(CONFIG_DIR / \"orm.yaml\", with_type=\"yaml\")\n", - "SR.orm.save(CONFIG_DIR / \"orm.npz\", with_type=\"npz\")\n", - "\n", - "SR.orbit.load(CONFIG_DIR / \"orm.json\")\n", - "print(\"ORM measured, saved and loaded.\")" - ] + "outputs": [], + "source": "SR.tool.orm.measure(sleep_between_step=wait_time)\nSR.tool.orm.save(CONFIG_DIR / \"orm.json\")\nSR.tool.orm.save(CONFIG_DIR / \"orm.yaml\", with_type=\"yaml\")\nSR.tool.orm.save(CONFIG_DIR / \"orm.npz\", with_type=\"npz\")\n\nSR.tool.orbit.load(CONFIG_DIR / \"orm.json\")\nprint(\"ORM measured, saved and loaded.\")" }, { "cell_type": "markdown", @@ -344,15 +227,7 @@ "id": "942f8f3b", "metadata": {}, "outputs": [], - "source": [ - "orm_data = SR.orm.get()\n", - "plt.imshow(np.array(orm_data[\"matrix\"]))\n", - "plt.colorbar()\n", - "plt.title(\"Orbit response matrix\")\n", - "plt.xlabel(\"Corrector index\")\n", - "plt.ylabel(\"BPM index\")\n", - "plt.show()" - ] + "source": "orm_data = SR.tool.orm.get()\nplt.imshow(np.array(orm_data[\"matrix\"]))\nplt.colorbar()\nplt.title(\"Orbit response matrix\")\nplt.xlabel(\"Corrector index\")\nplt.ylabel(\"BPM index\")\nplt.show()" }, { "cell_type": "markdown", @@ -370,28 +245,7 @@ "id": "693fc409", "metadata": {}, "outputs": [], - "source": [ - "# Uncomment to measure and visualise dispersion\n", - "\n", - "# def disp_callback(action: int, cb_data) -> bool:\n", - "# from pyaml.common.constants import Action\n", - "# if action == Action.APPLY:\n", - "# print(\"Changing RF frequency\")\n", - "# elif action == Action.MEASURE:\n", - "# print(\"Reading orbit\")\n", - "# elif action == Action.RESTORE:\n", - "# print(\"Restoring RF frequency\")\n", - "# return True\n", - "\n", - "# SR.dispersion.measure(callback=disp_callback)\n", - "# disp_data = SR.dispersion.get()\n", - "# plt.plot(disp_data[\"frequency_response_x\"], label=\"H dispersion\")\n", - "# plt.plot(disp_data[\"frequency_response_y\"], label=\"V dispersion\")\n", - "# plt.xlabel(\"BPM index\")\n", - "# plt.ylabel(\"Orbit / Δf [m/Hz]\")\n", - "# plt.legend()\n", - "# plt.show()" - ] + "source": "# Uncomment to measure and visualise dispersion\n\n# def disp_callback(action: int, cb_data) -> bool:\n# from pyaml.common.constants import Action\n# if action == Action.APPLY:\n# print(\"Changing RF frequency\")\n# elif action == Action.MEASURE:\n# print(\"Reading orbit\")\n# elif action == Action.RESTORE:\n# print(\"Restoring RF frequency\")\n# return True\n\n# SR.tool.dispersion.measure(callback=disp_callback)\n# disp_data = SR.tool.dispersion.get()\n# plt.plot(disp_data[\"frequency_response_x\"], label=\"H dispersion\")\n# plt.plot(disp_data[\"frequency_response_y\"], label=\"V dispersion\")\n# plt.xlabel(\"BPM index\")\n# plt.ylabel(\"Orbit / Δf [m/Hz]\")\n# plt.legend()\n# plt.show()" }, { "cell_type": "markdown", @@ -464,16 +318,7 @@ "cell_type": "markdown", "id": "cf49c543", "metadata": {}, - "source": [ - "### Correct the orbit\n", - "\n", - "Standard correction: `SR.orbit.correct(reference=reference)`.\n", - "\n", - "Optional variants (uncomment to use):\n", - "- **Virtual corrector weight**: down-weights correctors that are already at large strengths.\n", - "- **RF correction**: also adjusts the RF frequency to minimise dispersion-driven orbit.\n", - "- **Live unit mismatch**: if BESSY2 BPMs read in nm, pass `gain=1e-9`." - ] + "source": "### Correct the orbit\n\nStandard correction: `SR.tool.orbit.correct(reference=reference)`.\n\nOptional variants (uncomment to use):\n- **Virtual corrector weight**: down-weights correctors that are already at large strengths.\n- **RF correction**: also adjusts the RF frequency to minimise dispersion-driven orbit.\n- **Live unit mismatch**: if BESSY2 BPMs read in nm, pass `gain=1e-9`." }, { "cell_type": "code", @@ -481,22 +326,7 @@ "id": "93135a4c", "metadata": {}, "outputs": [], - "source": [ - "# Standard correction\n", - "SR.orbit.correct(reference=reference)\n", - "\n", - "# With virtual corrector weight (ESRF style):\n", - "# SR.orbit.set_virtual_weight(1000)\n", - "# SR.orbit.correct(reference=reference)\n", - "\n", - "# With RF orbit correction (ESRF style, requires dispersion in ORM):\n", - "# SR.orbit.correct(reference=reference, rf=True)\n", - "\n", - "# BESSY2 live mode — BPMs in nm, use gain to compensate unit mismatch:\n", - "# SR.orbit.correct(reference=reference, gain=1e-9)\n", - "\n", - "sleep(wait_time)" - ] + "source": "# Standard correction\nSR.tool.orbit.correct(reference=reference)\n\n# With virtual corrector weight (ESRF style):\n# SR.tool.orbit.set_virtual_weight(1000)\n# SR.tool.orbit.correct(reference=reference)\n\n# With RF orbit correction (ESRF style, requires dispersion in ORM):\n# SR.tool.orbit.correct(reference=reference, rf=True)\n\n# BESSY2 live mode — BPMs in nm, use gain to compensate unit mismatch:\n# SR.tool.orbit.correct(reference=reference, gain=1e-9)\n\nsleep(wait_time)" }, { "cell_type": "code", diff --git a/examples/use_cases/03-orbit_correction.py b/examples/use_cases/03-orbit_correction.py index b7af039c..7271f26f 100644 --- a/examples/use_cases/03-orbit_correction.py +++ b/examples/use_cases/03-orbit_correction.py @@ -92,23 +92,23 @@ # ### Orbit response matrix # -# The ORM can be saved in multiple formats. Load it into `SR.orbit` before correcting. +# The ORM can be saved in multiple formats. Load it into `SR.tool.orbit` before correcting. # In[5]: -print(SR.orm) # string representation +print(SR.tool.orm) # string representation # In[6]: -SR.orm.measure(sleep_between_step=wait_time) -SR.orm.save(CONFIG_DIR / "orm.json") -SR.orm.save(CONFIG_DIR / "orm.yaml", with_type="yaml") -SR.orm.save(CONFIG_DIR / "orm.npz", with_type="npz") +SR.tool.orm.measure(sleep_between_step=wait_time) +SR.tool.orm.save(CONFIG_DIR / "orm.json") +SR.tool.orm.save(CONFIG_DIR / "orm.yaml", with_type="yaml") +SR.tool.orm.save(CONFIG_DIR / "orm.npz", with_type="npz") -SR.orbit.load(CONFIG_DIR / "orm.json") +SR.tool.orbit.load(CONFIG_DIR / "orm.json") print("ORM measured, saved and loaded.") @@ -117,7 +117,7 @@ # In[7]: -orm_data = SR.orm.get() +orm_data = SR.tool.orm.get() plt.imshow(np.array(orm_data["matrix"])) plt.colorbar() plt.title("Orbit response matrix") @@ -147,8 +147,8 @@ # print("Restoring RF frequency") # return True -# SR.dispersion.measure(callback=disp_callback) -# disp_data = SR.dispersion.get() +# SR.tool.dispersion.measure(callback=disp_callback) +# disp_data = SR.tool.dispersion.get() # plt.plot(disp_data["frequency_response_x"], label="H dispersion") # plt.plot(disp_data["frequency_response_y"], label="V dispersion") # plt.xlabel("BPM index") @@ -202,7 +202,7 @@ # ### Correct the orbit # -# Standard correction: `SR.orbit.correct(reference=reference)`. +# Standard correction: `SR.tool.orbit.correct(reference=reference)`. # # Optional variants (uncomment to use): # - **Virtual corrector weight**: down-weights correctors that are already at large strengths. @@ -213,17 +213,17 @@ # Standard correction -SR.orbit.correct(reference=reference) +SR.tool.orbit.correct(reference=reference) # With virtual corrector weight (ESRF style): -# SR.orbit.set_virtual_weight(1000) -# SR.orbit.correct(reference=reference) +# SR.tool.orbit.set_virtual_weight(1000) +# SR.tool.orbit.correct(reference=reference) # With RF orbit correction (ESRF style, requires dispersion in ORM): -# SR.orbit.correct(reference=reference, rf=True) +# SR.tool.orbit.correct(reference=reference, rf=True) # BESSY2 live mode — BPMs in nm, use gain to compensate unit mismatch: -# SR.orbit.correct(reference=reference, gain=1e-9) +# SR.tool.orbit.correct(reference=reference, gain=1e-9) sleep(wait_time) diff --git a/examples/use_cases/README.md b/examples/use_cases/README.md index ebcfe8c9..6bc3076e 100644 --- a/examples/use_cases/README.md +++ b/examples/use_cases/README.md @@ -89,8 +89,8 @@ In `design` mode all wait times can be set to `0.0`. In `live` mode use `wait_ti | `BPM` | Beam position monitors | | `BETATRON_TUNE` | Betatron tune monitor | | `CHROMATICITY_MONITOR` | Chromaticity monitor | -| `DEFAULT_TUNE_CORRECTION` | Tune correction tool → `SR.tune` | -| `DEFAULT_TUNE_RESPONSE_MATRIX` | Tune response matrix tool → `SR.trm` | -| `DEFAULT_ORBIT_CORRECTION` | Orbit correction tool → `SR.orbit` | -| `DEFAULT_ORBIT_RESPONSE_MATRIX` | Orbit response matrix tool → `SR.orm` | -| `DEFAULT_DISPERSION` | Dispersion measurement tool → `SR.dispersion` | +| `DEFAULT_TUNE_CORRECTION` | Tune correction tool → `SR.tool.tune` | +| `DEFAULT_TUNE_RESPONSE_MATRIX` | Tune response matrix tool → `SR.tool.trm` | +| `DEFAULT_ORBIT_CORRECTION` | Orbit correction tool → `SR.tool.orbit` | +| `DEFAULT_ORBIT_RESPONSE_MATRIX` | Orbit response matrix tool → `SR.tool.orm` | +| `DEFAULT_DISPERSION` | Dispersion measurement tool → `SR.tool.dispersion` | diff --git a/pyaml/common/holders/element_holder.py b/pyaml/common/holders/element_holder.py index 5eed50c3..21d303ac 100644 --- a/pyaml/common/holders/element_holder.py +++ b/pyaml/common/holders/element_holder.py @@ -66,11 +66,6 @@ class ElementHolder(metaclass=ABCMeta): Diagnostics of this mode, with typed default-name access. tool Tuning and measurement tools of this mode, with typed default-name access. - tune, chromaticity, orbit, dispersion - Backward-compatible aliases for ``tool.tune``, ``tool.chromaticity``, ``tool.orbit`` - and ``tool.dispersion``. - trm, crm, orm - Backward-compatible aliases for ``tool.trm``, ``tool.crm`` and ``tool.orm``. Methods ------- @@ -695,16 +690,6 @@ def get_crm_tuning(self, name: str) -> "ChromaticityResponseMatrix": """ return self._get("ChromaticityResponseMatrix tool", name, self._TOOLS) - @property - def chromaticity(self) -> "Chromaticity": - """Return the chromaticity. Alias for ``tool.chromaticity``.""" - return self.tool.chromaticity - - @property - def crm(self) -> "ChromaticityResponseMatrix": - """Return the crm. Alias for ``tool.crm``.""" - return self.tool.crm - # ---- Tune --------------------------------------------------------- def get_tune_tuning(self, name: str) -> "Tune": @@ -723,11 +708,6 @@ def get_tune_tuning(self, name: str) -> "Tune": """ return self._get("Tune tuning tool", name, self._TOOLS) - @property - def tune(self) -> "Tune": - """Return the tune. Alias for ``tool.tune``.""" - return self.tool.tune - def get_trm_tuning(self, name: str) -> "TuneResponseMatrix": """ Return a named tune response-matrix tool. @@ -744,11 +724,6 @@ def get_trm_tuning(self, name: str) -> "TuneResponseMatrix": """ return self._get("TuneResponseMatrix tool", name, self._TOOLS) - @property - def trm(self) -> "TuneResponseMatrix": - """Return the default tune response-matrix tool. Alias for ``tool.trm``.""" - return self.tool.trm - # ---- Orbit -------------------------------------------------------- def get_orbit_tuning(self, name: str) -> "Orbit": @@ -767,11 +742,6 @@ def get_orbit_tuning(self, name: str) -> "Orbit": """ return self._get("Orbit tuning tool", name, self._TOOLS) - @property - def orbit(self) -> "Orbit": - """Return the orbit. Alias for ``tool.orbit``.""" - return self.tool.orbit - def get_orm_tuning(self, name: str) -> "OrbitResponseMatrix": """ Return a named orbit response-matrix tool. @@ -788,11 +758,6 @@ def get_orm_tuning(self, name: str) -> "OrbitResponseMatrix": """ return self._get("OrbitResponseMatrix tool", name, self._TOOLS) - @property - def orm(self) -> "OrbitResponseMatrix": - """Return the default orbit response-matrix tool. Alias for ``tool.orm``.""" - return self.tool.orm - # ---- BBA -------------------------------------------------------- def get_bba(self, name: str) -> "BBA": @@ -829,11 +794,6 @@ def get_dispersion_tuning(self, name: str) -> "Dispersion": """ return self._get("Dispersion tool", name, self._TOOLS) - @property - def dispersion(self) -> "Dispersion": - """Return the dispersion. Alias for ``tool.dispersion``.""" - return self.tool.dispersion - def _get_array(self, name: str): """ Generic array resolver used by YellowPages. diff --git a/pyaml/common/holders/tool_holder.py b/pyaml/common/holders/tool_holder.py index 2ac49e86..9f861959 100644 --- a/pyaml/common/holders/tool_holder.py +++ b/pyaml/common/holders/tool_holder.py @@ -40,12 +40,6 @@ class ToolHolder: get(name=None) Return a named tool, or all configured tools when no name is given. - Notes - ----- - :attr:`ElementHolder.tune `, - ``.trm``, ``.orbit``, ``.orm``, ``.chromaticity``, ``.crm`` and ``.dispersion`` are - backward-compatible aliases for the corresponding properties here. - Examples -------- >>> tune_correction = sr.live.tool.tune @@ -137,7 +131,7 @@ def chromaticity(self) -> "Chromaticity": from ...tuning_tools.chromaticity import Chromaticity name = "DEFAULT_CHROMATICITY_CORRECTION" - return self._validate_type(name, self._peer.get_chromaticity_tuning(name), Chromaticity) + return self._validate_type(name, self.get(name), Chromaticity) @property def crm(self) -> "ChromaticityResponseMatrix": @@ -145,7 +139,7 @@ def crm(self) -> "ChromaticityResponseMatrix": from ...tuning_tools.chromaticity_response_matrix import ChromaticityResponseMatrix name = "DEFAULT_CHROMATICITY_RESPONSE_MATRIX" - return self._validate_type(name, self._peer.get_crm_tuning(name), ChromaticityResponseMatrix) + return self._validate_type(name, self.get(name), ChromaticityResponseMatrix) @property def tune(self) -> "Tune": @@ -153,7 +147,7 @@ def tune(self) -> "Tune": from ...tuning_tools.tune import Tune name = "DEFAULT_TUNE_CORRECTION" - return self._validate_type(name, self._peer.get_tune_tuning(name), Tune) + return self._validate_type(name, self.get(name), Tune) @property def trm(self) -> "TuneResponseMatrix": @@ -161,7 +155,7 @@ def trm(self) -> "TuneResponseMatrix": from ...tuning_tools.tune_response_matrix import TuneResponseMatrix name = "DEFAULT_TUNE_RESPONSE_MATRIX" - return self._validate_type(name, self._peer.get_trm_tuning(name), TuneResponseMatrix) + return self._validate_type(name, self.get(name), TuneResponseMatrix) @property def orbit(self) -> "Orbit": @@ -169,7 +163,7 @@ def orbit(self) -> "Orbit": from ...tuning_tools.orbit import Orbit name = "DEFAULT_ORBIT_CORRECTION" - return self._validate_type(name, self._peer.get_orbit_tuning(name), Orbit) + return self._validate_type(name, self.get(name), Orbit) @property def orm(self) -> "OrbitResponseMatrix": @@ -177,7 +171,7 @@ def orm(self) -> "OrbitResponseMatrix": from ...tuning_tools.orbit_response_matrix import OrbitResponseMatrix name = "DEFAULT_ORBIT_RESPONSE_MATRIX" - return self._validate_type(name, self._peer.get_orm_tuning(name), OrbitResponseMatrix) + return self._validate_type(name, self.get(name), OrbitResponseMatrix) @property def dispersion(self) -> "Dispersion": @@ -185,7 +179,7 @@ def dispersion(self) -> "Dispersion": from ...tuning_tools.dispersion import Dispersion name = "DEFAULT_DISPERSION" - return self._validate_type(name, self._peer.get_dispersion_tuning(name), Dispersion) + return self._validate_type(name, self.get(name), Dispersion) def __repr__(self): return __pyaml_repr__(self) diff --git a/pyaml/tuning_tools/chromaticity_response_matrix.py b/pyaml/tuning_tools/chromaticity_response_matrix.py index c75ec53c..4d739e0e 100644 --- a/pyaml/tuning_tools/chromaticity_response_matrix.py +++ b/pyaml/tuning_tools/chromaticity_response_matrix.py @@ -151,10 +151,10 @@ def callback(action: Action, data:dict): sr = Accelerator.load("tests/config/EBSOrbit.yaml") acc = sr.design - if acc.crm.measure(callback=callback): - acc.crm.save("ideal_crm.json") - acc.crm.save("ideal_crm.yaml", with_type="yaml") - acc.crm.save("ideal_crm.npz", with_type="npz") + if acc.tool.crm.measure(callback=callback): + acc.tool.crm.save("ideal_crm.json") + acc.tool.crm.save("ideal_crm.yaml", with_type="yaml") + acc.tool.crm.save("ideal_crm.npz", with_type="npz") Parameters ---------- diff --git a/pyaml/tuning_tools/measurement_tool.py b/pyaml/tuning_tools/measurement_tool.py index 646d38ed..acdc5789 100644 --- a/pyaml/tuning_tools/measurement_tool.py +++ b/pyaml/tuning_tools/measurement_tool.py @@ -182,7 +182,7 @@ def callback(action: Action, data: dict): return True # Measure a tune response matrix using the above callback - sr.design.trm.measure(callback=callback) + sr.design.tool.trm.measure(callback=callback) Parameters ---------- diff --git a/pyaml/tuning_tools/orbit_response_matrix.py b/pyaml/tuning_tools/orbit_response_matrix.py index 101a7220..14bd96d2 100644 --- a/pyaml/tuning_tools/orbit_response_matrix.py +++ b/pyaml/tuning_tools/orbit_response_matrix.py @@ -173,10 +173,10 @@ def measure( sr = Accelerator.load("MyAccelerator.yaml") acc = sr.design - if acc.orm.measure(): - acc.orm.save("ideal_orm.json") - acc.orm.save("ideal_orm.yaml", with_type="yaml") - acc.orm.save("ideal_orm.npz", with_type="npz") + if acc.tool.orm.measure(): + acc.tool.orm.save("ideal_orm.json") + acc.tool.orm.save("ideal_orm.yaml", with_type="yaml") + acc.tool.orm.save("ideal_orm.npz", with_type="npz") Parameters ---------- diff --git a/pyaml/tuning_tools/tune_response_matrix.py b/pyaml/tuning_tools/tune_response_matrix.py index 0af72d6e..380a4105 100644 --- a/pyaml/tuning_tools/tune_response_matrix.py +++ b/pyaml/tuning_tools/tune_response_matrix.py @@ -190,10 +190,10 @@ def callback(action: Action, data:dict): sr = Accelerator.load("tests/config/EBSTune.yaml") acc = sr.design - if acc.trm.measure(n_avg_meas=3,sleep_between_meas=5,callback=callback): - acc.trm.save("ideal_trm.json") - acc.trm.save("ideal_trm.yaml", with_type="yaml") - acc.trm.save("ideal_trm.npz", with_type="npz") + if acc.tool.trm.measure(n_avg_meas=3,sleep_between_meas=5,callback=callback): + acc.tool.trm.save("ideal_trm.json") + acc.tool.trm.save("ideal_trm.yaml", with_type="yaml") + acc.tool.trm.save("ideal_trm.npz", with_type="npz") Parameters ---------- diff --git a/tests/diagnostics/test_diagnostic_accessors.py b/tests/diagnostics/test_diagnostic_accessors.py index 2acdb9c3..b4c6f58b 100644 --- a/tests/diagnostics/test_diagnostic_accessors.py +++ b/tests/diagnostics/test_diagnostic_accessors.py @@ -54,7 +54,7 @@ def test_diagnostic_raises_when_default_wrong_type(): ).design # Swap the registered default so it points to an object of the wrong type. - design._DIAG["BETATRON_TUNE"] = design.orbit + design._DIAG["BETATRON_TUNE"] = design.tool.orbit with pytest.raises(PyAMLException) as exc: _ = design.diagnostic.betatron_tune diff --git a/tests/tuning_tools/test_tool_accessors.py b/tests/tuning_tools/test_tool_accessors.py index d9a54e7b..a5dd2500 100644 --- a/tests/tuning_tools/test_tool_accessors.py +++ b/tests/tuning_tools/test_tool_accessors.py @@ -15,36 +15,36 @@ def test_tuning_tools_expose_configured_elements(): tune_monitor = design.get_betatron_tune_monitor("BETATRON_TUNE") quadrupoles = design.magnets.get("QForTune") - assert design.tune.tune_monitor is tune_monitor - assert design.tune.quadrupoles is quadrupoles - assert design.trm.tune_monitor is tune_monitor - assert design.trm.quadrupoles is quadrupoles + assert design.tool.tune.tune_monitor is tune_monitor + assert design.tool.tune.quadrupoles is quadrupoles + assert design.tool.trm.tune_monitor is tune_monitor + assert design.tool.trm.quadrupoles is quadrupoles chromaticity_monitor = design.get_chromaticity_monitor("CHROMATICITY_MONITOR") sextupoles = design.magnets.get("Sext") - assert design.chromaticity.chromaticity_monitor is chromaticity_monitor - assert design.chromaticity.sextupoles is sextupoles - assert design.crm.chromaticity_monitor is chromaticity_monitor - assert design.crm.sextupoles is sextupoles + assert design.tool.chromaticity.chromaticity_monitor is chromaticity_monitor + assert design.tool.chromaticity.sextupoles is sextupoles + assert design.tool.crm.chromaticity_monitor is chromaticity_monitor + assert design.tool.crm.sextupoles is sextupoles bpms = design.diagnostic.bpms.get("BPM") rf_plant = design.rf.get("DEFAULT_RF_PLANT") assert chromaticity_monitor.tune_monitor is tune_monitor assert chromaticity_monitor.bpms is bpms assert chromaticity_monitor.rf_plant is rf_plant - assert design.dispersion.bpms is bpms - assert design.dispersion.rf_plant is rf_plant + assert design.tool.dispersion.bpms is bpms + assert design.tool.dispersion.rf_plant is rf_plant hcorrectors = design.magnets.get("HCorr") vcorrectors = design.magnets.get("VCorr") - assert design.orbit.bpms is bpms - assert design.orbit.hcorrectors is hcorrectors - assert design.orbit.vcorrectors is vcorrectors - assert design.orbit.correctors.names() == hcorrectors.names() + vcorrectors.names() - assert design.orbit.rf_plant is rf_plant - assert design.orm.bpms is bpms - assert design.orm.hcorrectors is hcorrectors - assert design.orm.vcorrectors is vcorrectors + assert design.tool.orbit.bpms is bpms + assert design.tool.orbit.hcorrectors is hcorrectors + assert design.tool.orbit.vcorrectors is vcorrectors + assert design.tool.orbit.correctors.names() == hcorrectors.names() + vcorrectors.names() + assert design.tool.orbit.rf_plant is rf_plant + assert design.tool.orm.bpms is bpms + assert design.tool.orm.hcorrectors is hcorrectors + assert design.tool.orm.vcorrectors is vcorrectors for name in ("BBA-BPM_C04-04", "BBA2-BPM_C04-04"): bba = design.get_bba(name) @@ -54,7 +54,7 @@ def test_tuning_tools_expose_configured_elements(): assert bba.vcorrector is design.magnet.get("SD1A-C26-V") assert bba.quadrupole is design.magnet.get("QF6B-C04") - assert design.get_bba("BBA2-BPM_C04-04").tune_correction is design.tune + assert design.get_bba("BBA2-BPM_C04-04").tune_correction is design.tool.tune def test_tool_get_returns_named_tool(): @@ -64,8 +64,8 @@ def test_tool_get_returns_named_tool(): include_locations=False, ).design - assert design.tool.get("DEFAULT_TUNE_CORRECTION") is design.tune - assert design.tool.get("DEFAULT_ORBIT_RESPONSE_MATRIX") is design.orm + assert design.tool.get("DEFAULT_TUNE_CORRECTION") is design.tool.tune + assert design.tool.get("DEFAULT_ORBIT_RESPONSE_MATRIX") is design.tool.orm def test_tool_get_with_no_name_returns_all_configured_tools(): @@ -76,29 +76,13 @@ def test_tool_get_with_no_name_returns_all_configured_tools(): ).design all_tools = design.tool.get() - assert design.tune in all_tools - assert design.trm in all_tools - assert design.orbit in all_tools - assert design.orm in all_tools - assert design.chromaticity in all_tools - assert design.crm in all_tools - assert design.dispersion in all_tools - - -def test_tool_typed_properties_alias_existing_defaults(): - design = Accelerator.load( - "tests/config/EBSOrbit.yaml", - ignore_external=True, - include_locations=False, - ).design - - assert design.tool.tune is design.tune - assert design.tool.trm is design.trm - assert design.tool.orbit is design.orbit - assert design.tool.orm is design.orm - assert design.tool.chromaticity is design.chromaticity - assert design.tool.crm is design.crm - assert design.tool.dispersion is design.dispersion + assert design.tool.tune in all_tools + assert design.tool.trm in all_tools + assert design.tool.orbit in all_tools + assert design.tool.orm in all_tools + assert design.tool.chromaticity in all_tools + assert design.tool.crm in all_tools + assert design.tool.dispersion in all_tools def test_tool_raises_when_default_missing(ebs_lattice_file): @@ -117,7 +101,7 @@ def test_tool_raises_when_default_wrong_type(): ).design # Swap the registered default so it points to an object of the wrong type. - design._TOOLS["DEFAULT_TUNE_CORRECTION"] = design.orbit + design._TOOLS["DEFAULT_TUNE_CORRECTION"] = design.tool.orbit with pytest.raises(PyAMLException) as exc: _ = design.tool.tune diff --git a/tests/tuning_tools/test_tuning_dispersion.py b/tests/tuning_tools/test_tuning_dispersion.py index 9cd3e66b..a2abcc43 100644 --- a/tests/tuning_tools/test_tuning_dispersion.py +++ b/tests/tuning_tools/test_tuning_dispersion.py @@ -12,7 +12,7 @@ def test_tuning_orm(): sr = Accelerator.load(config_path) element_holder = sr.design - dispersion = element_holder.dispersion + dispersion = element_holder.tool.dispersion dispersion.measure() dispersion_data = dispersion.get() diff --git a/tests/tuning_tools/test_tuning_orbit_correction.py b/tests/tuning_tools/test_tuning_orbit_correction.py index 7cf8fb56..930d59e9 100644 --- a/tests/tuning_tools/test_tuning_orbit_correction.py +++ b/tests/tuning_tools/test_tuning_orbit_correction.py @@ -27,7 +27,7 @@ def test_tuning_orbit_correction(): x, y = bpms.positions.get().T # get reference orbit reference = np.concat((x, y)) # there should be nothing to correct, but still work - element_holder.orbit.correct(reference=reference) + element_holder.tool.orbit.correct(reference=reference) h_strengths = hcorr.strengths.get() + std_kick * np.random.normal(size=len(hcorr)) v_strengths = vcorr.strengths.get() + std_kick * np.random.normal(size=len(vcorr)) @@ -43,7 +43,7 @@ def test_tuning_orbit_correction(): assert np.isclose(std_bc[0], original_H, rtol=0, atol=1e-14) assert np.isclose(std_bc[1], original_V, rtol=0, atol=1e-14) - element_holder.orbit.correct(reference=None) + element_holder.tool.orbit.correct(reference=None) positions_ac = bpms.positions.get() std_ac = np.std(positions_ac, axis=0) @@ -53,7 +53,7 @@ def test_tuning_orbit_correction(): # mangle orbit again, test gain_h/gain_v hcorr.strengths.set(h_strengths) vcorr.strengths.set(v_strengths) - element_holder.orbit.correct(gain_h=0.5, gain_v=0.1) + element_holder.tool.orbit.correct(gain_h=0.5, gain_v=0.1) positions_ac = bpms.positions.get() std_ac = np.std(positions_ac, axis=0) @@ -63,7 +63,7 @@ def test_tuning_orbit_correction(): # mangle orbit again, test gain/gain_v hcorr.strengths.set(h_strengths) vcorr.strengths.set(v_strengths) - element_holder.orbit.correct(gain=1, gain_v=0.1) + element_holder.tool.orbit.correct(gain=1, gain_v=0.1) positions_ac = bpms.positions.get() std_ac = np.std(positions_ac, axis=0) @@ -73,7 +73,7 @@ def test_tuning_orbit_correction(): # mangle orbit again, test singular_values_h hcorr.strengths.set(h_strengths) vcorr.strengths.set(v_strengths) - element_holder.orbit.correct(singular_values_h=100) + element_holder.tool.orbit.correct(singular_values_h=100) positions_ac = bpms.positions.get() std_ac = np.std(positions_ac, axis=0) @@ -83,7 +83,7 @@ def test_tuning_orbit_correction(): # mangle orbit again, test singular_values_v hcorr.strengths.set(h_strengths) vcorr.strengths.set(v_strengths) - element_holder.orbit.correct(singular_values_v=50) + element_holder.tool.orbit.correct(singular_values_v=50) positions_ac = bpms.positions.get() std_ac = np.std(positions_ac, axis=0) @@ -93,7 +93,7 @@ def test_tuning_orbit_correction(): # mangle orbit again, test plane=H hcorr.strengths.set(h_strengths) vcorr.strengths.set(v_strengths) - element_holder.orbit.correct(plane="H") + element_holder.tool.orbit.correct(plane="H") positions_ac = bpms.positions.get() std_ac = np.std(positions_ac, axis=0) @@ -104,7 +104,7 @@ def test_tuning_orbit_correction(): # mangle orbit again, test plane=V hcorr.strengths.set(h_strengths) vcorr.strengths.set(v_strengths) - element_holder.orbit.correct(plane="V") + element_holder.tool.orbit.correct(plane="V") positions_ac = bpms.positions.get() std_ac = np.std(positions_ac, axis=0) @@ -116,65 +116,65 @@ def test_tuning_orbit_correction(): hcorr.strengths.set(h_strengths) vcorr.strengths.set(v_strengths) - element_holder.orbit.set_weight("SJ2A-C04-H", 2) - element_holder.orbit.correct() + element_holder.tool.orbit.set_weight("SJ2A-C04-H", 2) + element_holder.tool.orbit.correct() positions_ac = bpms.positions.get() std_ac = np.std(positions_ac, axis=0) assert np.isclose(std_ac[0], 5.057265926153962e-07, rtol=0, atol=1e-14) assert np.isclose(std_ac[1], 4.78927471675123e-07, rtol=0, atol=1e-14) - element_holder.orbit.set_weight("SJ2A-C04-H", 1) + element_holder.tool.orbit.set_weight("SJ2A-C04-H", 1) # mangle orbit again, test bpm weight hcorr.strengths.set(h_strengths) vcorr.strengths.set(v_strengths) - element_holder.orbit.set_weight("BPM_C04-05", 2) - element_holder.orbit.correct() + element_holder.tool.orbit.set_weight("BPM_C04-05", 2) + element_holder.tool.orbit.correct() positions_ac = bpms.positions.get() std_ac = np.std(positions_ac, axis=0) assert np.isclose(std_ac[0], 5.056719006414065e-07, rtol=0, atol=1e-14) assert np.isclose(std_ac[1], 4.790610352466602e-07, rtol=0, atol=1e-14) - element_holder.orbit.set_weight("BPM_C04-05", 1) + element_holder.tool.orbit.set_weight("BPM_C04-05", 1) # mangle orbit again, test virtual weight hcorr.strengths.set(h_strengths) vcorr.strengths.set(v_strengths) - element_holder.orbit.set_virtual_weight(2) - element_holder.orbit.correct() + element_holder.tool.orbit.set_virtual_weight(2) + element_holder.tool.orbit.correct() positions_ac = bpms.positions.get() std_ac = np.std(positions_ac, axis=0) assert np.isclose(std_ac[0], 5.05398857685373e-07, rtol=0, atol=1e-14) assert np.isclose(std_ac[1], 4.789270969888965e-07, rtol=0, atol=1e-14) - element_holder.orbit.set_virtual_weight(1000) + element_holder.tool.orbit.set_virtual_weight(1000) # mangle orbit again, test virtual target hcorr.strengths.set(h_strengths) vcorr.strengths.set(v_strengths) virtual_target = 1e-8 - element_holder.orbit.correct(virtual_target=virtual_target) + element_holder.tool.orbit.correct(virtual_target=virtual_target) delta_h_strengths = hcorr.strengths.get() - h_strengths delta_h_strengths_sum = -np.sum(delta_h_strengths) assert np.isclose(delta_h_strengths_sum - virtual_target, 0, rtol=0, atol=1e-13) - element_holder.orbit.set_virtual_weight(1) + element_holder.tool.orbit.set_virtual_weight(1) # mangle orbit again, test reference hcorr.strengths.set(h_strengths) vcorr.strengths.set(v_strengths) reference = np.concatenate((positions_bc[:, 0], positions_bc[:, 1])) - element_holder.orbit.correct(reference=reference) + element_holder.tool.orbit.correct(reference=reference) positions_ac = bpms.positions.get() std_ac = np.std(positions_ac, axis=0) assert np.isclose(std_ac[0], original_H, rtol=0, atol=1e-14) assert np.isclose(std_ac[1], original_V, rtol=0, atol=1e-14) # no need to mangle orbit again, test reference/plane=H - element_holder.orbit.correct(reference=reference / 2, plane="H") + element_holder.tool.orbit.correct(reference=reference / 2, plane="H") positions_ac = bpms.positions.get() std_ac = np.std(positions_ac, axis=0) assert np.isclose(std_ac[0], 3.360429728849497e-05, rtol=0, atol=1e-14) @@ -187,7 +187,7 @@ def test_tuning_orbit_correction(): frf = element_holder.rf.frequency.get() element_holder.rf.frequency.set(frf + 100) for _ in range(3): - element_holder.orbit.correct( + element_holder.tool.orbit.correct( reference=reference_before_rf, plane="H", rf=True, @@ -202,12 +202,12 @@ def test_tuning_orbit_correction(): x, y = bpms.positions.get().T # get reference orbit reference_before_rf = np.concat((x, y)) - rf_weight = element_holder.orbit.get_rf_weight() - element_holder.orbit.set_rf_weight(1.1 * rf_weight) + rf_weight = element_holder.tool.orbit.get_rf_weight() + element_holder.tool.orbit.set_rf_weight(1.1 * rf_weight) frf = element_holder.rf.frequency.get() element_holder.rf.frequency.set(frf + 100) for _ in range(8): - element_holder.orbit.correct( + element_holder.tool.orbit.correct( reference=reference_before_rf, plane="H", rf=True, @@ -217,12 +217,12 @@ def test_tuning_orbit_correction(): frf_after = element_holder.rf.frequency.get() assert np.isclose(frf, frf_after, rtol=0, atol=1e-16) - element_holder.orbit.set_rf_weight(rf_weight) + element_holder.tool.orbit.set_rf_weight(rf_weight) # test getters of weights - assert np.isclose(element_holder.orbit.get_weight("BPM_C04-05", plane="H"), 1, rtol=0, atol=1e-16) - assert np.isclose(element_holder.orbit.get_virtual_weight(), 1, rtol=0, atol=1e-16) - assert np.isclose(element_holder.orbit.get_rf_weight(), rf_weight, rtol=0, atol=1e-16) + assert np.isclose(element_holder.tool.orbit.get_weight("BPM_C04-05", plane="H"), 1, rtol=0, atol=1e-16) + assert np.isclose(element_holder.tool.orbit.get_virtual_weight(), 1, rtol=0, atol=1e-16) + assert np.isclose(element_holder.tool.orbit.get_rf_weight(), rf_weight, rtol=0, atol=1e-16) def test_tuning_orbit_correction_config(): diff --git a/tests/tuning_tools/test_tuning_orm.py b/tests/tuning_tools/test_tuning_orm.py index f3652f0c..3ea994f0 100644 --- a/tests/tuning_tools/test_tuning_orm.py +++ b/tests/tuning_tools/test_tuning_orm.py @@ -15,7 +15,7 @@ def test_tuning_orm(): sr = Accelerator.load(config_path) element_holder = sr.design - orm = element_holder.orm + orm = element_holder.tool.orm bpms = element_holder.diagnostic.bpms.get("BPM") hcorr_names = element_holder.magnets.get("HCorr").names()[:4] @@ -31,4 +31,4 @@ def test_tuning_orm(): orm.save(save_path=f.name) # load saved file - element_holder.orbit.load(f.name) + element_holder.tool.orbit.load(f.name) diff --git a/tests/tuning_tools/test_tuning_tools.py b/tests/tuning_tools/test_tuning_tools.py index 5c748b00..635142a2 100644 --- a/tests/tuning_tools/test_tuning_tools.py +++ b/tests/tuning_tools/test_tuning_tools.py @@ -12,11 +12,11 @@ def callback(action: Action, data: dict): def test_tune_tool(): sr = Accelerator.load("tests/config/EBSTune.yaml", include_locations=False) sr.design.get_lattice().disable_6d() - sr.design.trm.measure(callback=callback) - sr.design.trm.save("tunemat.json") - sr.design.tune.load("tunemat.json") - sr.design.tune.set([0.17, 0.32], iter=2) - tune = sr.design.tune.readback() + sr.design.tool.trm.measure(callback=callback) + sr.design.tool.trm.save("tunemat.json") + sr.design.tool.tune.load("tunemat.json") + sr.design.tool.tune.set([0.17, 0.32], iter=2) + tune = sr.design.tool.tune.readback() assert np.abs(tune[0] - 0.17) < 1e-5 assert np.abs(tune[1] - 0.32) < 1e-5 @@ -24,20 +24,20 @@ def test_tune_tool(): def test_tune_add(): sr = Accelerator.load("tests/config/EBSTune.yaml", include_locations=False) sr.design.get_lattice().disable_6d() - sr.design.tune.load("tunemat.json") - tune_initial = sr.design.tune.readback() + sr.design.tool.tune.load("tunemat.json") + tune_initial = sr.design.tool.tune.readback() dtune = np.array([0.01, -0.01]) - sr.design.tune.add(dtune) - tune = sr.design.tune.readback() + sr.design.tool.tune.add(dtune) + tune = sr.design.tool.tune.readback() np.testing.assert_allclose(tune - tune_initial, dtune, atol=1e-5) def test_chroma_tool(): sr: Accelerator = Accelerator.load("tests/config/EBSOrbit.yaml", include_locations=False) sr.design.get_lattice().enable_6d() - sr.design.chromaticity.set([8.0, 5.0], iter=2) + sr.design.tool.chromaticity.set([8.0, 5.0], iter=2) QpAT = sr.design.get_lattice().get_chrom()[:-1] - Qp = sr.design.chromaticity.readback() + Qp = sr.design.tool.chromaticity.readback() assert np.abs(Qp[0] - 8.0) < 1e-3 assert np.abs(Qp[1] - 5.0) < 1e-3 assert np.abs(QpAT[0] - 8.0) < 1e-2 @@ -48,7 +48,7 @@ def test_chroma_add(): sr: Accelerator = Accelerator.load("tests/config/EBSOrbit.yaml", include_locations=False) sr.design.get_lattice().enable_6d() chromaAT = sr.design.get_lattice().get_chrom()[:-1] - sr.design.chromaticity.add([0.5, 0.4]) + sr.design.tool.chromaticity.add([0.5, 0.4]) chromaAT2 = sr.design.get_lattice().get_chrom()[:-1] chromaDiff = chromaAT2 - chromaAT assert np.abs(chromaDiff[0] - 0.5) < 5e-2