Skip to content

Commit

Permalink
Fixed data_plot string formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
jcandy committed Nov 29, 2024
1 parent e1f2958 commit cd4ff29
Showing 1 changed file with 21 additions and 21 deletions.
42 changes: 21 additions & 21 deletions f2py/pygacode/cgyro/data_plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,7 @@ def plot_flux(self,xin):
# Now, ys -> {n_species,3,nt}

if moment == 'n':
mtag = '\Gamma'
mtag = r'\Gamma'
ttag = 'G'
ftag = 'flux_n'
y = ys[:,0,:]
Expand All @@ -493,7 +493,7 @@ def plot_flux(self,xin):
y = ys[:,1,:]/self.qc
elif moment == 'v':
# JC: correct for other norms?
mtag = '\Pi'
mtag = r'\Pi'
ttag = 'Pi'
ftag = 'flux_v'
y = ys[:,2,:]
Expand All @@ -512,7 +512,7 @@ def plot_flux(self,xin):
mnorm = ''
else:
norm_vec = 1.0/self.dens
mnorm = '^\mathrm{norm}'
mnorm = r'^\mathrm{norm}'

color = ['k','m','b','c','g','r']

Expand All @@ -532,7 +532,7 @@ def plot_flux(self,xin):
ave = time_average(y_norm,t,imin,imax)
y_ave = ave*np.ones(len(t))
u = specmap(self.mass[ispec],self.z[ispec])
label = r'$'+mtag+mnorm+'_\mathrm{'+u+'}/'+mtag+self.gbnorm+': '+str(round(ave,3))+'$'
label = r'$'+mtag+mnorm+r'_\mathrm{'+u+'}/'+mtag+self.gbnorm+': '+str(round(ave,3))+'$'
if not ftype == 'nox':
# Average
ax.plot(t[imin:imax+1],y_ave[imin:imax+1],'--',color=color[ispec])
Expand Down Expand Up @@ -612,7 +612,7 @@ def plot_ky_flux(self,xin):
ys = self.ky_flux[:,:,field,:,:]

if moment == 'n':
mtag = '\Gamma'
mtag = r'\Gamma'
ttag = 'G'
ftag = 'flux_n'
y = ys[:,0,:,:]
Expand All @@ -622,7 +622,7 @@ def plot_ky_flux(self,xin):
ftag = 'flux_e'
y = ys[:,1,:,:]/self.qc
elif moment == 'v':
mtag = '\Pi'
mtag = r'\Pi'
ttag = 'Pi'
ftag = 'flux_v'
y = ys[:,2,:,:]
Expand Down Expand Up @@ -668,7 +668,7 @@ def plot_ky_flux(self,xin):
ax = fig.add_subplot(nrow,ncol,ispec+1)

ax.set_xlabel(self.kystr)
ax.set_ylabel(r'$'+mtag+'_\mathrm{'+u+'}/'+mtag+self.gbnorm+'$',color='k')
ax.set_ylabel(r'$'+mtag+r'_\mathrm{'+u+'}/'+mtag+self.gbnorm+'$',color='k')

if ispec < ncol:
ax.set_title(mpre+mwin,fontsize=16)
Expand Down Expand Up @@ -757,7 +757,7 @@ def absexp(x,tau):
# calculate envelope
corr_hilbert = signal.hilbert(corr)
corr_env = np.abs(corr_hilbert)
ax.set_ylabel(r'$C_{'+ft+'}(\Delta r)$',color='k')
ax.set_ylabel(r'$C_{'+ft+r'}(\Delta r)$',color='k')
ax.plot(delta_r,0*delta_r,color='k',ls='--')
ax.plot(delta_r,corr,color=color[0])

Expand Down Expand Up @@ -995,7 +995,7 @@ def plot_zf(self,xin):
gfactor = 1e6*(1-np.i0(k0**2)*np.exp(-k0**2))/(np.i0(k0**2)*np.exp(-k0**2))

y = f[i,:]*gfactor
ax.plot(t,y,label=self.kxstr+'$={:.4f}$'.format(k0))
ax.plot(t,y,label=self.kxstr+r'$={:.4f}$'.format(k0))

#----------------------------------------------------
# Average calculations
Expand Down Expand Up @@ -1048,13 +1048,13 @@ def plot_xflux(self,xin):

if moment == 'n':
ntag = 'Density~flux'
mtag = '\Gamma'
mtag = r'\Gamma'
elif moment == 'e':
ntag = 'Energy~flux'
mtag = 'Q'
elif moment == 'v':
ntag = 'Momentum~flux'
mtag = '\Pi'
mtag = r'\Pi'
else:
print('ERROR: (plot_xflux) Invalid moment.')
sys.exit()
Expand All @@ -1065,7 +1065,7 @@ def plot_xflux(self,xin):

# Rescale with density ratio
if nscale == 1:
mnorm = '^\mathrm{norm}'
mnorm = r'^\mathrm{norm}'
else:
mnorm = ''

Expand All @@ -1081,7 +1081,7 @@ def plot_xflux(self,xin):
imin,imax = time_index(t,w)
mpre,mwin = wintxt(imin,imax,t)

ax.set_title(r'$\mathrm{'+ntag+'} \quad $'+mwin)
ax.set_title(r'$\mathrm{'+ntag+r'} \quad $'+mwin)

na = 128

Expand All @@ -1097,7 +1097,7 @@ def plot_xflux(self,xin):
for ispec in range(ns):

u = specmap(self.mass[ispec],self.z[ispec])
label = r'$'+mtag+mnorm+'_'+u+'/'+mtag+'_\mathrm{GB}$'
label = r'$'+mtag+mnorm+'_'+u+r'/'+mtag+r'_\mathrm{GB}$'

#---------------------------------
# Global flux versus x
Expand All @@ -1108,7 +1108,7 @@ def plot_xflux(self,xin):
g = np.ones(na)*self.lky_xr[0,ispec]
for l in range(1,ng):
g[:] = g[:]+2*(np.cos(l*a2)*self.lky_xr[l,ispec]-np.sin(l*a2)*self.lky_xi[l,ispec])
ax.plot(r,g,color=color[ispec],linestyle='--',label=label+'$\mathrm{(mirror)}$')
ax.plot(r,g,color=color[ispec],linestyle='--',label=label+r'$\mathrm{(mirror)}$')
#---------------------------------

#---------------------------------
Expand Down Expand Up @@ -1209,7 +1209,7 @@ def plot_kxky_phi(self,xin):

ax.set_xlabel(self.kxstr)
ax.set_ylabel(self.kystr)
ax.set_title(r'$\mathrm{Log} |'+ft+'| \quad $'+mwin)
ax.set_title(r'$\mathrm{Log} |'+ft+r'| \quad $'+mwin)

ax.imshow(y,extent=[xl,xr,0,y0],interpolation='none',cmap='plasma')
print('INFO: (plot_kxky_phi) min={:.2e} max={:.2e}'.format(np.min(y),np.max(y)))
Expand Down Expand Up @@ -1562,7 +1562,7 @@ def plot_hb(self,xin):
#======================================
ax = fig.add_subplot(3,2,p)

ax.set_title(r'${\rm Re} \, h_'+u+' \quad \mathrm{ie}='+str(ie)+'$')
ax.set_title(r'${\rm Re} \, h_'+u+r' \quad \mathrm{ie}='+str(ie)+'$')
ax.set_xlabel(r'$\theta/\pi$')
ax.set_ylabel(r'$\xi = v_\parallel/v$')

Expand All @@ -1587,7 +1587,7 @@ def plot_hb(self,xin):
#======================================
ax = fig.add_subplot(3,2,p)

ax.set_title(r'${\rm Im} \, h_'+u+' \quad \mathrm{ie}='+str(ie)+'$')
ax.set_title(r'${\rm Im} \, h_'+u+r' \quad \mathrm{ie}='+str(ie)+'$')
ax.set_xlabel(r'$\theta/\pi$')
ax.set_ylabel(r'$\xi = v_\parallel/v$')

Expand Down Expand Up @@ -1662,7 +1662,7 @@ def plot_hbcut(self,xin):
ax.grid(which="both",ls=":")
ax.grid(which="major",ls=":")

ax.set_title(r'$'+u+': \\xi=0 \quad \mathrm{ie}='+str(ie)+'$')
ax.set_title(r'$'+u+r': \\xi=0 \quad \mathrm{ie}='+str(ie)+'$')
ax.set_xlabel(r'$\theta/\pi$')

if self.n_xi%2 == 0:
Expand All @@ -1684,7 +1684,7 @@ def plot_hbcut(self,xin):
ax.grid(which="both",ls=":")
ax.grid(which="major",ls=":")

ax.set_title(r'$'+u+': \\theta/\pi='+str(thetapi)+' \quad \mathrm{ie}='+str(ie)+'$')
ax.set_title(r'$'+u+r': \\theta/\pi='+str(thetapi)+r' \quad \mathrm{ie}='+str(ie)+'$')
ax.set_xlabel(r'$\xi = v_\parallel/v$')

n0 = (self.n_radial//2)*self.n_theta+i0
Expand All @@ -1703,7 +1703,7 @@ def plot_hbcut(self,xin):
ax.grid(which="both",ls=":")
ax.grid(which="major",ls=":")

ax.set_title(r'$'+u+': \\theta/\pi='+str(thetapi)+' \quad \mathrm{ix}='+str(ix)+'$')
ax.set_title(r'$'+u+r': \\theta/\pi='+str(thetapi)+r' \quad \mathrm{ix}='+str(ix)+'$')
ax.set_xlabel(r'$x=\sqrt{\varepsilon}$')

n0 = (self.n_radial//2)*self.n_theta+i0
Expand Down

0 comments on commit cd4ff29

Please sign in to comment.