My Project
plotLoadedCI.py
Go to the documentation of this file.
1 from frictionImports import sys, os, plt, np
2 from frictionImports import *
3 
4 python_path = os.path.dirname(os.path.realpath(__file__))
5 
6 colors_diverging_short = ['#d7191c','#fdae61','#ffffbf','#abd9e9','#2c7bb6']
7 colors_diverging_long = ['#a50026','#d73027','#f46d43','#fdae61','#fee090','#ffffbf','#e0f3f8','#abd9e9','#74add1','#4575b4','#313695']
8 colors_qualitative_short = ['#1b9e77','#d95f02','#7570b3','#e7298a','#66a61e']
9 colors_qualitative_long = ['#1b9e77','#d95f02','#7570b3','#e7298a','#66a61e','#e6ab02','#a6761d']
10 linestyles = ['-', '--', '-.', ':']
11 
12 
14  general_path = python_path + "/../../../results/CI_amplitude_plots/"
15  paths = ["average_bk_increase_16_runs.csv", "average_bkp_increase_16_runs.csv", "average_bk_decrease_16_runs.csv", "average_bkp_decrease_16_runs.csv"]
16  labels = ["BK: increase", "BK-Pad: increase", "BK: decrease", "BK-Pad: decrease"]
17  amplitude_files = np.array([np.loadtxt(general_path + path, delimiter = ",") for path in paths])
18 
19  colors = colors_qualitative_long
20 
21  for i, amplitude_file in enumerate(amplitude_files):
22  plt.plot(amplitude_file[0], amplitude_file[1], color=colors[i], label=labels[i], linestyle=linestyles[i])
23  plt.fill_between(amplitude_file[0], amplitude_file[1] + amplitude_file[2], amplitude_file[1] - amplitude_file[2], color = colors[i], alpha=.5)
24 
25  plt.legend(title="Model: run type")
26 
27  if("-log" in sys.argv):
28  plt.xscale('log')
29  plt.show()
30 
31 
32 def frictionLaw(
33  y,
34  sigma=0.01,
35  F_0=1
36 ):
37  phi = F_0 * ((1 - sigma)/(1 + np.abs(y)/(1 - sigma)) * np.sign(y))
38  return phi
39 
40 
41 
43  general_path = python_path + "/../../../results/week_20/average_model_plots/"
44  paths = ["bk_increasing/results/average_16_runs.csv", "bkp_increasing/results/average_16_runs.csv", "bk_decreasing/results/average_16_runs.csv", "bkp_decreasing/results/average_16_runs.csv"]
45  labels = ["BK: inc.", "BK-Pad: inc.", "BK: dec.", "BK-Pad: dec."]
46  amplitude_files = np.array([np.loadtxt(general_path + path, delimiter = ",") for path in paths])
47 
48  colors = colors_qualitative_long
49  ecolors = colors_diverging_long
50  start_index = 0
51 
52 
53 
54  for i, amplitude_file in enumerate(amplitude_files):
55  if(len(amplitude_file) > 3):
56  # plots average of firction value
57  plt.plot(amplitude_file[0], abs(amplitude_file[3]), color=colors[i], linestyle=linestyles[i % 4])
58 
59  plt.errorbar(amplitude_file[0], amplitude_file[1], yerr=amplitude_file[2], ecolor=ecolors[-i], label=labels[i], color=colors[i], linestyle=linestyles[i % 4])
60 
61  phi = frictionLaw(amplitude_files[0][0])
62  plt.plot(amplitude_files[0][0], phi*100, label="\$\phi(\\nu)*N\$", color=colors[-1])
63 
64  plt.legend(title="Model: type")
65  plt.ylabel("\$A\$")
66  plt.xlabel("\$\\nu\$")
67  plt.suptitle("Averaged BK/BKP runs")
68 
69  if("-log" in sys.argv):
70  plt.xscale('log')
71  plt.show()
72 
73 
74 def run():
75  if("--average" in sys.argv):
77  else:
79 
80 
81 if __name__ == "__main__":
82  run()
def plotCIAmplitudes()
Definition: plotLoadedCI.py:13
def plotAveragedAmplitudes()
Definition: plotLoadedCI.py:42
def frictionLaw(y, sigma=0.01, F_0=1)
Definition: plotLoadedCI.py:36