-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFig_A2_larger_system.py
More file actions
86 lines (68 loc) · 2.59 KB
/
Fig_A2_larger_system.py
File metadata and controls
86 lines (68 loc) · 2.59 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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#!/usr/bin/env python3
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
import glob
folders = [
'data/larger_system/rhytmite/L625_T100',
'data/larger_system/rhytmite/L750_T100',
'data/larger_system/rhytmite/L875_T150',
'data/larger_system/rhytmite/L1125_T150',
'data/larger_system/rhytmite/L1625_T5000',
]
labels = ["Aragonite", "Calcite", "Porosity", r"$Ca^{2+}$", r"$CO_3^{2-}$"]
line_styles = ['-', '--', '-.', ':', (0, (3, 1, 1, 1))]
colors = ['#E69F00', 'red', '#000000', '#009E73', '#0072B2']
fig, axes = plt.subplots(2, 3, figsize=(15, 10))
axes = axes.flatten()
Ts = 131.9 / 0.1**2
# Collect all y-values to determine common limits
all_y_values = []
for idx, folder in enumerate(folders):
ascii_files = glob.glob(f'{folder}/*.ascii')
if not ascii_files:
print(f"Warning: No .ascii file found in {folder}")
continue
filename = ascii_files[0]
ax = axes[idx]
df = (pd.read_csv(filename, sep=r'\s+')).shift(axis=1).iloc[:,1:]
t_plot = np.array(df.x * Ts / 1000)
ax.plot(t_plot, np.array(df.AR), label=labels[0],
color=colors[0], linestyle=line_styles[0])
ax.plot(t_plot, np.array(df.CA), label=labels[1],
color=colors[1], linestyle=line_styles[1])
ax.plot(t_plot, np.array(df.phi), label=labels[2],
color=colors[2], linestyle=line_styles[2])
ax.plot(t_plot, np.array(df.ca), label=labels[3],
color=colors[3], linestyle=line_styles[3])
ax.plot(t_plot, np.array(df.co), label=labels[4],
color=colors[4], linestyle=line_styles[4])
# Collect y-values for common axis limits
all_y_values.extend(df.AR)
all_y_values.extend(df.CA)
all_y_values.extend(df.phi)
all_y_values.extend(df.ca)
all_y_values.extend(df.co)
folder_name = folder.split('/')[-1]
parts = folder_name.split('_')
L = parts[0][1:]
tstar = parts[1][1:]
ax.set_title(f'$T^*$ = {tstar}, L = {L}', fontsize=10)
ax.set_xlabel('Time [ky]')
ax.set_ylabel('Concentration/Porosity')
panel_label = chr(97 + idx)
ax.text(0.02, 0.98, f'({panel_label})', transform=ax.transAxes,
fontsize=12, fontweight='bold', va='top', ha='left')
if idx == 4:
ax.legend(loc='lower right', fontsize=8)
# Set common y-axis
y_min = min(all_y_values)
y_max = max(all_y_values)
y_margin = (y_max - y_min) * 0.05
for i in range(5):
axes[i].set_ylim(y_min - y_margin, y_max + y_margin)
axes[5].axis('off')
plt.tight_layout()
plt.savefig('figs/larger_system/Fig_A2_larger_system.png',
format='png', dpi=300, bbox_inches='tight')
plt.close()