Skip to content

Commit 7f1711c

Browse files
committed
plotting seds
1 parent 06b73cb commit 7f1711c

File tree

3 files changed

+95
-0
lines changed

3 files changed

+95
-0
lines changed

sed.py

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import matplotlib as mpl
2+
mpl.use('Agg')
3+
import matplotlib.pyplot as plt
4+
5+
from hyperion.model import ModelOutput
6+
from hyperion.util.constants import pc
7+
8+
# Open the model - we specify the name without the .rtout extension
9+
m = ModelOutput('tutorial_model.rtout')
10+
11+
# Create the plot
12+
fig = plt.figure()
13+
ax = fig.add_subplot(1, 1, 1)
14+
15+
# Extract the SED for the smallest inclination and largest aperture, and
16+
# scale to 300pc. In Python, negative indices can be used for lists and
17+
# arrays, and indicate the position from the end. So to get the SED in the
18+
# largest aperture, we set aperture=-1.
19+
wav, nufnu = m.get_sed(inclination=0, aperture=-1, distance=300 * pc)
20+
21+
# Plot the SED. The loglog command is similar to plot, but automatically
22+
# sets the x and y axes to be on a log scale.
23+
ax.loglog(wav, nufnu)
24+
25+
# Add some axis labels (we are using LaTeX here)
26+
ax.set_xlabel(r'$\lambda$ [$\mu$m]')
27+
ax.set_ylabel(r'$\lambda F_\lambda$ [ergs/s/cm$^2$]')
28+
29+
# Set view limits
30+
ax.set_xlim(0.1, 5000.)
31+
ax.set_ylim(1.e-12, 2.e-6)
32+
33+
# Write out the plot
34+
fig.savefig('sed.png')

sed_incl.py

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import matplotlib as mpl
2+
mpl.use('Agg')
3+
import matplotlib.pyplot as plt
4+
5+
from hyperion.model import ModelOutput
6+
from hyperion.util.constants import pc
7+
8+
m = ModelOutput('tutorial_model.rtout')
9+
10+
fig = plt.figure()
11+
ax = fig.add_subplot(1, 1, 1)
12+
13+
# Extract all SEDs
14+
wav, nufnu = m.get_sed(inclination='all', aperture=-1, distance=300 * pc)
15+
16+
# Plot SED for each inclination
17+
for i in range(nufnu.shape[0]):
18+
ax.loglog(wav, nufnu[i, :], color='black')
19+
20+
ax.set_xlabel(r'$\lambda$ [$\mu$m]')
21+
ax.set_ylabel(r'$\lambda F_\lambda$ [ergs/s/cm$^2$]')
22+
ax.set_xlim(0.1, 5000.)
23+
ax.set_ylim(1.e-12, 2.e-6)
24+
fig.savefig('sed_incl.png')

sed_origin.py

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import matplotlib as mpl
2+
mpl.use('Agg')
3+
import matplotlib.pyplot as plt
4+
5+
from hyperion.model import ModelOutput
6+
from hyperion.util.constants import pc
7+
8+
m = ModelOutput('tutorial_model.rtout')
9+
10+
fig = plt.figure()
11+
ax = fig.add_subplot(1, 1, 1)
12+
13+
# Direct stellar photons
14+
wav, nufnu = m.get_sed(inclination=0, aperture=-1, distance=300 * pc,
15+
component='source_emit')
16+
ax.loglog(wav, nufnu, color='blue')
17+
18+
# Scattered stellar photons
19+
wav, nufnu = m.get_sed(inclination=0, aperture=-1, distance=300 * pc,
20+
component='source_scat')
21+
ax.loglog(wav, nufnu, color='teal')
22+
23+
# Direct dust photons
24+
wav, nufnu = m.get_sed(inclination=0, aperture=-1, distance=300 * pc,
25+
component='dust_emit')
26+
ax.loglog(wav, nufnu, color='red')
27+
28+
# Scattered dust photons
29+
wav, nufnu = m.get_sed(inclination=0, aperture=-1, distance=300 * pc,
30+
component='dust_scat')
31+
ax.loglog(wav, nufnu, color='orange')
32+
33+
ax.set_xlabel(r'$\lambda$ [$\mu$m]')
34+
ax.set_ylabel(r'$\lambda F_\lambda$ [ergs/s/cm$^2$]')
35+
ax.set_xlim(0.1, 5000.)
36+
ax.set_ylim(1.e-12, 2.e-6)
37+
fig.savefig('sed_origin.png')

0 commit comments

Comments
 (0)