Files
katrin-plasma/src/mcelectron-analysis/functions/archive/old_plot_script.ipynb
T

30 KiB

In [1]:
import numpy as np
import pandas as pd
import os as os

import scipy.optimize as optimization
import glob as glob
import h5py as h5py
import numpy as np
from scipy.signal import argrelextrema
In [2]:
import matplotlib.pyplot as plt
%matplotlib inline

import seaborn as sns

NEJM = sns.color_palette(palette = ['#bc3c29',
 '#0072bf',
 '#e18727',
 '#20854e',
 '#7876b1',
 '#6f99ad',
 '#ffdc91',
 '#ee4c97'])
sns.set(
    context='paper', 
    style='white', 
    palette=NEJM, 
    font='sans-serif', 
    font_scale=1, 
    color_codes=False, 
    rc = {'figure.dpi' : 100,
        'text.usetex' : True,
        'axes.labelsize' : 10,
        'xtick.labelsize' : 10, 
        'ytick.labelsize' : 10,
        'legend.fontsize' : 10,
        'xtick.bottom' : True, 
        'xtick.minor.bottom' : False,
        'ytick.left' : True,
        'ytick.minor.left' : False
        })
In [3]:
%run "../functions/particles/load_histograms.py"
%run "../functions/populations/h5_loadpop.py"
ERROR:root:File `'../functions/particles/load_histograms.py'` not found.
ERROR:root:File `'../functions/populations/h5_loadpop.py'` not found.
In [4]:
# Load dfs with population data and create df with sum over E_bins
dfs_pop = load_pop(f)
---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-4-bf17c6a9ae9c> in <module>
      1 # Load dfs with population data and create df with sum over E_bins
----> 2 dfs_pop = load_pop(f)

NameError: name 'load_pop' is not defined
In [5]:
dfs_pop_E_summed = sum_E_bins(dfs_pop)
---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-5-26a20512a96e> in <module>
----> 1 dfs_pop_E_summed = sum_E_bins(dfs_pop)

NameError: name 'sum_E_bins' is not defined
In [6]:
# Load df with meaned for each time step
dfs_time_means = calc_time_means(dfs_pop_E_summed)
---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-6-381ccb5fefdd> in <module>
      1 # Load df with meaned for each time step
----> 2 dfs_time_means = calc_time_means(dfs_pop_E_summed)

NameError: name 'calc_time_means' is not defined
In [7]:
# Plot time expansion
fig, ax = plt.subplots()
plot_time_means(dfs_time_means, ax)
ax.set_title('Averaged densities time development.')
#ax.axvline(x=calc_simulation_time_s(1000),linewidth=2, color='black')
fig.show()
---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-7-4a68902e573a> in <module>
      1 # Plot time expansion
      2 fig, ax = plt.subplots()
----> 3 plot_time_means(dfs_time_means, ax)
      4 ax.set_title('Averaged densities time development.')
      5 #ax.axvline(x=calc_simulation_time_s(1000),linewidth=2, color='black')

NameError: name 'plot_time_means' is not defined
In [8]:
# Load df with meaned values for each z_bin
dfs_z_means = calc_z_means(dfs_pop_E_summed)
---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-8-e2e81d82aa38> in <module>
      1 # Load df with meaned values for each z_bin
----> 2 dfs_z_means = calc_z_means(dfs_pop_E_summed)

NameError: name 'calc_z_means' is not defined
In [9]:
# Plot z expansion
fig, ax = plt.subplots()
plot_z_means(dfs_z_means, ax)
ax.axvline(x=5,linewidth=1, color='black', linestyle = ':')
ax.set_title('Densities over z')
fig.show()
---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-9-2a30b258a9ba> in <module>
      1 # Plot z expansion
      2 fig, ax = plt.subplots()
----> 3 plot_z_means(dfs_z_means, ax)
      4 ax.axvline(x=5,linewidth=1, color='black', linestyle = ':')
      5 ax.set_title('Densities over z')

NameError: name 'plot_z_means' is not defined
In [ ]:
# Load rw_df 
rw_df = calc_rwcurrents(f, n_decays = n_decays)
In [ ]:
%run '../functions/particles/calc_rwcurrent.py'
In [ ]:
# Plot rw current
fig, ax = plt.subplots()
plot_exp_rw(ax)
plot_rw_df(rw_df, ax)
ax.set_title('Rear wall current vs voltage')
fig.show()
In [10]:
# Load df_spec
df_spec = calc_pop_spectrum(dfs_pop)
---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-10-a7eb88677b24> in <module>
      1 # Load df_spec
----> 2 df_spec = calc_pop_spectrum(dfs_pop)

NameError: name 'calc_pop_spectrum' is not defined
In [ ]:
# Plot Spectrum from populations data
fig, ax = plt.subplots()
plot_pop_spectrum(df_spec, ax)
ax.set_title('Energy Spectrum from Population data')
fig.show()
In [ ]:
dfs_part = load_part(f)
hists = calc_histogram(dfs_part, calc_simulation_time_s(10000))
In [ ]:
# Plot histograms
hist = hists['e-']
fig, ax = plt.subplots()
plot_fermi(ax, n_decays)
plot_hist(hist, ax)
ax.set_title('Histograms')
fig.show()
In [ ]:
# Calc df_curs
time_s = calc_simulation_time_s(n_decays)
n_rbins = 9
dfs_curs = calc_dfs_curs(dfs_part, n_rbins, time_s)
In [ ]:
# Plot current_means
fig, ax = plt.subplots()
plot_cur_means(dfs_curs, ax)
ax.axvline(x=5,linewidth=1, color='black', linestyle = ':')
ax.set_title('Particle density current')
fig.show()
In [ ]:
max_cur = get_max_cur(dfs_curs)
In [11]:
# Plot current maps
max_cur = get_max_cur(dfs_curs)
for s in dfs_curs:
    [z, r, j] = calc_mesh_data(dfs_curs[s])
    fig, ax = plt.subplots()
    plot_mesh(z, r, j, max_cur, ax, fig)
    ax.axvline(x=5,linewidth=1, color='black', linestyle = ':')
    ax.set_title(s + ' current density spatially resolved')
    fig.show()
---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-11-f252d937e215> in <module>
      1 # Plot current maps
----> 2 max_cur = get_max_cur(dfs_curs)
      3 for s in dfs_curs:
      4     [z, r, j] = calc_mesh_data(dfs_curs[s])
      5     fig, ax = plt.subplots()

NameError: name 'get_max_cur' is not defined
In [12]:
# Plot ion currents
max_cur = get_max_cur(dfs_curs)
z_all = []
r_all = []
j_all = []
for s in dfs_curs:
    if s != 'e-':
        [z, r, j] = calc_mesh_data(dfs_curs[s])
        z_all.append(z)
        r_all.append(r)
        j_all.append(j)
z_mean = np.mean(z_all,axis=0)
r_mean = np.mean(r_all,axis=0)
j_sum = np.sum(j_all,axis=0)

fig, ax = plt.subplots()
plot_mesh(z_mean, r_mean, j_sum, max_cur, ax, fig)
ax.axvline(x=5,linewidth=1, color='black', linestyle = ':')
ax.set_title('Summed Ion current density spatially resolved')
fig.show()
---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-12-d2b1210a8e1f> in <module>
      1 # Plot ion currents
----> 2 max_cur = get_max_cur(dfs_curs)
      3 z_all = []
      4 r_all = []
      5 j_all = []

NameError: name 'get_max_cur' is not defined
In [13]:
def load_rwdata(h5_file):
    h5_file['Particles']
    rwdata = dict()
    for species in list(h5_file['Particles'].keys()):
        try:
            df = load_part(h5_file, species=species, z='-3.000000')
            rwdata.update({species:df})
        except:
            pass
    return rwdata
In [14]:
rw_data = load_rwdata(f)
---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-14-87a2a61eb15a> in <module>
----> 1 rw_data = load_rwdata(f)

NameError: name 'f' is not defined
In [15]:
ion_cur = 0
for s in rw_data:
    if get_Z(s) > 0:
        ion_cur = ion_cur + get_Z(s)*rw_data[s].shape[0]
---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-15-4ad9fff83913> in <module>
      1 ion_cur = 0
----> 2 for s in rw_data:
      3     if get_Z(s) > 0:
      4         ion_cur = ion_cur + get_Z(s)*rw_data[s].shape[0]

NameError: name 'rw_data' is not defined
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]: