Plot density radially
This commit is contained in:
@@ -0,0 +1,62 @@
|
||||
import numpy as np
|
||||
import h5py as h5py
|
||||
import os
|
||||
import sys
|
||||
import matplotlib
|
||||
import matplotlib.pyplot as plt
|
||||
|
||||
from functions.calculate_density_from_karl import *
|
||||
import functions.plot_standards as pst
|
||||
|
||||
def makeBarPlotData(data, mins, maxs):
|
||||
plot_bins = np.dstack((mins,maxs)).flatten()
|
||||
plot_datas = np.dstack((data,data)).flatten()
|
||||
return plot_bins, plot_datas
|
||||
|
||||
def plotAllDensityVsR(filename, filename_output, z_bin):
|
||||
keys = ["/Populations/e-/e-", "/Populations/T+/T+", "/Populations/T2+/T2+", "/Populations/T3+/T3+"]
|
||||
|
||||
rmins = getRBinsMin(filename, keys[0])
|
||||
rmaxs = getRBinsMax(filename, keys[0])
|
||||
|
||||
print("Get Density: e-")
|
||||
total_density_e = np.sum(getDensities(filename, keys[0])[z_bin, :, 0,:],1)
|
||||
|
||||
print("Get Density: T+")
|
||||
total_density_T = np.sum(getDensities(filename, keys[1])[z_bin, :, 0,:],1)
|
||||
print("Get Density: T2+")
|
||||
total_density_T2 = np.sum(getDensities(filename, keys[2])[z_bin, :, 0,:],1)
|
||||
print("Get Density: T3+")
|
||||
total_density_T3 = np.sum(getDensities(filename, keys[3])[z_bin, :, 0,:],1)
|
||||
|
||||
|
||||
pst.setRcParams()
|
||||
prop_cycle = plt.rcParams['axes.prop_cycle']
|
||||
colors = prop_cycle.by_key()['color']
|
||||
|
||||
fig, ax = plt.subplots(figsize=pst.set_size('thesis'))
|
||||
|
||||
plot_bins, plot_data = makeBarPlotData(total_density_e, rmins, rmaxs)
|
||||
ax.plot(plot_bins - plot_bins[0], plot_data/1E6,'-', label="e-")
|
||||
|
||||
plot_bins, plot_data = makeBarPlotData(total_density_T3, rmins, rmaxs)
|
||||
ax.plot(plot_bins - plot_bins[0], plot_data/1E6, '--', label=r'T$^+_3$')
|
||||
|
||||
plot_bins, plot_data = makeBarPlotData(total_density_T, rmins, rmaxs)
|
||||
ax.plot(plot_bins - plot_bins[0], plot_data/1E6, '-.', label=r'T$^+_2$')
|
||||
|
||||
plot_bins, plot_data = makeBarPlotData(total_density_T2, rmins, rmaxs)
|
||||
ax.plot(plot_bins - plot_bins[0], plot_data/1E6, ':', label=r'T$^+$')
|
||||
|
||||
ax.set_yscale("log")
|
||||
ax.set_xlabel(r"Radius $r$ [m]")
|
||||
ax.set_ylabel(r"Density $n$ [$cm^{-3}$]")
|
||||
|
||||
ax.set_facecolor('#e7e7e7ff')
|
||||
ax.grid(color='white')
|
||||
|
||||
ax.legend(loc=(0.85, 0.15))
|
||||
#ax.legend(loc="lower right")
|
||||
|
||||
fig.savefig(filename_output, format='pdf', bbox_inches='tight')
|
||||
plt.show()
|
||||
Binary file not shown.
Reference in New Issue
Block a user