Example #1
0
import numpy as np
import scipy
import sys
sys.path.insert(0, './../src/')

import proc_profile_bottollier as ppb

if len(sys.argv) < 1:
    shot_number = int(open('shot_number.txt', 'r').read())
else:
    if (len(sys.argv) == 1) & ("py" in sys.argv[0]):
        shot_number = int(open('shot_number.txt', 'r').read())
    else:
        shot_number = int(sys.argv[1])

shot = ppb.ProcProfile(shot_number)
sweeps_average = 8

shot.reference_gd(all_shot=1, sw_clustersize=sweeps_average)
shot.eval_freq_overlap()
shot.plasma_gd(5000, sweeps_average, 1)
shot.eval_gd_overlap()
shot.init_gd()
shot.eval_phase()

fig = plt.figure()
fig.subplots_adjust(bottom=0.25)
ax1 = fig.add_subplot(111)
lns1 = ax1.plot(shot.freqs,
                shot.gd,
                marker='.',
Example #2
0
import proc_profile_bottollier as ppb
import ref_functions as rf

if len(sys.argv) < 1:
    shot_number = int(open('shot_number.txt', 'r').read())
else:
    if (len(sys.argv) == 1) & ("py" in sys.argv[0]):
        shot_number = int(open('shot_number.txt', 'r').read())
    else:
        shot_number = int(sys.argv[1])

factors = {'1': '1', '2/3': '2/3', '1/2': '1/2'}
pos = {}
cluster = 20
shot = ppb.ProcProfile(shot_number, save_locally=1)
sweep_ini = shot.time2sweep(100)
shot.reference_gd(all_shot=1, sw_clustersize=cluster)
shot.eval_freq_overlap()
shot.prepare_gd(sweep_ini, cluster, all_shot=1)
shot.eval_phase()
fig, ax = plt.subplots()
plt.subplots_adjust(bottom=0.25)
lines = {}

for f in factors.keys():
    pos[f] = ppb.find_pos(shot.freqs[1:], shot.phi, factor=eval(f))
    lines[f], = plt.plot(pos[f] * 1e2, shot.ne[1:], label=factors[f])

ax.legend(loc='upper left', title='Factor:')
ax.set_xlabel('r (cm)')
def main(argv):
    """Test maximum density."""
    print(len(argv))
    if len(argv) < 1:
        shot_number = int(open('shot_number.txt', 'r').read())
    else:
        if (len(argv) == 1) & ("py" in argv[0]):
            shot_number = int(open('shot_number.txt', 'r').read())
        else:
            shot_number = int(argv[1])
    fig, ax = plt.subplots()
    plt.subplots_adjust(bottom=0.25)
    shot = ppb.ProcProfile(shot_number)

    shot.reference_gd(all_shot=1)
    cluster = 20
    shot.plasma_gd(1, cluster, 1)

    ax.pcolormesh(shot.X['K'], shot.Y['K'], shot.matrix_k_mean)
    ax.pcolormesh(shot.X['Ka'], shot.Y['Ka'], shot.matrix_ka_mean)

    plt.plot(shot.X['K'],
             shot.Y['K'][shot.matrix_k_mean.argmax(axis=0)] - 3.36,
             color='b',
             linewidth=2.0)
    plt.plot(shot.X['Ka'],
             shot.Y['Ka'][shot.matrix_ka_mean.argmax(axis=0)] - 3.36,
             color='b',
             linewidth=2.0)
    plt.plot(shot.X['K'],
             shot.Y['K'][shot.matrix_k_mean.argmax(axis=0)],
             color='b',
             linewidth=2.0)
    plt.plot(shot.X['Ka'],
             shot.Y['Ka'][shot.matrix_ka_mean.argmax(axis=0)],
             color='b',
             linewidth=2.0)
    l, = plt.plot(shot.X['K'],
                  shot.Y['K'][shot.matrix_k_mean.argmax(axis=0)],
                  color='r',
                  linewidth=2.0)
    m, = plt.plot(shot.X['Ka'],
                  shot.Y['Ka'][shot.matrix_ka_mean.argmax(axis=0)],
                  color='r',
                  linewidth=2.0)
    plt.xlabel("freq (GHz)")
    plt.ylabel("group delay (ns)")
    plt.title("# %s - time: %s ms" %
              (shot.shot, shot.sweep2time(shot.sweep_cur)))
    plt.ylim(0, 12)
    plt.xlim(shot.X['K'].min(), shot.X['Ka'].max())

    axcolor = 'lightgoldenrodyellow'
    axfreq = plt.axes([0.25, 0.1, 0.65, 0.03], axisbg=axcolor)

    sweep = Slider(axfreq,
                   'Sweep',
                   1,
                   len(shot.points) - 1 - cluster,
                   valinit=1,
                   valfmt='%1.f')

    def update(val):
        shot.plasma_gd(int(sweep.val), cluster, 1)
        ax.pcolormesh(shot.X['K'], shot.Y['K'], shot.matrix_k_mean)
        ax.pcolormesh(shot.X['Ka'], shot.Y['Ka'], shot.matrix_ka_mean)
        l.set_ydata(shot.Y['K'][shot.matrix_k_mean.argmax(axis=0)])
        m.set_ydata(shot.Y['Ka'][shot.matrix_ka_mean.argmax(axis=0)])
        ax.set_title("# %s - time: %.3f ms" %
                     (shot.shot, shot.sweep2time(shot.sweep_cur)))
        fig.canvas.draw_idle()

    sweep.on_changed(update)

    resetax = plt.axes([0.8, 0.025, 0.1, 0.04])
    button = Button(resetax, 'Reset', color=axcolor, hovercolor='0.975')

    def reset(event):
        sweep.reset()

    button.on_clicked(reset)

    plt.show()