コード例 #1
0
                bpm1_list.append(bpm_data1)
                bpm2_list.append(bpm_data2)

                offset = np.array(dict_['scan 1']['method']['actuators'][
                    'SARUN18-UDCP%i00' % n_streaker]['CENTER']) * 1e-3
            xx_list.append(offset)

            # Model
            if n_file == 0:
                _, year, month, day, hour, minute, second, _ = os.path.basename(
                    file_).split('_')
                date = datetime.datetime(int(year), int(month), int(day),
                                         int(hour), int(minute), int(second))
                timestamp = int(date.strftime('%s'))
                mat = elegant_matrix.get_elegant_matrix(
                    n_streaker - 1, timestamp)
                r12_bpm1 = mat[bpms[0]][0, 1]
                r12_bpm2 = mat[bpms[1]][0, 1]

                wf_dict_bpm1 = wf_calc.calc_all(semigap_m,
                                                r12_bpm1,
                                                calc_dipole=True,
                                                beam_offset=offset[...,
                                                                   np.newaxis])
                wf_dict_bpm2 = wf_calc.calc_all(semigap_m,
                                                r12_bpm2,
                                                calc_dipole=True,
                                                beam_offset=offset[...,
                                                                   np.newaxis])
                bpm1_list_model.append(
                    wf_dict_bpm1['lin_dipole']['kick_per_m_offset'])
コード例 #2
0
import matplotlib.pyplot as plt
import datetime

import elegant_matrix
from ElegantWrapper.simulation import ElegantSimulation

import myplotstyle as ms

plt.close('all')

year, month, day, hour, minute, second = 2020, 2, 9, 22, 54, 27
date = datetime.datetime(int(year), int(month), int(day), int(hour),
                         int(minute), int(second))
timestamp = int(date.strftime('%s'))
mat0 = elegant_matrix.get_elegant_matrix(0,
                                         timestamp,
                                         del_sim=False,
                                         print_=False)
mat1 = elegant_matrix.get_elegant_matrix(1,
                                         timestamp,
                                         del_sim=False,
                                         print_=False)

dscr0 = 'SARBD01.DSCR050'
dscr1 = 'SARBD02.DSCR050'
#print(mat0[dscr0])
#print(mat1[dscr0])

#print(mat0[dscr1])
print(mat1[dscr1])

sys.exit()
コード例 #3
0
                bpm2_list.append(bpm_data2)

                offset = np.array(dict_['scan 1']['method']['actuators'][
                    'SARUN18-UDCP%i00' % (n_streaker + 1)]['CENTER']) * 1e-3
                #print(n_streaker, gap, offset.min(), offset.max(), offset.size)
            xx_list.append(offset)

            # Model
            if n_file == 0:
                _, year, month, day, hour, minute, second, _ = os.path.basename(
                    file_).split('_')
                date = datetime.datetime(int(year), int(month), int(day),
                                         int(hour), int(minute), int(second))
                timestamp = int(date.strftime('%s'))
                mat = elegant_matrix.get_elegant_matrix(n_streaker,
                                                        timestamp,
                                                        print_=True)
                r12_bpm1 = mat[bpms[0]][0, 1]
                r12_bpm2 = mat[bpms[1]][0, 1]

                beam_offset = offset[...,
                                     np.newaxis] - guessed_centers[n_streaker]
                wf_dict_bpm1 = wf_calc.calc_all(semigap_m,
                                                r12_bpm1,
                                                calc_dipole=True,
                                                beam_offset=beam_offset)
                wf_dict_bpm2 = wf_calc.calc_all(semigap_m,
                                                r12_bpm2,
                                                calc_dipole=True,
                                                beam_offset=beam_offset)
                bpm1_list_model = (wf_dict_bpm1['lin_dipole']['kick_effect'] /
コード例 #4
0
import datetime
import elegant_matrix

data_timestamps = list(elegant_matrix.mag_data.values())[0][:, 0]

year, month, day = 2020, 8, 26
times = [
    (21, 55, 0),
    (21, 57, 0),
    (22, 0, 0),
    #(11, 0, 0),
    #(11, 21, 00),
    #(17, 34, 33),
    #(17, 57, 47),
]

for hour, minute, second in times:
    date = datetime.datetime(int(year), int(month), int(day), int(hour),
                             int(minute), int(second))
    timestamp = int(date.strftime('%s'))
    mat0 = elegant_matrix.get_elegant_matrix(99,
                                             timestamp,
                                             del_sim=False,
                                             print_=False,
                                             branch='Athos')

    dscr0 = 'SATBD02.DSCR050'

    print('Streaker 1 to %s at %02i:%02i:%02i R12=%.3e' %
          (dscr0, hour, minute, second, mat0[dscr0][0, 1]))
コード例 #5
0
tt = list(mag_data.values())[0][-2, 0]

macro_dict = {'_matrix_start_': 'MIDDLE_STREAKER_%i$1' % (streaker_index + 1)}
for quad in quads:
    key = '_' + quad.lower() + '.k1_'
    val = get_data(quad, tt)
    length = get_magnet_length(quad)
    macro_dict[key] = val / length

cmd, sim = elegant_matrix.run_sim(macro_dict, './SwissFEL_in0.ele',
                                  './Elegant-Aramis-Reference.lat')

devices = quads + streakers + bpms + [q + '.COR' for q in quads] + [
    q + '.Q2' for q in quads
] + ['DRIFT1427'] + [s + '_B' for s in streakers]
mat_dict = {}
mat = sim.mat
for name, r11, r12, r21, r22 in zip(
        mat['ElementName'],
        mat['R11'],
        mat['R12'],
        mat['R21'],
        mat['R22'],
):
    if name in devices:
        mat_dict[name] = np.array([[r11, r12], [r21, r22]])

mat_elegant_new = mat_dict[bpm]

mat_elegant_new2 = elegant_matrix.get_elegant_matrix(0, tt)[bpm]