This repository has been archived by the owner on Mar 10, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
cross_sectional_area_boxplot.py
66 lines (38 loc) · 1.68 KB
/
cross_sectional_area_boxplot.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# This code transforms .csv data of cross-sectional damage foci areas into a boxplot.
import pandas as pd
import matplotlib.pyplot as plt
from matplotlib import rc
import numpy as np
# region Typesetting of plots
rc('text', usetex=True)
# endregion
# region Importing data
alpha_sim_data = pd.read_csv('.csv file containg cross-sectional areas', delimiter=';')
alpha_exp_data = pd.read_csv('.csv file containg cross-sectional areas')
alpha_sim_data = alpha_sim_data.loc[:, ~alpha_sim_data.columns.str.contains('^Unnamed')]
alpha_exp_data = alpha_exp_data.loc[:, ~alpha_exp_data.columns.str.contains('^Unnamed')]
# endregion
# region Sampling simulated dataset and processing experimental data
sample_times = 1
sampled_data_table = []
all_data = pd.DataFrame()
for i in range(sample_times):
random_sample = np.random.randint(1, len(alpha_sim_data), 100)
sampled_data = np.zeros(len(alpha_sim_data), float)
for j in range(len(random_sample)):
sampled_data[j] = list(alpha_sim_data['5000 simulated events'])[random_sample[j]]
sampled_data = [np.nan if x == 0 else x for x in sampled_data]
sampled_data_process = list(filter(lambda v: v==v, sampled_data))
sampled_data_table.append(sampled_data_process)
all_data['Sampled simulation data (n = 100)'] = sampled_data
sampled_data_table = np.asarray(sampled_data_table)
all_data['Experiment 0.5 Gy data (n = 233)'] = alpha_exp_data
# endregion
# region Saving data and outputting plot
np.savetxt('sampled_data_table.csv', sampled_data_table, delimiter=',')
all_data.boxplot()
plt.grid(None)
plt.ylabel('Cross-sectional area ($\mu$m$^2$)')
#plt.savefig('Figure_6_xray_foci_boxplot.pdf')
plt.show()
# endregion