-
Notifications
You must be signed in to change notification settings - Fork 0
/
plot_phase_plot.py
150 lines (130 loc) · 6.55 KB
/
plot_phase_plot.py
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
import matplotlib
matplotlib.use('Agg')
import matplotlib.pylab as plt
import sys
import seaborn as sns
sns.set_style("ticks", {'font.family':'serif'})
import yt
import ion_plot_definitions as ipd
import romulus_analysis_helper as rom
def plot_metallicity_radius(append_profiles = False, output = 3035, append_observations = False, use_average_profile = False, \
weight_field = None, data_cut = None, profile = False, use_rvir = True):
# metallicity vs spherical radius plot
xfield = 'spherical_position_radius'
yfield = 'metallicity'
zfield = 'mass'
# zfield = 'xray_emissivity'
xlabel = '$\mathrm{Radius\ (kpc)}$'
if use_rvir:
xlabel = '$\mathrm{R\ /\ R}_{200}$'
ylabel = '$\mathrm{Metallicity}\ (Z_{\odot})$'
cbar_label = '$\mathrm{Relative\ Frequency}$'
xlim = (0, 3000)
xlim = (0, 3)
ylim = (5e-4, 6)
zlim = (3e-6, 1e-3)
# zlim = (1e-10, 1e-3)
cmap = 'binary'
nbins = 40
profile_color = matplotlib.cm.get_cmap(cmap)(0.75)
xscale = 'linear'
profile_label = 'All Mass'
fig, ax, im, cbar = ipd.plot_phase(xfield, yfield, zfield, output = output, weight_field = weight_field,
profile = profile, profile_label = profile_label, use_rvir = use_rvir,\
profile_color = profile_color, nbins = nbins,\
xlabel = xlabel, ylabel = ylabel, xlim = xlim, ylim = ylim, zlim = zlim, \
cbar_label = cbar_label, xscale = xscale, cmap = cmap, data_cut = data_cut)
if append_observations:
#rvir = rom.get_romulus_rvir('romulusC', output)
rvir = rom.get_romulusC_r200(output)
rvir = 1
ipd.add_cluster_metallicity_observations(ax, color = 'firebrick', rvir = rvir)
if append_profiles:
data_list = ['hot', 'warm', 'cool', 'cold']
# data_list = ['hot_icm', 'warm_icm', 'cool_icm', 'cold_icm']
cmap_list = ['firebrick', 'goldenrod', 'seagreen', 'steelblue']
title_list = ['$\mathrm{Hot\ Gas}$', '$\mathrm{Warm\ Gas}$', '$\mathrm{Cool\ Gas}$', '$\mathrm{Cold\ Gas}$']
linestyle_list = ['solid', 'dashed', 'dashdot', 'dotted']
nbins = [20, 20, 20, 20]
nbins = [40, 40, 40, 40]
for i, data_cut in enumerate(data_list):
cmap = sns.dark_palette(cmap_list[i], as_cmap = True)
ffig, aax, im, cbar = ipd.plot_phase(xfield, yfield, zfield, output = output, weight_field = weight_field, \
fig = fig, ax = ax, do_pcolormesh = False, \
use_average_profile = use_average_profile, use_rvir = use_rvir,\
profile = True, profile_linestyle = linestyle_list[i], \
profile_color = cmap_list[i], profile_label = title_list[i],\
xlabel = xlabel, ylabel = ylabel, xlim = xlim, ylim = ylim, zlim = zlim, nbins = nbins[i],\
cbar_label = cbar_label, xscale = xscale, cmap = cmap, data_cut = data_cut)
fs = 8
ax.legend(loc = 'lower left', fontsize = fs)
fig.tight_layout()
plt.savefig('metallicity_radius_%06d.png'%(output), dpi = 300)
def plot_temperature_density(output = 3035, zfield = 'metallicity', weight_field = 'Mass', data_cut = None):
# metalliciyt distribution
xfield = 'particle_H_nuclei_density'
yfield = 'temperature'
zfield = zfield
# zfield = 'xray_intensity'
xlabel = '$\mathrm{n}_{\mathrm{H}}\ (\mathrm{cm}^{-3})$'
ylabel = '$\mathrm{Temperature\ (K)}$'
xlim = (1e-8, 1e2)
ylim = (1e3, 5e9)
if zfield == 'metallicity':
cbar_label = '$\mathrm{Metallicity}\ (Z_{\odot})$'
cmap = 'gist_earth'
zlim = (1e-3, 5)
elif zfield == 'mass':
cbar_label = 'Mass (M$_{\odot}$)'
zlim = (1e8, 1e11)
elif zfield == 'O_p5_mass':
cbar_label = 'O VI Mass (M$_{\odot}$)'
zlim = (1e-7, 1e-3)
xlim = (1e-7, 1e2)
ylim = (1e4, 1e7)
cmap = 'magma'
# cbar_label = 'xray intensity'
weight_field = weight_field
# zlim= (1e-50, 1e-35)
fig, ax, im, cbar = ipd.plot_phase(xfield, yfield, zfield, output = output, weight_field = weight_field, \
xlabel = xlabel, ylabel = ylabel, xlim = xlim, data_cut = data_cut, \
ylim = ylim, zlim = zlim, cbar_label = cbar_label, cmap = cmap)
if zfield == 'metallicity':
ipd.plot_box(ax, 1e-6, 1e-2, 1e4, 1e6)
ipd.plot_box(ax, 1e-4, .8, 2e6, 7e7)
fs = 13
fs = 7
ax.annotate('$\mathrm{Probed\ by\ UV}$\n $\mathrm{\ Absorption}$', \
xy = (3e-6, 5e4), fontsize = fs)
# ax.annotate('Probed by X-ray \n \ \ Emission', xy = (2e-4, 8e6), fontsize = fs)
ax.annotate('$\mathrm{Probed\ by\ X}$-$\mathrm{ray}$\n $\mathrm{\ \ \ Emission}$', \
xy = (2e-4, 8e6), fontsize = fs)
plt.savefig('density_temperature_%s_phase_%06d.png'%(zfield, output), dpi = 300)
def plot_cooling_time_ratio(output = 3035):
xfield = 'particle_H_nuclei_density'
yfield = 'temperature'
zfield = 'metal_primordial_cooling_time_ratio'
xlabel = '$\mathrm{n}_{\mathrm{H}}\ (\mathrm{cm}^{-3})$'
ylabel = '$\mathrm{Temperature\ (K)}$'
cbar_label = '$t_{cool, metal} / t_{cool, primordial}$'
xlim = (1e-8, 1e2)
ylim = (1e3, 5e9)
zlim = (1e-2, 1)
cmap = 'coolwarm'
weight_field = 'Mass'
fig, ax, im, cbar = ipd.plot_phase(xfield, yfield, zfield, output = output, weight_field = weight_field, \
xlabel = xlabel, ylabel = ylabel, xlim = xlim, \
ylim = ylim, zlim = zlim, cbar_label = cbar_label, cmap = cmap)
fs = 13
plt.savefig('density_temperature_cooling_time_%06d.png'%(output), dpi = 300)
output = int(sys.argv[1])
#output = 3035
weight_field = None
data_cut = None
#plot_cooling_time_ratio()
#plot_metallicity_radius(append_profiles = True, output = output, append_observations = True, use_rvir = True, \
# weight_field = weight_field, data_cut = data_cut, use_average_profile = False)
#plot_metallicity_radius(append_profiles = False, output = output, append_observations = True, \
# data_cut = 'hot_icm2', profile = True)
#plot_temperature_density(output = output)
plot_temperature_density(output = output, zfield = 'O_p5_mass', weight_field = None, data_cut = None)