Skip to content

Commit b71b26b

Browse files
committed
update
1 parent 59b8bd1 commit b71b26b

1 file changed

Lines changed: 62 additions & 50 deletions

File tree

Lines changed: 62 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,100 +1,112 @@
1-
import numpy
2-
from matplotlib import pyplot
3-
from amuse.lab import *
1+
import numpy as np
2+
import matplotlib.pyplot as plt
3+
from amuse.units import units
4+
5+
from amuse.examples.supernova_IIp_Lightcurve import Supernova_IIp
46

5-
from prepare_figure import single_frame, figure_frame, set_tickmarks
6-
from distinct_colours import get_distinct
7-
from supernova_IIp_Lightcurve import Supernova_IIp
87

98
def read_supernova_irradiation_file(filename):
109
t = []
1110
Tmean = []
1211
Tmax = []
1312
for line in open(filename):
14-
if 'Time' in line:
13+
if "Time" in line:
1514
sl = line.split()
1615
t.append(float(sl[1]))
17-
if 'Temperature:' in line:
16+
if "Temperature:" in line:
1817
sl = line.split()
1918
Tmean.append(float(sl[3]))
2019
Tmax.append(float(sl[1]))
21-
return numpy.asarray(t, dtype="float"), Tmean, Tmax
20+
return np.asarray(t, dtype="float"), Tmean, Tmax
21+
2222

2323
def read_Earthorbit():
2424
t = []
2525
e = []
2626
a = []
27-
tmax = 1.e+6
28-
for line in open('Eart_Orbit_Eps-3.data'):
29-
if '#' not in line:
27+
tmax = 1.0e6
28+
for line in open("Eart_Orbit_Eps-3.data"):
29+
if "#" not in line:
3030
sl = line.split()
3131
t.append(float(sl[0]))
3232
a.append(float(sl[1]))
3333
e.append(float(sl[2]))
34-
if t[-1]>tmax:
34+
if t[-1] > tmax:
3535
break
36-
return t, a, e
36+
return t, a, e
37+
3738

38-
if __name__ in ('__main__', '__plot__'):
39-
to = 50|units.day
39+
def plot_supernova_IIp_and_disk_temperature():
40+
to = 50 | units.day
4041

41-
t_offset = to + (((0.15|units.parsec)/(1|units.lightyear)) | units.yr)
42-
filename = 'SN10a.R0.15.i15.data'
42+
t_offset = to + (((0.15 | units.parsec) / (1 | units.lightyear)) | units.yr)
43+
filename = "SN10a.R0.15.i15.data"
4344
time, Tmean, Tmax = read_supernova_irradiation_file(filename)
4445
time += t_offset.value_in(units.day)
4546

46-
t_offset = to + (((0.3|units.parsec)/(1|units.lightyear)) | units.yr)
47-
filename = 'SN11aof.R0.3.i45.data'
47+
t_offset = to + (((0.3 | units.parsec) / (1 | units.lightyear)) | units.yr)
48+
filename = "SN11aof.R0.3.i45.data"
4849
t3pc_N7, Tmean3pc_N7, Tmax3pc_N7 = read_supernova_irradiation_file(filename)
4950
t3pc_N7 += t_offset.value_in(units.day)
5051

51-
t_offset = to + (((0.4|units.parsec)/(1|units.lightyear)) | units.yr)
52-
filename = 'SN11aof.R0.4.i15.data'
52+
t_offset = to + (((0.4 | units.parsec) / (1 | units.lightyear)) | units.yr)
53+
filename = "SN11aof.R0.4.i15.data"
5354
t3pc_N8, Tmean3pc_N8, Tmax3pc_N8 = read_supernova_irradiation_file(filename)
5455
t3pc_N8 += t_offset.value_in(units.day)
5556

5657
PS1_11aof = Supernova_IIp("11aof", to)
57-
t = 10**numpy.arange(-2, 3., 0.01) | units.day
58-
L11aof = [] | units.erg/units.s
58+
t = 10 ** np.arange(-2, 3.0, 0.01) | units.day
59+
L11aof = [] | units.erg / units.s
5960
for ti in t:
6061
L11aof.append(PS1_11aof.luminosity_at_time(ti))
61-
L11aof = numpy.log10(L11aof.value_in(units.LSun))
62+
L11aof = np.log10(L11aof.value_in(units.LSun))
6263

6364
PS1_10a = Supernova_IIp("10a", to)
64-
L10a = [] | units.erg/units.s
65+
L10a = [] | units.erg / units.s
6566
for ti in t:
6667
L10a.append(PS1_10a.luminosity_at_time(ti))
67-
L10a = numpy.log10(L10a.value_in(units.LSun))
68-
69-
from matplotlib import pyplot, rc
68+
L10a = np.log10(L10a.value_in(units.LSun))
69+
7070
x_label = "$t$ [day]"
7171
y_label = "L [L$_\odot$]"
72-
figure = single_frame(x_label, y_label, xsize=14, ysize=10)
73-
ax1 = pyplot.gca()
74-
cols = get_distinct(4)
75-
76-
font = {'size' : 20}
77-
rc('font', **font)
78-
ax1.plot(t.value_in(units.day), L11aof, ls='-', c=cols[0])
79-
ax1.plot(t.value_in(units.day), L10a, ls='--', c=cols[0])
80-
ax1.set_xlabel('time [day]')
81-
ax1.set_ylabel('log$_{10}$(L/L$_\odot$)', color=cols[0])
72+
figure = plt.figure()
73+
ax1 = figure.add_subplot(1, 1, 1)
74+
ax1.set_xlabel(x_label)
75+
ax1.set_ylabel(y_label)
76+
77+
colors = plt.rcParams["axes.prop_cycle"].by_key()["color"]
78+
ax1.plot(t.value_in(units.day), L11aof, ls="-", c=colors[0])
79+
ax1.plot(t.value_in(units.day), L10a, ls="--", c=colors[0])
80+
ax1.set_xlabel("time [day]")
81+
ax1.set_ylabel("log$_{10}$(L/L$_\odot$)", color=colors[0])
8282
for tl in ax1.get_yticklabels():
83-
tl.set_color(cols[0])
83+
tl.set_color(colors[0])
8484

8585
ax2 = ax1.twinx()
86-
ax2.plot(time, Tmean, cols[1], ls='--')
87-
ax2.plot(t3pc_N7, Tmean3pc_N7, cols[1])
88-
ax2.plot(t3pc_N8, Tmean3pc_N8, cols[1], lw=4)
89-
ax2.set_ylabel('mean temperature [K]', color=cols[1])
86+
ax2.plot(time, Tmean, colors[1], ls="--")
87+
ax2.plot(t3pc_N7, Tmean3pc_N7, colors[1])
88+
ax2.plot(t3pc_N8, Tmean3pc_N8, colors[1], lw=4)
89+
ax2.set_ylabel("mean temperature [K]", color=colors[1])
9090
for tl in ax2.get_yticklabels():
91-
tl.set_color(cols[1])
91+
tl.set_color(colors[1])
9292

9393
t_cooling = [950, 1061]
9494
T_cooling = [1600, 800]
95-
ax2.plot(t_cooling, T_cooling, cols[3], lw=1)
96-
ax2.text(t_cooling[0]+20, T_cooling[0]-100, "cooling of 0.3 K/h", rotation=-76.5, color=cols[3])
97-
98-
pyplot.show()
99-
# pyplot.savefig("supernova_IIp_and_disk_temperature")
95+
ax2.plot(t_cooling, T_cooling, colors[3], lw=1)
96+
ax2.text(
97+
t_cooling[0] + 20,
98+
T_cooling[0] - 100,
99+
"cooling of 0.3 K/h",
100+
rotation=-76.5,
101+
color=colors[3],
102+
)
103+
104+
plt.savefig("supernova_IIp_and_disk_temperature")
105+
106+
107+
def main():
108+
plot_supernova_IIp_and_disk_temperature()
109+
100110

111+
if __name__ == "__main__":
112+
main()

0 commit comments

Comments
 (0)