-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathquickplot_amountgas.py
More file actions
67 lines (55 loc) · 2.39 KB
/
Copy pathquickplot_amountgas.py
File metadata and controls
67 lines (55 loc) · 2.39 KB
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
67
import os
import re
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
path = "C:\\Users\\User\\Documents\\Documents\\University\\Bachelor_RUG\\Year_4\\IIB\\Research_project\\Research\\Simulations\\"
files = os.listdir(path)
files.remove("Analysis")
lst_volatiles1 = ["H2O", "CO2", "H2", "CH4", "CO", "N2", "NH3", "O2"]
lst_volatiles2 = ["H2O", "CO2", "H2", "CH4", "CO", "N2", "NH3"]
for i in files:
print(i)
module = i.split("_")[1]
if module == "JANUS":
lst_volatiles = lst_volatiles1
else:
lst_volatiles = lst_volatiles2
fig, ax1 = plt.subplots(1,1)
x_gas = dict.fromkeys(lst_volatiles)
p = dict.fromkeys(lst_volatiles)
pp_gas = dict.fromkeys(lst_volatiles)
for w in x_gas.keys():
x_gas[w] = []
p[w] = []
pp_gas[w] = []
for t in lst_volatiles:
data = os.listdir(path+i+f"\\Results\\Data\\{t}\\")
A = []
for k in data:
a = int(re.search(r"\d+", k).group())
A.append(a)
A = sorted(A) #And pull time points from the names of the files
Time = A
A_new = []
for k in A:
a = "phasestte"+str(k)+".txt"
A_new.append(a)
data = A_new
for n in data:
df = pd.read_csv(path+i+f"\\Results\\Data\\{t}\\{n}", header = None, sep=" ")
df.columns = df.iloc[0]
df = df[1:]
l = len(df["x_gas"])-2
x_gas[t].append(float(df["x_gas"][l])) #sum([float(w) for w in df["x_gas"]]) / len([float(w) for w in df["x_gas"]]) )
p[t].append(float(df["Pressure(Pa)"][l])) #sum([float(w) for w in df["Pressure(Pa)"]]) / len([float(w) for w in df["Pressure(Pa)"]]) )
x_gas[t] = np.array(x_gas[t])
p[t] = np.array(p[t])/1e5
pp_gas[t] = x_gas[t]*p[t]
ax1.plot(Time, pp_gas[t], linewidth = 1, label = f"{t}")
ax1.set_xscale("log")
ax1.set_yscale("log")
ax1.set_xlabel("Time (yr)")
ax1.set_ylabel("Partial pressure of volatiles at the surface (bar)")
ax1.legend(loc='lower left', bbox_to_anchor=(1, 0), borderaxespad=0.2)
fig.savefig(f"C:\\Users\\User\\Documents\\Documents\\University\\Bachelor_RUG\\Year_4\\IIB\\Research_project\\Research\\Simulations\\{i}\\Amountgas.png", bbox_inches = "tight", dpi=150)