Skip to content

Commit e340fbf

Browse files
committed
get rid of hardcoded paths
1 parent 8ef8104 commit e340fbf

1 file changed

Lines changed: 17 additions & 8 deletions

File tree

src/amuse/examples/compare_disk_size_trapezium.py

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,38 @@
1+
import os
12
import pickle
23
import matplotlib.pyplot as plt
34

4-
plt.style.use('../lib/matplotlibrc')
55

66
def main():
7-
with open("../data/Obs_Trapezium_disksizes.pkl", 'r', encoding="utf-8") as filepointer:
7+
datadir = os.path.dirname(__file__)
8+
with open(
9+
os.path.join(datadir, "data") + "Obs_Trapezium_disksizes.pkl",
10+
"r",
11+
encoding="utf-8",
12+
) as filepointer:
813
(radius_obs, yc_obs) = pickle.load(filepointer)
914

10-
with open("../data/Tr_N2000_R0.5pc_Q0.5_F1.6.pkl", 'r', encoding="utf-8") as filepointer:
15+
with open(
16+
os.path.join(datadir, "data") + "Tr_N2000_R0.5pc_Q0.5_F1.6.pkl",
17+
"r",
18+
encoding="utf-8",
19+
) as filepointer:
1120
(radius_sim, yc_sim) = pickle.load(filepointer)
1221

1322
print(len(radius_obs), len(yc_obs))
1423
print(len(radius_sim), len(yc_sim))
1524

16-
color = plt.rcParams['axes.prop_cycle'].by_key()['color']
25+
color = plt.rcParams["axes.prop_cycle"].by_key()["color"]
1726

18-
x_label = r'R [$R_\odot$]'
19-
y_label = '$f_{<R}$'
27+
x_label = r"R [$R_\odot$]"
28+
y_label = "$f_{<R}$"
2029
figure = plt.figure(figsize=(8, 8))
2130
ax = figure.add_subplot(111)
2231
ax.set_xlabel(x_label)
2332
ax.set_ylabel(y_label)
2433

25-
ax.plot(radius_obs, 95*yc_obs, c=color[0])
26-
ax.plot(radius_sim, 95*yc_sim, c=color[1], ls="--")
34+
ax.plot(radius_obs, 95 * yc_obs, c=color[0])
35+
ax.plot(radius_sim, 95 * yc_sim, c=color[1], ls="--")
2736

2837
plt.savefig("Tr_N2000_R05pc_Q05_F16_r1")
2938

0 commit comments

Comments
 (0)