Ejemplo n.º 1
0
def plot_3D_opt_cases(var, tilt_case):
    data_dir = '../data/TSS/{}/{}'.format(tilt_case, 'UNOPT')
    SMPAnalysis.fetch_from(data_dir + '/DUMMY_BOTH')
    case = SMPAnalysis('')
    z = case[VARS]

    fig = plt.figure(figsize=plt.figaspect(0.5))
    for i, opt_case in enumerate(['UNOPT', 'OPTIM']):
        data_dir = '../data/TSS/{}/{}'.format(tilt_case, opt_case)
        st = load_davecs(data_dir)
        ax = fig.add_subplot(2, 2, i + 1, projection='3d')
        ax.set_xlabel('Y [mm]')
        ax.set_ylabel('B')
        ax.set_title(var + ' ({}, {})'.format(tilt_case, opt_case))
        var_vals = np.array([st[var](v) for v in z.T]).T
        for j, v in enumerate(var_vals.T):
            ax.plot(z['Y'][:, j], z['B'][:, j], var_vals[:, j])
        art.form(ax)
    for i, opt_case in enumerate(['UNOPT', 'OPTIM']):
        data_dir = '../data/TSS/{}/{}'.format(tilt_case, opt_case)
        ax = fig.add_subplot(2, 2, i + 3, projection='3d')
        ax.set_xlabel('Y [mm]')
        ax.set_ylabel('B')
        SMPAnalysis.fetch_from(data_dir + '/DUMMY_BOTH')
        case = SMPAnalysis('')
        z = case[VARS]
        var_vals = case.stunee[var]
        for j, v in enumerate(var_vals.T):
            ax.plot(z['Y'][:, j], z['B'][:, j], var_vals[:, j])
        art.form(ax)
Ejemplo n.º 2
0
def plot_main(z, x='Y', y='B', var='mu0', title=''):
    fig = plt.figure()
    ax = fig.add_subplot(121)
    if title != '':
        ax.set_title('Trajectory: ' + title)
    ax.set_xlabel(x + ' [mm]')
    ax.set_ylabel(y + ' [mrad]')
    ax.plot(z[x] * 1e3, z[y] * 1e3)
    art.form(ax)
    ax = fig.add_subplot(122, projection='3d')
    ax.set_xlabel(x + ' [mm]')
    ax.set_ylabel(y + ' [mrad]')
    ax.set_title(var)
    for traj in z.T[1:]:
        ax.plot(traj[x] * 1e3,
                traj[y] * 1e3,
                ST[VAR](traj),
                label='{:4.2} [mm]'.format(traj[x][0] * 1e3))
    ax.legend()
    art.form(ax)
Ejemplo n.º 3
0
def plot_3D(var, tilt_case, opt_case):
    data_dir = '../data/TSS/{}/{}'.format(tilt_case, opt_case)
    SMPAnalysis.fetch_from(data_dir + '/DUMMY_BOTH')
    case = SMPAnalysis('')
    z = case[VARS]
    st = load_davecs(data_dir)
    po_vals = case.stunee[var]
    py_vals = np.array([st[var](v) for v in z.T]).T

    fig = plt.figure(figsize=plt.figaspect(0.5))
    ax = fig.add_subplot(121, projection='3d')
    ax.set_xlabel('Y [mm]')
    ax.set_ylabel('B')
    ax.set_title(var + ' ({}, {}, {})'.format(tilt_case, opt_case, 'POLVAL'))
    for i, v in enumerate(po_vals.T):
        ax.plot(z['Y'][:, i], z['B'][:, i], po_vals[:, i])
    art.form(ax)
    ax = fig.add_subplot(122, projection='3d')
    ax.set_xlabel('Y [mm]')
    ax.set_ylabel('B')
    ax.set_title(var + ' ({}, {}, {})'.format(tilt_case, opt_case, 'PYTHON'))
    for i, v in enumerate(py_vals.T):
        ax.plot(z['Y'][:, i], z['B'][:, i], py_vals[:, i])
    art.form(ax)
Ejemplo n.º 4
0
t = np.column_stack([case['TURN'][:, 1:] * 1e-6 for case in dat_arr])
sy = np.column_stack([case['S_Y'][:, 1:] for case in dat_arr])
sx = np.column_stack([case['S_X'][:, 1:] for case in dat_arr])
yoff = np.hstack([case.pray['Y'][1:] * 1e3 for case in dat_arr])
ii = np.argsort(yoff)
tbl = {}
tbl['Y'] = fit_matrix(t.T, sy.T)
tbl['X'] = fit_matrix(t.T, sx.T)

f, ax = plt.subplots(1, 1)
ax.errorbar(yoff[ii],
            tbl['Y'][ii, 0]['f'],
            yerr=tbl['Y'][ii, 1]['f'],
            fmt='--.')
art.form(ax)
ax.set_xlabel('Y offset [mm]')
ax.set_ylabel('Frequency estimate [Hz]')

f, ax = plt.subplots(1, 1)
ax.errorbar(yoff[ii], meanmu0[ii], yerr=semu0[ii], fmt='--.')
art.form(ax)
ax.set_xlabel('Y offset [mm]')
ax.set_ylabel('mean (over time) spin tune')

f, ax = plt.subplots(1, 2, sharey=True)
ax[0].errorbar(meanmu0[ii],
               meannx[ii],
               yerr=senx[ii],
               xerr=semu0[ii],
               fmt='--.')
Ejemplo n.º 5
0
from statsmodels.graphics.tsaplots import plot_acf, plot_pacf

font = {'size': 14}
plt.rc('font', **font)

SMPAnalysis.fetch_from('../data/ARTEM_TEST/SEXTVAR/SEXT1')

dat = SMPAnalysis('CW1')

f, ax = plt.subplots(1, 1)
pidmin = 28
ymin = dat.pray[pidmin]['Y'] * 1e3
pidmax = 24
ymax = dat.pray[pidmax]['Y'] * 1e3
ax.plot(dat['T'][:, pidmin],
        dat['D'][:, pidmin],
        '--.',
        label='y-offset: {:4.2f} [mm]'.format(ymin))
ax.plot(dat['T'][:, pidmax],
        dat['D'][:, pidmax],
        '--.',
        label='y-offset: {:4.2f} [mm]'.format(ymax))
ax.set_xlabel('Phase difference')
ax.set_ylabel('(K-K0)/K0')
ax.legend()
ax.grid()
art.form(ax)

dat.fit_polarization()
plot_pacf(dat.model.residual, lags=10)