def __init__(self, shot): self.shot = shot # load the geometry self._geometry() # open the shotfile self.Ioc = dd.shotfile('IOC', self.shot) # read and create the attribute dictionary self._read() # close all the stuff self.Ioc.close() # open and read available gas information self.Uvs = dd.shotfile('UVS', self.shot) self._valves() self._readGas() self.Uvs.close() # now the directory where eventually the neutrals resides try: _path = os.path.abspath( os.path.join( os.path.join(__file__, '../../../..'), 'Experiments/AUG/analysis/data/neutrals/%5i' % self.shot)) data = numpy.load(_path + '/n0_avg.npy') self.n0 = data[:, 0] self.n0Err = data[:, 1] self.n0Time = numpy.loadtxt(_path + '/time_brillanza.txt') except: logging.warning('File not found') pass # now also the equilibrium since it will be useful for # the plot of gauges and valves location self.Eq = equilibrium.equilibrium(device='AUG', time=2, shot=self.shot) self.rg, self.zg = map_equ.get_gc()
def plotGeometry(self, time=3): """ Plot the geometry of the different LOS in the divertor region with the corresponding equilibrium. """ self.Eq.set_time(time) rVessel, zVessel = map_equ.get_gc() fig, ax = mpl.pylab.subplots(figsize=(10, 8), nrows=1, ncols=1) fig.subplots_adjust(right=0.8) for key in rVessel.iterkeys(): ax.plot(rVessel[key], zVessel[key], 'k', lw=1.5) ax.contour(self.Eq.R, self.Eq.Z, self.Eq.psiN, np.linspace(0.1, 0.95, num=10), colors='grey', linestyles='-') ax.contour(self.Eq.R, self.Eq.Z, self.Eq.psiN, [1], colors='r', linewidths=2) ax.contour(self.Eq.R, self.Eq.Z, self.Eq.psiN, np.linspace(1.01, 1.05, num=4), colors='grey', linestyles='--') # adess facciamo il ciclo sulle LoS salvate e # costruiamo una legenda a dx ax.set_color_cycle(palettable.tableau.Tableau_20.mpl_colors) for name in self.Los.iterkeys(): ax.plot([self.Los[name]['R1'], self.Los[name]['R2']], [self.Los[name]['Z1'], self.Los[name]['Z2']], label=name, lw=2) ax.legend(loc='upper center', numpoints=1, frameon=False, bbox_to_anchor=(0.5, 1.2), fontsize=14, ncol=3) ax.set_aspect('equal') ax.set_xlim([0.7, 2.]) ax.set_ylim([-1.5, -0.5])
def _loadeq(self): # loading the equilibrium self.Eqm = map_equ.equ_map() status = self.Eqm.Open(self.shot, diag='EQH') self.Eqm._read_scalars() self.Eqm._read_profiles() self.Eqm._read_pfm() # load the wall for aug self.rg, self.zg = map_equ.get_gc() self._psi = self.Eqm.pfm.transpose() self._time_array = self.Eqm.t_eq nr = self._psi.shape[0] nz = self._psi.shape[1] self._r = self.Eqm.Rmesh self._z = self.Eqm.Zmesh self._psi_axis = self.Eqm.psi0 self._psi_bnd = self.Eqm.psix # get the fpol in similar way # as done in eqtools self._jpol = self.Eqm.jpol # these are the lower xpoints self._rxpl = self.Eqm.ssq['Rxpu'] self._zxpl = self.Eqm.ssq['Zxpu'] # read also the upper xpoint self._rxpu = self.Eqm.ssq['Rxpo'] self._zxpu = self.Eqm.ssq['Zxpo'] # R magnetic axis self._axisr = self.Eqm.ssq['Rmag'] # Z magnetic axis self._axisz = self.Eqm.ssq['Zmag'] # eqm does not load the RBphi on axis Mai = dd.shotfile('MAI', self.shot) self.Rcent = 1.65 # we want to interpolate on the same time basis Spl = UnivariateSpline(Mai('BTF').time, Mai('BTF').data, s=0) self._bphi = Spl(self._time_array) * self.Rcent Mai.close() Mag = dd.shotfile('MAG', self.shot) Spl = UnivariateSpline(Mag('Ipa').time, Mag('Ipa').data, s=0) self._cplasma = Spl(self._time_array) # we want to load also the plasma curent # now define the psiN self._psiN = (self._psi-self._psi_axis[:, np.newaxis, np.newaxis])/ \ (self._psi_bnd[:, np.newaxis, np.newaxis]-self._psi_axis[:, np.newaxis, np.newaxis])
def plot_flux(self, col_levels=None, Nlines=20, axes=None, show=True, title=None, colorbar=True): from copy import deepcopy as copy """ Contour plot of the equilibrium poloidal flux keywords: t = int time index to plot flux at col_levels = [] array storing contour levels for color plot Nlines = int number of contour lines to display """ import matplotlib.pyplot as plt #Set contour levels if self.psi is not None: if col_levels is None: col_levels = np.linspace(np.min(self.psi), np.max(self.psi), 100) if axes is None: axes = plt.gca() else: show = False im = axes.contourf(self.R, self.Z, self.psi, levels=col_levels) if colorbar: cbar = plt.colorbar(im, format='%.3f', ax=axes) axes.contour(self.R, self.Z, self.psi, Nlines, colors='k') axes.contour(self.R, self.Z, self.psi, [self.psi_bnd], colors='r', linewidth=1.5) axes.set_xlim(np.min(self.R), np.max(self.R)) axes.set_ylim(np.min(self.Z), np.max(self.Z)) if self.wall is not None: axes.plot(self.wall['R'], self.wall['Z'], '-g', linewidth=2) if self.xpoints: for xpoint in self.xpoints: axes.plot(self.xpoints[xpoint].r, self.xpoints[xpoint].z, 'rx') if self.axis is not None: axes.plot(self.axis.r, self.axis.z, 'ro') if self.machine == 'AUG': rg, zg = map_equ.get_gc() for key in rg.iterkeys(): axes.plot(rg[key], zg[key], 'k') axes.set_xlabel('R (m)') axes.set_ylabel('Z (m)') if title is not None: axes.set_title(title) if colorbar: cbar.ax.set_ylabel('$\psi$') axes.set_aspect('equal') if show: plt.show() else: print( "ERROR: No poloidal flux found. Please load an equilibrium before plotting.\n" )
def plotTimeTraces(self, trange=[0, 7]): """ This produce a plot of all the collected signal divided into two groups together with the evolution of H-5N and of the fueling. This will be combined also with the equilibrium with the same color code of the LoS """ fig = mpl.pylab.figure(figsize=(14, 10)) ax = mpl.pylab.subplot2grid((4, 2), (0, 0), rowspan=2) self.Eq.set_time(3) rVessel, zVessel = map_equ.get_gc() for key in rVessel.iterkeys(): ax.plot(rVessel[key], zVessel[key], 'k', lw=1.5) ax.contour(self.Eq.R, self.Eq.Z, self.Eq.psiN, np.linspace(0.1, 0.95, num=10), colors='grey', linestyles='-') ax.contour(self.Eq.R, self.Eq.Z, self.Eq.psiN, [1], colors='r', linewidths=2) ax.contour(self.Eq.R, self.Eq.Z, self.Eq.psiN, np.linspace(1.01, 1.05, num=4), colors='grey', linestyles='--') # adess facciamo il ciclo sulle LoS salvate e # costruiamo una legenda a dx ax.set_color_cycle(palettable.tableau.Tableau_20.mpl_colors) for name in self.Los.iterkeys(): ax.plot([self.Los[name]['R1'], self.Los[name]['R2']], [self.Los[name]['Z1'], self.Los[name]['Z2']], label=name, lw=2) ax.legend(loc='upper center', numpoints=1, frameon=False, bbox_to_anchor=(0.5, 1.2), fontsize=14, ncol=3) ax.set_aspect('equal') ax.set_xlim([0.7, 2.]) ax.set_ylim([-1.5, -0.5]) # now plot the rest including fueling and density ax1 = mpl.pylab.subplot2grid((4, 2), (0, 1)) ax1.plot(self._Dcn('H-5').time, self._Dcn('H-5').data / 1e19, 'k', lw=2, label=r'# %5i' % self.shot) ax1.set_ylabel(r'$\overline{n}_e$ H-5 [10$^{19}$]') ax1.set_xlabel(r't [s]') ax1.set_xlim(trange) ax2 = mpl.pylab.subplot2grid((4, 2), (1, 1)) ax2.plot(self._Uvs('D_tot').time, self._Uvs('D_tot').data / 1e21, 'k', lw=2, label=r'# %5i' % self.shot) ax2.set_ylabel(r'D$_2 [10^{21}$ e/s]') ax2.set_xlabel(r't [s]') ax2.set_xlim(trange) ax3 = mpl.pylab.subplot2grid((4, 2), (2, 1), rowspan=2) ax3.set_color_cycle(palettable.tableau.Tableau_20.mpl_colors) for name in self.Los.iterkeys(): ax3.plot(self.time, self.Los[name]['data'] / 1e20, label=name, lw=2) ax3.set_xlabel('t[s]') ax3.set_ylabel(r'n$_e [10^{20}$ m$^{-3}$]') ax3.set_ylim([0, 3]) ax3.set_xlim(trange)
t = 5.33,#s color = 'b','g' rho = np.linspace(0,2,101) R,Z = eqm.rho2rz( rho, t, all_lines=True) print(len(R)) for r,z,c in zip(R,Z,color): for rc,zc in zip(r,z): plt.plot(rc,zc,c) R,Z = eqm.rhoTheta2rz( np.linspace(0,1,51),np.linspace(-np.pi,np.pi,1000), t) plt.plot(R[0],Z[0],'r') Rv,Zv = get_gc() for key in list(Rv.keys()): plt.plot(Rv[key],Zv[key]) plt.axis('equal') plt.show() eqm._read_pfm() eqm._read_profiles() eqm._read_scalars() rho = np.linspace(0,0.98,100) q = eqm.getQuantity(rho, 'Qpsi', 2)[0]
ax[2, 1].set_xlim(_xlim) ax[2, 1].set_ylim([0, 1.2e3]) ax[3, 1].plot(iD2.time, iD2.data / 1e21, col, ls='-', lw=1.7, label=r'Shot # %5i' % shot) ax[3, 1].set_xlabel(r't [s]') ax[3, 1].set_ylabel(r'D$_{2} [10^{21}]$') ax[3, 1].set_xlim(_xlim) # ora plottiamo l'equilibrio in un asse a parte if i == 0: rg, zg = map_equ.get_gc() for key in rg.iterkeys(): axE.plot(rg[key], zg[key], 'k') axE.contour(Eq.R, Eq.Z, Eq.psiN(Eq.R, Eq.Z), np.linspace(0, 1, 5), colors=col) axE.contour(Eq.R, Eq.Z, Eq.psiN(Eq.R, Eq.Z), np.linspace(1, 1.09, 3), colors=col, linestyles='--') axE.set_xlabel('R') axE.set_ylabel('Z')