Exemplo n.º 1
0
def main(fname1, fname2, R, z):
    f1 = tf.transp_fbm(fname1)
    f2 = tf.transp_fbm(fname2)
    f1.plot_Epitch()
    f2.plot_Epitch()
    #mean=f1.f_space_int
    x = f1.dict_dim['pitch']
    y = f2.dict_dim['E'] * 1e-3
    indR = np.argmin(f1.dict_dim['R'] - R < 0.)
    indz = np.argmin(f1.dict_dim['z'] - z < 0.)

    diff = f2.fdist_notnorm[:, :, indR, indz] - f1.fdist_notnorm[:, :, indR,
                                                                 indz]

    f = plt.figure()
    ax = f.add_subplot(111)
    cb = ax.contourf(x, y, diff, cmap='rainbow')
    ax.set_xlabel(r'$\xi$')
    ax.set_ylabel(r'E [keV]')
    plt.colorbar(cb)
    pu.limit_labels(
        ax,
        r'$\xi$',
        r'E [keV]',
        title='(t2-t1,R,z)=({:.2f}-{:.2f} s,{:.2f} m,{:.2f} m)'.format(
            f2.time, f1.time, R, z))
    f.tight_layout()
    ax.grid('on')
    plt.show()
Exemplo n.º 2
0
    def plot_ripplewell(self):
        """
        """
        R_grid, z_grid, ripplewell = self.calculate_alpha()
        eqd = self.eqd

        f=plt.figure(figsize=(7,8)); ax=f.add_subplot(111)
        levels=[1.]
        cs=ax.contour(R_grid, z_grid, ripplewell, levels, colors='r')
        try:
            w=np.loadtxt('/home/vallar/WORK/JT-60SA/wall/input.wall_2d', skiprows=1)
            ax.plot(w[:,0], w[:,1], 'k-', lw=3)
            ax.plot(self.eqd.R, self.eqd.Z, 'b', lw=2.)
        except:
            print('No Wall')
        plt.axis('equal')
        #plt.legend(loc='best')
        limit_labels(ax, r'R [m]', r'Z [m]')

        legend_elements = [Line2D([0], [0], color='r', lw=3, label=r'$\alpha^*=1$'),\
        #Line2D([0], [0], color='g', label=r'$\alpha^*_{cyl}=1$', ls='--', lw=3.),\
        Line2D([0], [0], color='b', label=r'Sep.', lw=3.),\
        Line2D([0], [0], color='k', label=r'Wall', lw=3.)]

        #ax.legend(bbox_to_anchor=(0.2, 0.8),handles=legend_elements,loc='best')
        ax.legend(handles=legend_elements,loc='best')
        plt.tight_layout()
Exemplo n.º 3
0
def plot_input_1d(to, time, axne, axTe, ls):
    """ plot 1d input

    Plots ne,ni,te,ti vol-avgd

    Parameters:
        time (arr) : array with the times where to plot the lines
    Attributes:
        None    
    Note:
    """
    au.common_style()

    if axne==0:
        f = plt.figure(figsize=(8, 8))
        axne = f.add_subplot(211)
        axTe = f.add_subplot(212, sharex=axne)
        fig_flag = 0 # this means it wasn't initialized 
    #axzf = f.add_subplot(313, sharex=axne)
    else:
        f=plt.gcf()
        fig_flag=1

    t=to.t
    for y, c, l in zip([to.ne_vavg, to.ni_vavg], ['k','r'], [r'e', r'i']):
        au._plot_1d(t, y, ax=axne, color=c, label=l, ls=ls)
    for y, c, l in zip([to.Te_vavg, to.Ti_vavg], ['k','r'], [r'e', r'i']):
        au._plot_1d(t, y, ax=axTe, color=c, label=l, ls=ls)

    if fig_flag==0:
        #====================================================
        # Correct ticks and xylabels
        #====================================================
        au.limit_labels(axne, r'Time [s]', r'$\langle n \rangle$ [$1/m^3$]','' )
        au.limit_labels(axTe, r'Time [s]', r'$\langle T \rangle$ [$eV$]','' )

    #====================================================
    # Plot vertical lines
    #====================================================
    ind = tu._time_to_ind(to.t, time)
    for ax in [axne, axTe]:#, axzf]:
        if len(ind)!=1:
            for i, el in enumerate(ind):
                ax.axvline(x=to.t[el], color=col[i], lw=2., linestyle='--')
        if fig_flag==0:
            ax.legend(loc='best')

    f.tight_layout()
    plt.show()    
Exemplo n.º 4
0
def plot_tips(run, ind, ax=0, label=''):
    orb = run.orbit.read()
    plot_flag = 1
    if ax == 0:
        f = plt.figure()
        ax = f.add_subplot(111)
        plot_flag = 0
    pitch, ind_tips = _find_tips(run, ind)
    ax.scatter(orb['r'][ind][ind_tips],
               orb['z'][ind][ind_tips],
               marker='x',
               label=label)
    #w=run.wall.read()
    #ax.plot(w['r'], w['z'], 'k')
    if plot_flag == 0:
        limit_labels(ax, 'R [m]', 'z [m]')
        ax.axis('equal')
    return
Exemplo n.º 5
0
def main(fname1, fname2):
    f1 = tf.transp_fbm(fname1)
    f2 = tf.transp_fbm(fname2)
    f1.plot_Epitch()
    f2.plot_Epitch()
    diff = f1.f_space_int - f2.f_space_int
    #mean=f1.f_space_int
    x = f1.dict_dim['pitch']
    y = f2.dict_dim['E'] * 1e-3

    f = plt.figure()
    ax = f.add_subplot(111)
    cb = ax.contourf(x, y, diff, cmap='rainbow')
    ax.set_xlabel(r'$\xi$')
    ax.set_ylabel(r'E [keV]')
    plt.colorbar(cb)
    pu.limit_labels(ax, r'$\xi$', r'E [keV]', title='Post crash - pre crash')
    f.tight_layout()
    ax.grid('on')
    plt.show()
Exemplo n.º 6
0
    def plot_ripplewell_cyl():
        """
        """
        R_grid, z_grid, ripplewell_cyl = calc_ripplewell_cyl()
        _,_,eqd = read_file()
        f=plt.figure(figsize=(5,8)); ax=f.add_subplot(111)
        levels=[0.1, 0.2, 1., 5., 50]
        levels=[1.]
        cs=ax.contour(R_grid, z_grid, ripplewell_cyl, levels, colors='black',linewidths=3., label='Cyl.')
        plt.clabel(cs, levels)
        labels=['Cyl.']
        for i in range(len(labels)):
            cs.collections[i].set_label(labels[i])

        w=np.loadtxt('/home/vallar/WORK/JT-60SA/wall/input.wall_2d', skiprows=1)
        ax.plot(w[:,0], w[:,1], 'k-', lw=3)
        ax.plot(self.eqd.R, self.eqd.Z, 'r-', lw=2.)
        plt.axis('equal')
        #plt.legend(loc='best')
        limit_labels(ax, r'R [m]', r'Z [m]')
        ax.set_title(r'$\alpha^*$')
        #ax.legend(loc='best')
        plt.tight_layout()
Exemplo n.º 7
0
def plot_delta_tips(run, ind, ax=0, label=''):
    orb = run.orbit.read()
    plot_flag = 1
    if ax == 0:
        f = plt.figure()
        ax = f.add_subplot(111)
        plot_flag = 0
    pitch, ind_tips = _find_tips(run, ind)

    delta = np.sqrt(
        np.diff(orb['r'][ind][ind_tips])**2 +
        np.diff(orb['z'][ind][ind_tips])**2)
    CS = ax.scatter(orb['r'][ind][ind_tips][:-1],
                    orb['z'][ind][ind_tips][:-1],
                    c=delta,
                    cmap='jet')
    CB = plt.colorbar(CS)
    w = run.wall.read()
    #ax.plot(w['r'], w['z'], 'k')
    if plot_flag == 0:
        limit_labels(ax, 'R [m]', 'z [m]')
        ax.axis('equal')

    return ind_tips, delta
Exemplo n.º 8
0
def plot_input_prof(to, time=[0]):
    """ plot 1d input

    Plots input quantities, such as ne, ni, Te, Ti profiles

    Parameters:
        time (arr) : array with the times   where to plot the lines
    Attributes:
        None    
    Note:
    """        
    au.common_style()

    f = plt.figure(figsize=(12,10))
    axne = f.add_subplot(221)
    axni = f.add_subplot(222, sharey=axne)
    axTe = f.add_subplot(223)
    axTi = f.add_subplot(224, sharey=axTe)
    ind = tu._time_to_ind(to, time)

    for i, el in enumerate(ind):
        lab = r't = {:.2f}'.format(to.t[el])
        axne.plot(to.rho[el,:], to.kin_vars['ne'][el,:], col[i], label=lab, lw=2.)
        axni.plot(to.rho[el,:], to.kin_vars['ni'][el,:], col[i], label=lab, lw=2.)
        axTe.plot(to.rho[el,:], to.kin_vars['te'][el,:]*1e-3, col[i], label=lab, lw=2.)
        axTi.plot(to.rho[el,:], to.kin_vars['ti'][el,:]*1e-3, col[i], label=lab, lw =2.)

    #========================================================
    # SET TICK LOCATION
    #========================================================
    au.limit_labels(axne, r'$\rho$', r'$n_e$ [$1/m^3$]','' )
    au.limit_labels(axTe, r'$\rho$', r'$T_e$ [$keV$]','' )
    au.limit_labels(axni, r'$\rho$', r'$n_i$ [$1/m^3$]','' )
    au.limit_labels(axTi, r'$\rho$', r'$T_i$ [$keV$]','' )

    axTi.legend(loc='best')

    f.tight_layout()
    #f.subplots_adjust(left=0.2)
    plt.show()    
Exemplo n.º 9
0
def summary_plot(fname_sim=['/home/vallar/TCV/58823/58823V71.CDF'], t=0.):
    """
    Summary plot of a TRANSP simulation
    
    Params:
        fname   str : CDF filename of the simulation

    """
    if type(fname_sim) == str: fname_sim = [fname_sim]

    ncol = 4
    nrow = 3
    f, ax = plt.subplots(nrow, ncol, figsize=[4 * ncol, 3 * nrow])
    objs = []
    for i, fname in enumerate(fname_sim):
        try:
            if fname[-4:] != '.CDF': fname += '.CDF'
            o = te.transp_exp(fname)
        except:
            print('No fname ' + fname)
            continue
        objs = np.append(objs, o)
        if t == 0.:
            ind = int(np.size(o.t) / 2)
        else:
            ind = np.argmin(o.t - t < 0.)

        ax[0, 0].plot(o.t, o.ip * 1e-3, col[i], lw=2.3, label=fname[-12:-4])
        au.limit_labels(ax[0, 0], r't (s)', '$I_{TOT} (kA)$')
        ax[0, 0].legend(loc='best')
        ax[0, 0].axvline(x=o.t[ind])

        ax[1, 0].plot(o.rho[ind, :],
                      o.file['Q'][ind, :],
                      col[i],
                      lw=2.3,
                      label='t=' + str(round(o.t[ind], 3)) + ' s')
        if i == 0:
            ax[1, 0].plot([0., 1.], [1., 1.], 'k--', lw=2.3)
        au.limit_labels(ax[1, 0], r'$\rho$', r'q')
        ax[1, 0].legend(loc='best')

        ax[0, 1].plot(o.rho[ind, :],
                      o.kin_vars['ne'][ind, :],
                      col[i],
                      lw=2.3,
                      label='el.')
        ax[0, 1].plot(o.rho[ind, :],
                      o.kin_vars['ni'][ind, :],
                      col[i],
                      lw=2.3,
                      ls='--',
                      label='ions')
        au.limit_labels(ax[0, 1], r'$\rho$', r'$n (m^{-3})$')

        ax[1, 1].plot(o.rho[ind, :],
                      o.kin_vars['te'][ind, :] * 1e-3,
                      col[i],
                      lw=2.3,
                      label='el.')
        ax[1, 1].plot(o.rho[ind, :],
                      o.kin_vars['ti'][ind, :] * 1e-3,
                      col[i],
                      lw=2.3,
                      ls='--',
                      label='ions')
        au.limit_labels(ax[1, 1], r'$\rho$', r'$T (keV)$')
        try:
            ax[0, 2].plot(o.rho[ind, :],
                          o.nb_FKP_vars['n'][ind, :],
                          col[i],
                          lw=2.3)
            au.limit_labels(ax[0, 2], r'$\rho$', r'$n_{fast} (m^{-3})$')

            ax[1, 2].plot(o.rho[ind, :],
                          o.nb_FKP_vars['nbcd'][ind, :] * 1e-3,
                          col[i],
                          lw=2.3)
            au.limit_labels(ax[1, 2], r'$\rho$',
                            r'$j_{fast} (kA\cdot m^{-2})$')
            ax[0, 3].plot(o.t,
                          o.nb_in_vars['P_D'] * 1e-6,
                          col[i],
                          marker='x',
                          lw=2.3)
            au.limit_labels(ax[0, 3], r'$t (s)$', r'$P_{inj} (MW)$')
            ax[0, 3].axvline(x=o.t[ind])
            ax2 = ax[0, 3].twinx()
            ax2.plot(o.t,
                     o.nb_in_vars['E_D'] * 1e-3,
                     col[i],
                     marker='x',
                     lw=2.3)
            ax2.set_ylabel(r'$E_{inj} (keV)$')
        except:
            None

        ax[2, 0].plot(o.t, o.file['YAXIS'][:], col[i], lw=2.3)
        au.limit_labels(ax[2, 0], r'$t (s)$', r'$z_{axis} (cm)$')
        ax[2, 0].axvline(x=o.t[ind])

        ax[2, 1].plot(o.rho[ind, :], o.file['TAUPI'][ind, :], col[i], lw=2.3)
        au.limit_labels(ax[2, 1], r'$\rho$', r'$\tau^{conf}_{ion} (s)$')

        o._calculate_n0()
        ax[2, 2].semilogy(o.rho[ind, :], o.n0_tot[ind, :], col[i], lw=2.3)
        #au.limit_labels(ax[2,2], r'$\rho$', r'$n_0 (m^{-3})$')

        #au.limit_labels(ax2, r'$t (s)$', r'$E_{inj} (keV)$')

        ax[1, 3].plot(o.t,
                      o.file.variables['NEUTT'],
                      col[i],
                      marker='x',
                      lw=2.3)
        au.limit_labels(ax[1, 3], r'$t (s)$', r'Total neutron (1/s) ')
        ax[1, 3].axvline(x=o.t[ind])

        o._calculate_wmhd()
        ax[2, 3].plot(o.t, o.wtot * 1e-3, col[i], lw=2.3)
        ax[2, 3].plot(o.t, o.wth * 1e-3, col[i], ls='--', lw=2.3)
        au.limit_labels(ax[2, 3], r'$t (s)$', r'$W (kJ)$')
        ax[2, 3].axvline(x=o.t[ind])
    for el in ax:
        for el2 in el:
            el2.grid('on')
    f.tight_layout()
    plt.show()

    return objs, f, ax
Exemplo n.º 10
0
def plot_eq(to, time=[0], f=0):
    """ plot equilibrium

    Plots equilibrium

    Parameters:
        time (arr) : array with the times   where to plot the lines
    Attributes:
        None    
    Note:
    """
    au.common_style()
    ind = tu._time_to_ind(to.t, time)
    ind = ind[0]

    flag_leg = 1
    ls = '-'
    if not isinstance(f, matplotlib.figure.Figure):
        f = plt.figure(figsize=(12, 10))
        axj = f.add_subplot(221)
        axp = f.add_subplot(222)
        axf = f.add_subplot(223)
        axc = f.add_subplot(224)
        axq = axf.twinx(
        )  # instantiate a second axes that shares the same x-axis
        #axff=axc.twinx()
    else:
        axj, axp, axf, axc, axq = f.axes
        flag_leg = 0
        ls = '--'
    axj.plot(to.rho[ind, :],
             to.eq_vars['j'][ind, :] * 1e-3,
             'k',
             label=r'$j_{TOT}$',
             lw=2.,
             linestyle=ls)
    axj.plot(to.rho[ind, :],
             to.eq_vars['joh'][ind, :] * 1e-3,
             'b',
             label=r'$j_{OH}$',
             lw=2.,
             linestyle=ls)
    axj.plot(to.rho[ind, :],
             to.eq_vars['jbs'][ind, :] * 1e-3,
             'r',
             label=r'$j_{BS}$',
             lw=2.,
             linestyle=ls)
    add_curr = to.eq_vars['j'][ind, :] - to.eq_vars['joh'][
        ind, :] - to.eq_vars['jbs'][ind, :]
    axj.plot(to.rho[ind, :],
             add_curr * 1e-3,
             'g',
             label=r'$j_{Add. heat.}$',
             lw=2.,
             linestyle=ls)

    axp.plot(to.rho[ind, :],
             to.eq_vars['p'][ind, :] * 1e-3,
             'k',
             label=r'Total',
             lw=2.,
             linestyle=ls)
    axp.plot(to.rho[ind, :],
             to.eq_vars['pth'][ind, :] * 1e-3,
             'r',
             label=r'Th.',
             lw=2.,
             linestyle=ls)
    axp.plot(to.rho[ind, :],
             to.eq_vars['pnth'][ind, :] * 1e-3,
             'b',
             label=r'Non th.',
             lw=2.,
             linestyle=ls)

    axf.plot(to.rho[ind, :],
             to.eq_vars['pol_flux'][ind, :] * 10.,
             'k',
             label=r'Pol. flux x 10',
             lw=2.,
             linestyle=ls)
    axf.plot(to.rho[ind, :],
             to.eq_vars['tor_flux'][ind, :],
             'b',
             label=r'Tor. Flux',
             lw=2.,
             linestyle=ls)
    axq.plot(to.rho[ind, :],
             to.eq_vars['q'][ind, :],
             'r',
             label=r'q',
             lw=2.,
             linestyle=ls)
    axq.plot([0, 1], [1, 1], 'r--')
    axq.set_ylim([0, 10])
    axf.set_ylim([0, 0.5])

    axc.plot(to.rho[ind, :],
             to.file.variables['ETA_USE'][ind, :],
             'k',
             lw=2.,
             linestyle=ls)

    # axc.plot(to.t[ind], to.file.variables['PCUR'][ind]*1e-3, 'kv', label=r'TRANSP CUR', lw=2., linestyle=ls)
    # #axc.plot(to.t[ind], to.file.variables['PCURC'][ind]*1e-3, 'kv', label=r'Calc', lw=2., linestyle=ls)
    # axff.plot(to.t[ind], to.eq_vars['f'][ind], 'rx', label=r'TRANSP F', lw=2., linestyle=ls)

    #========================================================
    # SET TICK LOCATION
    #========================================================
    if flag_leg == 1:
        axq.tick_params(axis='y', labelcolor='r')
        axq.set_ylabel(r'q', color='r')
        axc.set_yscale('log')
        au.limit_labels(axj, r'$\rho_{TOR}$', r'j [kA/m$^2$]', '')
        au.limit_labels(axp, r'$\rho_{TOR}$', r'p [kPa]', '')
        axf.set_xlabel(r'$\rho_{TOR}$')
        axf.set_ylabel(r'Fluxes (Wb/rad)')
        axj.legend(loc='best')
        axf.legend(loc='upper left')
        axf.grid('on')
        axp.legend(loc='upper right')
        axp.grid('on')
        axc.grid('on')
        axc.set_xlabel(r'$\rho_{TOR}$')
        axc.set_ylabel(r'$\eta$')
        f.tight_layout()
        f.subplots_adjust(top=0.9)
    else:
        axq.set_yticklabels([])
    try:
        titles = f.get_children()[-1]
        title = titles.get_text()
        if titles.get_text() == '':
            f.suptitle('{} t={:.2f} s'.format(to.fname[-12:-4], time))
        else:
            newtitle = title + ' {}'.format(to.fname[-12:-4])
            titles.set_text(newtitle)
    except:
        f.suptitle('{} t={:.2f} s'.format(to.fname[-12:-4], time))

    plt.show()
Exemplo n.º 11
0
# x,y,yH,yfrac = o1._init_pbalance_vars()
# o1._plot_pbalance_frac(x, yfrac, axfrac, ylim=[0,70])
# x,y,yH,yfrac = o2._init_pbalance_vars()
# o2._plot_pbalance_frac(x, yfrac, axfrac, ylim=[0,70], ls='--', leg=0)
# f.text(0.15, 0.95,'Shot #'+str(shot1)+' (on-axis,  solid )', fontsize=16, color='k')
# f.text(0.6, 0.95,'Shot #'+str(shot2)+' (off-axis, dotted)', fontsize=16, color='k')
# f.tight_layout()
# plt.subplots_adjust(top=0.9)

f = plt.figure()
axE = f.add_subplot(111)
#axp = f.add_subplot(212, sharex=axp)
axE.plot(o1.dict_dim['E']*1e-3, o1.f_spacep_int/o1.norm, 'k-', lw=2.3, label=r'No EC')
axE.plot(o2.dict_dim['E']*1e-3, o2.f_spacep_int/o2.norm, 'r-', lw=2.3, label=r'Full EC')
axE.set_xlim(0, 25)
limit_labels(axE,r'Energy [keV]',r'f [1/keV]','')
f.tight_layout()
axE.legend(loc='best')

o1._integrate_spaceE()
o2._integrate_spaceE()

f = plt.figure()
axE = f.add_subplot(111)
#axp = f.add_subplot(212, sharex=axp)
axE.plot(o1.dict_dim['pitch'], o1.f_spaceE_int, 'k-', lw=2.3, label=r'No EC')
axE.plot(o2.dict_dim['pitch'], o2.f_spaceE_int, 'r-', lw=2.3, label=r'Full EC')
axE.set_xlim(-1., 1.)
limit_labels(axE,r'$\xi=v_\parallel/v$',r'f ','')
f.tight_layout()
axE.legend(loc='best')
Exemplo n.º 12
0
        [pitch[0], pitch[-1]])
    ax_nocoll_rz.scatter([orb_nocoll['r'][ind][0], orb_nocoll['r'][ind][-1]],
                         [orb_nocoll['z'][ind][0], orb_nocoll['z'][ind][-1]],
                         color='k')
    ax_Emu.scatter([dE[0], dE[-1]], [mu[0], mu[-1]], color='k', marker='x')
    plot_tips.plot_tips(fnocoll, ind, ax_tips_rz, label='No Coll')

for i in [ax_coll_rhopitch, ax_nocoll_rhopitch]:
    i.set_xlim([0, 1.2])
    i.set_ylim([-1., 1.])
    i.grid('on')

for i in [ax_coll_rz, ax_nocoll_rz]:
    i.set_xlim([1.5, 4.5])
    i.set_ylim([-3., 3.])
    i.grid('on')

limit_labels(ax_coll_rhopitch, 'rho', 'pitch', 'Coll')
limit_labels(ax_nocoll_rhopitch, 'rho', 'pitch')
limit_labels(ax_nocoll_rz, 'r', 'z')
limit_labels(ax_coll_rz, 'r', 'z', 'Coll')
limit_labels(axcompare, 'r', 'z')
limit_labels(ax_Emu, 'E [eV]', 'mu')
#axcompare.legend(loc='best')
ax_tips_rz.legend(loc='best')
ax_tips_rz.axis('equal')
f.tight_layout()
f2.tight_layout()
f3.tight_layout()

plt.show()
Exemplo n.º 13
0
f.tight_layout()

###################
# Power gi, ge
###################
f = plt.figure(figsize=(10, 8))
axp = f.add_subplot(111)
f = plt.figure()
axf = f.add_subplot(111, sharex=axp)
_plot_1d(t, pe * 1e-3, ax=axp, color='k', label=r'e')
_plot_1d(t, pi * 1e-3, ax=axp, color='r', label=r'i')
_plot_1d(t, pe / (pe + pi) * 100., ax=axf, color='k', label=r'e')
_plot_1d(t, pi / (pe + pi) * 100., ax=axf, color='r', label=r'i')
axf.plot(t, g * 1e2, 'c', lw=2.3, label=r'G')

limit_labels(axp, r'Time [s]', r'P[kW]', '')
limit_labels(axf, r'Time [s]', r'%', '')
axp.set_ylim([0, 220])
axf.set_ylim([30., 65.])
axf.legend(loc='best')
f.tight_layout()

###################
# Power deposition profiles (pe, pi, nf/ntot)
###################

f = plt.figure(figsize=(18, 6))
axi = f.add_subplot(131)
axe = f.add_subplot(132)
axn = f.add_subplot(133)
labs = [r't=0.9 s', r't=1.25 s']
Exemplo n.º 14
0
f1=plt.figure()
axn0=f1.add_subplot(111)
axn0.plot(n0data[:,0], n0data[:,1], 'k', label='Exp.', lw=2.3)

wtot=np.array([])
n0=np.array([])
time=np.array([])
for i, key in enumerate(['1','2','3','4']):
    o=te.transp_exp(data[key]['fname'])
    if key=='1':
        tth, wth = o.t, o.wth
    o._calculate_wmhd()
    timet=data[key]['time']
    it = np.logical_and(o.t<timet[1], o.t>timet[0])
    time = np.append(time, o.t[it])                     
    wtot = np.append(wtot, o.wtot[it])
    o._calculate_n0()
    n0 = np.append(n0, o.n0_tot[it, -1])
ax.plot(time, wtot*1e-3, 'r', lw=2.3, label='Simulation, total')
ax.plot(tth, wth*1e-3, 'r--', lw=2.3, label='Simulation, thermal')
axn0.plot(time, n0*1e6, 'r', lw=2.3, label='Simulation')
    
limit_labels(ax, r'Time (s)', r'Energy [kJ]')
ax.legend(loc='best', fontsize='medium')
limit_labels(axn0, r'Time (s)',r'n$_0^{edge}$ [1/m$^3$]')
axn0.legend(loc='best', fontsize='medium')
f1.tight_layout()

ax.grid('on')
plt.show()
Exemplo n.º 15
0
                   color=col[np.mod(i, 5)],
                   marker='o')
    plot_tips.plot_tips(fgc, ind, ax_tips_rz, label='No Coll')

for i in [ax_go_rhopitch]:
    i.set_xlim([0.1, 1.2])
    i.set_ylim([-1., 1.])
    i.grid('on')
ax_gc_rhopitch.grid('on')

for i in [ax_go_rz, ax_gc_rz]:
    i.set_xlim([1.5, 4.5])
    i.set_ylim([-3., 3.])
    i.grid('on')

limit_labels(ax_go_rhopitch, 'rho', 'pitch', 'go')
limit_labels(ax_gc_rhopitch, 'rho', 'pitch', 'gc')

limit_labels(ax_gc_rz, 'r', 'z', 'gc')
limit_labels(ax_go_rz, 'r', 'z', 'go')

limit_labels(axcompare, 'r', 'z')
#limit_labels(ax_Emu, 'E [eV]', '$\mu$')
limit_labels(ax_pphimu, '$P_{\phi}$', '$\mu$')
limit_labels(ax_Emu, 'E', '$\mu$')

#axcompare.legend(loc='best')
ax_tips_rz.legend(loc='best')
ax_tips_rz.axis('equal')
ax_gc_rz.axis('equal')
ax_go_rz.axis('equal')
Exemplo n.º 16
0
def plot_tcv_eq(s, f=0):
    """
    """
    au.common_style()
    flag_leg = 1
    ls = '-'
    if not isinstance(f, matplotlib.figure.Figure):
        f = plt.figure(figsize=(12, 10))
        axj = f.add_subplot(221)
        axp = f.add_subplot(222)
        axf = f.add_subplot(223)
        axc = f.add_subplot(224)
        axq = axf.twinx(
        )  # instantiate a second axes that shares the same x-axis
        axff = axc.twinx()
    else:
        axj, axp, axf, axc, axq, axff = f.axes
        flag_leg = 0
        ls = '--'

    axj.plot(s['jbs']['x'],
             s['jbs']['y'] * 1e-3,
             'r',
             label=r'BS',
             lw=2.,
             linestyle=ls)

    axp.plot(s['p']['x'],
             s['p']['y'],
             'k',
             label=r'Total exp',
             lw=2.,
             linestyle=ls)
    axf.plot(s['torflux']['x'],
             s['torflux']['y'],
             'b',
             label=r'Tor. Flux',
             lw=2.,
             linestyle=ls)
    axf.plot(s['polflux']['x'],
             s['polflux']['y'] * 10.,
             'k',
             label=r'Pol. Flux x 10',
             lw=2.,
             linestyle=ls)

    axq.plot(s['q']['x'], s['q']['y'], 'r', label=r'q', lw=2., linestyle=ls)
    axq.plot([0, 1], [1, 1], 'r--')
    axq.set_ylim([0, 10])
    axf.set_ylim([0, 0.5])

    axc.plot(s['i']['x'],
             s['i']['y'] * 1e-3,
             'ko',
             label=r'EXP CUR',
             lw=2.,
             linestyle=ls)
    axff.plot(s['f']['x'],
              s['f']['y'],
              'r^',
              label=r'EXP F',
              lw=2.,
              linestyle=ls)
    axff.legend(loc='lower left')
    #========================================================
    # SET TICK LOCATION
    #========================================================
    if flag_leg == 1:
        axq.tick_params(axis='y', labelcolor='r')
        axq.set_ylabel(r'q', color='r')
        axff.tick_params(axis='y', labelcolor='r')
        au.limit_labels(axj, r'$\rho_{TOR}$', r'j [kA/m$^2$]', '')
        au.limit_labels(axp, r'$\rho_{TOR}$', r'p [kPa]', '')
        axf.set_xlabel(r'$\rho_{TOR}$')
        axf.set_ylabel(r'Fluxes (Wb/rad)')
        axj.legend(loc='best')
        axf.legend(loc='upper left')
        axf.grid('on')
        axp.legend(loc='upper right')
        axp.grid('on')
        axc.legend(loc='upper right')
        axc.grid('on')
        au.limit_labels(axc, r'$t [s]$', r'I [kA]', '')
        f.tight_layout()
        f.subplots_adjust(top=0.9)
    else:
        axq.set_yticklabels([])

        #if titles.get_text() == '':
        #f.suptitle('{} t={:.2f} s'.format(to.fname[-12:-4], time))
        #else:
        #newtitle = title+' {}'.format(to.fname[-12:-4])
        #    titles.set_text(newtitle)
    #except:
    #f.suptitle('{} t={:.2f} s'.format(to.fname[-12:-4], time))

    plt.show()
Exemplo n.º 17
0
    except:
        continue

    
for i in [ax_coll_rhopitch]:
    i.set_xlim([0.1,1.2])
    i.set_ylim([-1., 1.])
    i.grid('on')
ax_nocoll_rhopitch.grid('on')  

for i in [ax_coll_rz, ax_nocoll_rz]:
    i.set_xlim([1.5, 4.5])
    i.set_ylim([-3., 3.])
    i.grid('on')   

limit_labels(ax_coll_rhopitch, 'rho', 'pitch', 'Coll')
#limit_labels(ax_nocoll_rhopitch, 'rho', 'pitch')
#limit_labels(ax_nocoll_rz, 'r', 'z')
limit_labels(ax_coll_rz, 'r', 'z', 'Coll')
limit_labels(axcompare, 'r', 'z')
limit_labels(ax_Emu, 'E [eV]', '$\mu$')
limit_labels(ax_pphimu, '$P_{\phi}$', '$\mu$')

#axcompare.legend(loc='best')
ax_tips_rz.legend(loc='best'); ax_tips_rz.axis('equal')
ax_nocoll_rz.axis('equal'); ax_coll_rz.axis('equal'); 
f.tight_layout()    
#f2.tight_layout()
#f3.tight_layout()  

plt.show()