-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmodel_plots.py
590 lines (483 loc) · 27.8 KB
/
model_plots.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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
"""
This file contain a subclass of the model.py module and Cluster class. It
is dedicated to the computing of observables.
"""
#==================================================
# Requested imports
#==================================================
import matplotlib.pyplot as plt
from matplotlib.patches import Ellipse
from matplotlib.colors import SymLogNorm
import astropy.units as u
import numpy as np
from astropy.wcs import WCS
from astropy import constants as const
import os
#==================================================
# Style
#==================================================
cta_energy_range = [0.02, 100.0]*u.TeV
fermi_energy_range = [0.1, 300.0]*u.GeV
def set_default_plot_param():
dict_base = {'font.size': 16,
'legend.fontsize': 16,
'xtick.labelsize': 16,
'ytick.labelsize': 16,
'axes.labelsize': 16,
'axes.titlesize': 16,
'figure.titlesize': 16,
'figure.figsize':[8.0, 6.0],
'figure.subplot.right':0.97,
'figure.subplot.left':0.18, # Ensure enough space on the left so that all plot can be aligned
'font.family':'serif',
'figure.facecolor': 'white',
'legend.frameon': True}
plt.rcParams.update(dict_base)
#==================================================
# Plot radial profiles
#==================================================
def profile(radius, angle, prof, filename, label='Profile', R500=None):
"""
Plot the profiles
Parameters
----------
- radius (quantity): homogeneous to kpc
- angle (quantity): homogeneous to deg
- prof (quantity): any profile
- label (str): the full name of the profile
- filename (str): the full path name of the profile
- R500 (quantity): homogeneous to kpc
"""
p_unit = prof.unit
r_unit = radius.unit
t_unit = angle.unit
wgood = ~np.isnan(prof)
profgood = prof[wgood]
ymin = np.nanmin(profgood[profgood>0].to_value())*0.5
ymax = np.nanmax(profgood[profgood>0].to_value())*2.0
fig, ax1 = plt.subplots()
ax1.plot(radius, prof, 'blue')
if R500 != None:
ax1.axvline(R500.to_value(r_unit), ymin=-1e300, ymax=1e300,
color='black', label='$R_{500}$', linestyle='--')
ax1.set_xlabel('Radius ('+str(r_unit)+')')
ax1.set_ylabel(label)
ax1.set_xscale('log')
ax1.set_yscale('log')
ax1.set_xlim([np.amin(radius.to_value()), np.amax(radius.to_value())])
ax1.set_ylim([ymin,ymax])
ax1.legend()
# Add extra projected radius axis
ax2 = ax1.twiny()
ax2.plot(angle, prof, 'blue')
ax2.set_xlabel('Radius ('+str(t_unit)+')', color='k')
ax2.set_xscale('log')
ax2.set_xlim([np.amin(angle.to_value()),np.amax(angle.to_value())])
fig.savefig(filename)
plt.close()
#==================================================
# Plot spectra
#==================================================
def spectra(energy, freq, spec, filename, label='Spectrum'):
"""
Plot the profiles
Parameters
----------
- energy (quantity): homogeneous to GeV
- sepc (quantity): any spectrum
- sepc_label (str): the full name of the sepctrum
- filename (str): the full path name of the profile
"""
s_unit = spec.unit
e_unit = energy.unit
f_unit = freq.unit
wgood = ~np.isnan(spec)
specgood = spec[wgood]
ymin = np.nanmin(specgood[specgood>0].to_value())*0.5
ymax = np.nanmax(specgood[specgood>0].to_value())*2.0
fig, ax = plt.subplots()
ax.plot(energy, spec, 'black')
ax.fill_between(cta_energy_range.to_value(e_unit), ymin, ymax,
facecolor='blue', alpha=0.2, label='CTA range')
ax.fill_between(fermi_energy_range.to_value(e_unit), ymin, ymax,
facecolor='red', alpha=0.2, label='Fermi range')
ax.set_xlabel('Energy ('+str(e_unit)+')')
ax.set_ylabel(label)
ax.set_xscale('log')
ax.set_yscale('log')
ax.set_ylim([ymin,ymax])
ax.set_xlim([np.amin(energy.to_value()), np.amax(energy.to_value())])
plt.legend()
# Add extra projected frequency axis
ax2 = ax.twiny()
ax2.plot(freq, spec, 'black')
ax2.set_xlabel('Frequency ('+str(f_unit)+')', color='k')
ax2.set_xscale('log')
ax2.set_xlim([np.amin(freq.to_value()),np.amax(freq.to_value())])
fig.savefig(filename)
plt.close()
#==================================================
# Plot spectra
#==================================================
def maps(image, header, filename,
label='Map', coord=None, theta_500=None,
theta_trunc=None, logscale=False):
"""
Plot the profiles
Parameters
----------
- image (np.2darray): the map
- header (str): corresponding header
- filename (str): the full path name of the profile
- theta_500 (quantity): angle corresponding to R500
- theta_trunc (quantity): angle corresponding to the truncation
"""
plt.rcParams.update({'figure.subplot.right':0.90,
'figure.subplot.left':0.05})
wcs_map = WCS(header)
#---------- Check the map scale
if np.amin(image) == np.amax(image):
logscale = False
print('WARNING: the image is empty. You may have set the map coordinates far away from the cluster center.')
#---------- Get vmin/max
vmax = np.nanmax(image)
vmin = vmax/1e4
#---------- Plot the map
fig = plt.figure()
ax = plt.subplot(projection=wcs_map)
if logscale:
plt.imshow(image, origin='lower', cmap='magma', norm=SymLogNorm(vmin, vmin=vmin, vmax=vmax))
else:
plt.imshow(image, origin='lower', cmap='magma')
if coord != None and theta_500 != None:
circle = Ellipse((coord.icrs.ra.deg, coord.icrs.dec.deg),
2*theta_500.to_value('deg')/np.cos(coord.icrs.dec.rad),
2*theta_500.to_value('deg'),
linewidth=2, fill=False, zorder=2,
edgecolor='white', linestyle='-.',
facecolor='none', transform=ax.get_transform('fk5'))
ax.add_patch(circle)
txt = plt.text(coord.icrs.ra.deg - theta_500.to_value('deg'),
coord.icrs.dec.deg - theta_500.to_value('deg'),
'$R_{500}$',
transform=ax.get_transform('fk5'), fontsize=10, color='white',
horizontalalignment='center',verticalalignment='center')
if coord != None and theta_trunc != None:
circle = Ellipse((coord.icrs.ra.deg, coord.icrs.dec.deg),
2*theta_trunc.to_value('deg')/np.cos(coord.icrs.dec.rad),
2*theta_trunc.to_value('deg'),
linewidth=2, fill=False, zorder=2,
edgecolor='white', linestyle='--',
facecolor='none', transform=ax.get_transform('fk5'))
ax.add_patch(circle)
txt = plt.text(coord.icrs.ra.deg - theta_trunc.to_value('deg'),
coord.icrs.dec.deg - theta_trunc.to_value('deg'),
'$R_{trunc}$',
transform=ax.get_transform('fk5'), fontsize=10, color='white',
horizontalalignment='center',verticalalignment='center')
ax.set_xlabel('R.A. (deg)')
ax.set_ylabel('Dec. (deg)')
cbar = plt.colorbar()
cbar.set_label(label)
fig.savefig(filename)
plt.close()
set_default_plot_param()
#==================================================
# Main function
#==================================================
class Plots(object):
""" Observable class
This class serves as a parser to the main Cluster class, to
include the subclass Observable in this other file.
Attributes
----------
The attributes are the same as the Cluster class, see model.py
Methods
----------
- plot(self, list_prod=['all'],radius=np.logspace(0,4,1000)*u.kpc,
energy=np.logspace(-2,6,1000)*u.GeV, NR500max=5.0, Npt_los=100, Rmax=None,
Epmin=None, Epmax=None, Egmin=10.0*u.MeV, Egmax=1.0*u.PeV):
"""
#==================================================
# Main plot function
#==================================================
def plot(self, prod_list=['all'],
radius=np.logspace(0,4,100)*u.kpc,
energy=np.logspace(-2,7,100)*u.GeV,
energyX=np.linspace(0.1,20,100)*u.keV,
frequency=np.logspace(-2,3,100)*u.GHz,
Epmin=None, Epmax=None,
Eemin=None, Eemax=None,
freq0=1*u.GHz,
Rmax=None,
Egmin=None, Egmax=None):
"""
Main function of the sub-module of the cluster class dedicated to plots.
Parameters
----------
- prod_list (list): the list of what is required for production
- radius (quantity) : the physical radius
- energy (quantity) : the physical energy of CR protons
- NR500max (float): the integration will stop at NR500max x R500
Only used for projected profiles.
- Npt_los (int): the number of points for line of sight integration
Only used for projected profiles.
- Epmin (quantity): the lower bound for energy proton integration
- Epmax (quantity): the upper bound for energy proton integration
- Egmin (quantity): the lower bound for energy gamma integration
- Egmax (quantity): the upper bound for energy gamma integration
- Rmax (quantity): the radius within with the spectrum is computed
(default is R500)
"""
# Default keyword
if Epmin is None:
Epmin = self._Epmin
if Epmax is None:
Epmax = self._Epmax
if Eemin is None:
Eemin = (const.m_e*const.c**2).to('GeV')
if Eemax is None:
Eemax = self._Epmax
if Rmax is None:
Rmax = self._R500
if Egmin is None:
Egmin = self._Epmin/10.0
if Egmax is None:
Egmax = self._Epmax
# Create directory
if not os.path.exists(self._output_dir): os.mkdir(self._output_dir)
# get directory
outdir = self._output_dir
# plot parameters
set_default_plot_param()
Egstrlim = str(round(Egmin.value,2)*Egmin.unit)+'-'+str(round(Egmax.value,2)*Egmax.unit)
#---------- Profiles
if 'all' in prod_list or 'profile' in prod_list:
angle = (radius.to_value('kpc')/self._D_ang.to_value('kpc')*180.0/np.pi)*u.deg
# Pressure
rad, prof = self.get_pressure_gas_profile(radius)
profile(radius, angle, prof.to('keV cm-3'), self._output_dir+'/PLOT_PROF_gas_pressure.pdf',
label='Electron pressure (keV cm$^{-3}$)', R500=self._R500)
if not self._silent: print('----- Plot done: gas pressure')
# Density
rad, prof = self.get_density_gas_profile(radius)
profile(radius, angle, prof.to('cm-3'), self._output_dir+'/PLOT_PROF_gas_density.pdf',
label='Electron density (cm$^{-3}$)', R500=self._R500)
if not self._silent: print('----- Plot done: gas density')
# temperature
rad, prof = self.get_temperature_gas_profile(radius)
profile(radius, angle, prof.to('keV'), self._output_dir+'/PLOT_PROF_gas_temperature.pdf',
label='Gas temperature (keV)', R500=self._R500)
if not self._silent: print('----- Plot done: gas temperature')
# Entropy
rad, prof = self.get_entropy_gas_profile(radius)
profile(radius, angle, prof.to('keV cm2'), self._output_dir+'/PLOT_PROF_gas_entropy.pdf',
label='Gas entropy (keV cm$^2$)', R500=self._R500)
if not self._silent: print('----- Plot done: gas entropy')
# Masse HSE
rad, prof = self.get_hse_mass_profile(radius)
profile(radius, angle, prof.to('Msun'), self._output_dir+'/PLOT_PROF_hse_mass.pdf',
label='HSE mass (M$_{\\odot}$)', R500=self._R500)
if not self._silent: print('----- Plot done: HSE mass')
# Overdensity
rad, prof = self.get_overdensity_contrast_profile(radius)
profile(radius, angle, prof.to('adu'), self._output_dir+'/PLOT_PROF_overdensity.pdf',
label='Overdensity $\\rho / \\rho_{c}$', R500=self._R500)
if not self._silent: print('----- Plot done: density contrast')
# Gas mass
rad, prof = self.get_gas_mass_profile(radius)
profile(radius, angle, prof.to('Msun'), self._output_dir+'/PLOT_PROF_gas_mass.pdf',
label='Gas mass (M$_{\\odot}$)', R500=self._R500)
if not self._silent: print('----- Plot done: gas mass')
# fgas profile
rad, prof = self.get_fgas_profile(radius)
profile(radius, angle, prof.to('adu'), self._output_dir+'/PLOT_PROF_gas_fraction.pdf',
label='Gas fraction', R500=self._R500)
if not self._silent: print('----- Plot done: gas fraction')
# Thermal energy
rad, prof = self.get_thermal_energy_profile(radius)
profile(radius, angle, prof.to('erg'), self._output_dir+'/PLOT_PROF_gas_thermal_energy.pdf',
label='Thermal energy (erg)', R500=self._R500)
if not self._silent: print('----- Plot done: thermal energy')
# Magfield
rad, prof = self.get_magfield_profile(radius)
profile(radius, angle, prof.to('uG'), self._output_dir+'/PLOT_PROF_magnetic_field.pdf',
label='Magnetic field ($\\mu$G)', R500=self._R500)
if not self._silent: print('----- Plot done: magnetic field')
# Cosmic ray proton
rad, prof = self.get_density_crp_profile(radius, Emin=Epmin, Emax=Epmax, Energy_density=False)
profile(radius, angle, prof.to('cm-3'), self._output_dir+'/PLOT_PROF_crp_density.pdf',
label='CRp density (cm$^{-3}$)', R500=self._R500)
if not self._silent: print('----- Plot done: CRp density')
# Cosmic ray to thermal energy
rad, prof = self.get_crp_to_thermal_energy_profile(radius, Emin=Epmin, Emax=Epmax)
profile(radius, angle, prof.to('adu'), self._output_dir+'/PLOT_PROF_crp_fraction.pdf',
label='CRp to thermal energy $X_{CR}$', R500=self._R500)
if not self._silent: print('----- Plot done: CRp/thermal energy')
# Cosmic ray electrons
rad, prof = self.get_density_cre_profile(radius, Emin=Eemin, Emax=Eemax, Energy_density=False)
profile(radius, angle, prof.to('cm-3'), self._output_dir+'/PLOT_PROF_cre_density.pdf',
label='CRe density (cm$^{-3}$)', R500=self._R500)
if not self._silent: print('----- Plot done: CRe density')
# Gamma ray profile
rad, prof = self.get_gamma_profile(radius, Emin=Egmin, Emax=Egmax, Energy_density=False)
profile(radius, angle, prof.to('cm-2 s-1 sr-1'), self._output_dir+'/PLOT_PROF_gamma.pdf',
label='$\\gamma$-ray, '+Egstrlim+' (cm$^{-2}$ s$^{-1}$ sr$^{-1}$)', R500=self._R500)
if not self._silent: print('----- Plot done: gamma surface brightness profile')
# Gamma ray integrated flux profile
prof = self.get_gamma_flux(Emin=Egmin, Emax=Egmax, Rmax=radius, Energy_density=False, type_integral='spherical')
profile(radius, angle, prof.to('cm-2 s-1'), self._output_dir+'/PLOT_PROF_gammaF.pdf',
label='$\\gamma$-ray flux (<R, sph), '+Egstrlim+' (cm$^{-2}$ s$^{-1}$)', R500=self._R500)
if not self._silent: print('----- Plot done: gamma integrated (R) flux')
# neutrino profile
rad, prof = self.get_neutrino_profile(radius, Emin=Egmin, Emax=Egmax, Energy_density=False, flavor='all')
profile(radius, angle, prof.to('cm-2 s-1 sr-1'), self._output_dir+'/PLOT_PROF_neutrino.pdf',
label='$\\nu$, '+Egstrlim+' (cm$^{-2}$ s$^{-1}$ sr$^{-1}$)', R500=self._R500)
if not self._silent: print('----- Plot done: neutrino surface brightness profile')
# neutrino integrated flux profile
prof = self.get_neutrino_flux(Emin=Egmin, Emax=Egmax, Rmax=radius, Energy_density=False, type_integral='spherical', flavor='all')
profile(radius, angle, prof.to('cm-2 s-1'), self._output_dir+'/PLOT_PROF_neutrinoF.pdf',
label='$\\nu$ flux (<R, sph), '+Egstrlim+' (cm$^{-2}$ s$^{-1}$)', R500=self._R500)
if not self._silent: print('----- Plot done: neutrino integrated (R) flux')
# IC profile
rad, prof = self.get_ic_profile(radius, Emin=Egmin, Emax=Egmax, Energy_density=False)
profile(radius, angle, prof.to('cm-2 s-1 sr-1'), self._output_dir+'/PLOT_PROF_InverseCompton.pdf',
label='IC, '+Egstrlim+' (cm$^{-2}$ s$^{-1}$ sr$^{-1}$)', R500=self._R500)
if not self._silent: print('----- Plot done: IC surface brightness profile')
# IC integrated flux profile
prof = self.get_ic_flux(Emin=Egmin, Emax=Egmax, Rmax=radius, Energy_density=False, type_integral='spherical')
profile(radius, angle, prof.to('cm-2 s-1'), self._output_dir+'/PLOT_PROF_InverseComptonF.pdf',
label='IC flux (<R, sph), '+Egstrlim+' (cm$^{-2}$ s$^{-1}$)', R500=self._R500)
if not self._silent: print('----- Plot done: IC integrated (R) flux')
# Synchrotron profile
rad, prof = self.get_synchrotron_profile(radius, freq0=freq0)
profile(radius, angle, prof.to('Jy sr-1'), self._output_dir+'/PLOT_PROF_synchrotron.pdf',
label='Synchrotron, '+str(freq0)+' (Jy sr$^{-1}$)', R500=self._R500)
if not self._silent: print('----- Plot done: Synchrotron surface brightness profile')
# Synchrotron integrated flux profile
prof = self.get_synchrotron_flux(freq0=freq0, Rmax=radius, type_integral='spherical')
profile(radius, angle, prof.to('Jy'), self._output_dir+'/PLOT_PROF_synchrotronF.pdf',
label='Synchrotron flux (<R, sph), '+str(freq0)+' (Jy)', R500=self._R500)
if not self._silent: print('----- Plot done: Synchrotron integrated (R) flux')
# Compton parameter
rad, prof = self.get_sz_profile(radius, Compton_only=True)
profile(radius, angle, prof.to('adu'), self._output_dir+'/PLOT_PROF_SZ.pdf',
label='y Compton', R500=self._R500)
if not self._silent: print('----- Plot done: SZ Compton')
# Spherically integrated Compton
prof = self.get_sz_flux(Rmax=radius, Compton_only=True, type_integral='spherical')
profile(radius, angle, prof.to('kpc2'), self._output_dir+'/PLOT_PROF_SZF.pdf',
label='Y spherical (kpc$^2$)', R500=self._R500)
if not self._silent: print('----- Plot done: SZ integrated Compton (spherical)')
if os.path.exists(self._output_dir+'/XSPEC_table.txt'):
# Sx profile
rad, prof = self.get_xray_profile(radius, output_type='C')
profile(radius, angle, prof.to('s-1 cm-2 sr-1'), self._output_dir+'/PLOT_PROF_X.pdf',
label='X-ray (s$^{-1}$ cm$^{-2}$ sr$^{-1}$)', R500=self._R500)
if not self._silent: print('----- Plot done: Xray surface brightness')
# Spherically integrated Xray flux
prof = self.get_xray_flux(Rmax=radius, type_integral='spherical', output_type='C')
profile(radius, angle, prof.to('s-1 cm-2'), self._output_dir+'/PLOT_PROF_XF.pdf',
label='$F_X$ spherical (s$^{-1}$ cm$^{-2}$)', R500=self._R500)
if not self._silent: print('----- Plot done: Xray integrated flux (spherical)')
else:
print('!!! WARNING: XSPEC_table.txt not generated, skip Xray flux and Sx')
#---------- Spectra
if 'all' in prod_list or 'spectra' in prod_list:
# CR protons
eng, spec = self.get_crp_spectrum(energy, Rmax=Rmax)
spectra(energy, (energy/const.h).to('GHz'), spec.to('GeV-1'),
self._output_dir+'/PLOT_SPEC_CRproton.pdf', label='Volume integrated CRp (GeV$^{-1}$)')
if not self._silent: print('----- Plot done: CRp spectrum')
# CR electrons
eng, spec = self.get_cre_spectrum(energy, Rmax=Rmax)
spectra(energy, (energy/const.h).to('GHz'), spec.to('GeV-1'),
self._output_dir+'/PLOT_SPEC_CRelectron.pdf', label='Volume integrated CRe (GeV$^{-1}$)')
if not self._silent: print('----- Plot done: CRe spectrum')
# gamma
eng, spec = self.get_gamma_spectrum(energy, Rmax=Rmax, type_integral='spherical')
spectra(energy, (energy/const.h).to('GHz'), (energy**2*spec).to('GeV cm-2 s-1'),
self._output_dir+'/PLOT_SPEC_gamma.pdf',
label='$F_{\\gamma}$(<R, sph) (GeV cm$^{-2}$ s$^{-1}$)')
if not self._silent: print('----- Plot done: gamma spectrum')
# Gamma integrated flux spectrum
spec = self.get_gamma_flux(Emin=energy, Emax=Egmax, Rmax=Rmax, Energy_density=False, type_integral='spherical')
spectra(energy, (energy/const.h).to('GHz'), spec.to('cm-2 s-1'),
self._output_dir+'/PLOT_SPEC_gammaF.pdf', label='$\\gamma$-ray flux (>E, sph) (cm$^{-2}$ s$^{-1}$)')
if not self._silent: print('----- Plot done: gamma integrated flux (E)')
# neutrino
eng, spec = self.get_neutrino_spectrum(energy, Rmax=Rmax, type_integral='spherical', flavor='all')
spectra(energy, (energy/const.h).to('GHz'), (energy**2*spec).to('GeV cm-2 s-1'),
self._output_dir+'/PLOT_SPEC_neutrino.pdf', label='$F_{\\nu}$(<R, sph) (GeV cm$^{-2}$ s$^{-1}$)')
if not self._silent: print('----- Plot done: neutrino spectrum')
# neutrino integrated flux spectrum
spec = self.get_neutrino_flux(Emin=energy, Emax=Egmax, Rmax=Rmax, Energy_density=False, type_integral='spherical',
flavor='all')
spectra(energy, (energy/const.h).to('GHz'), spec.to('cm-2 s-1'),
self._output_dir+'/PLOT_SPEC_neutrinoF.pdf',label='$\\nu$ flux (>E, sph) (cm$^{-2}$ s$^{-1}$)')
if not self._silent: print('----- Plot done: neutrino integrated flux (E)')
# IC
eng, spec = self.get_ic_spectrum(energy, Rmax=Rmax, type_integral='spherical')
spectra(energy, (energy/const.h).to('GHz'), (energy**2*spec).to('GeV cm-2 s-1'),
self._output_dir+'/PLOT_SPEC_InverseCompton.pdf',label='$F_{IC}$(<R, sph) (GeV cm$^{-2}$ s$^{-1}$)')
if not self._silent: print('----- Plot done: IC spectrum')
# IC integrated flux spectrum
spec = self.get_ic_flux(Emin=energy, Emax=Egmax, Rmax=Rmax, Energy_density=False, type_integral='spherical')
spectra(energy, (energy/const.h).to('GHz'), spec.to('cm-2 s-1'), self._output_dir+'/PLOT_SPEC_InverseComptonF.pdf',
label='IC flux (>E, sph) (cm$^{-2}$ s$^{-1}$)')
if not self._silent: print('----- Plot done: IC integrated flux (E)')
# Synchrotron
freq, spec = self.get_synchrotron_spectrum(frequency, Rmax=Rmax, type_integral='spherical')
spectra((freq*const.h).to('eV'), freq, spec.to('Jy'), self._output_dir+'/PLOT_SPEC_Synchrotron.pdf',
label='$F_{synch}$(<R, sph) (Jy)')
if not self._silent: print('----- Plot done: Synchrotron spectrum')
# SZ
freq, spec = self.get_sz_spectrum(frequency, Rmax=Rmax, type_integral='spherical', Compton_only=False)
spectra((freq*const.h).to('eV'), freq, np.abs(spec.to('Jy')), self._output_dir+'/PLOT_SPEC_SZ.pdf',
label='$|F_{SZ}|$(<R, sph) (Jy)')
if not self._silent: print('----- Plot done: SZ spectrum')
# Xray
if os.path.exists(self._output_dir+'/XSPEC_table.txt'):
engX, spec = self.get_xray_spectrum(energyX, Rmax=Rmax, type_integral='spherical', output_type='C')
spectra(engX.to('keV'), (engX/const.h).to('GHz'), spec.to('cm-2 s-1 keV-1'), self._output_dir+'/PLOT_SPEC_X.pdf',
label='$S_{X}$(<R, sph) (cm$^{-2}$ s$^{-1}$ keV${-1}$)')
if not self._silent: print('----- Plot done: Xray spectrum')
else:
print('!!! WARNING: XSPEC_table.txt not generated, skip Xray spectrum')
#---------- Map
if 'all' in prod_list or 'map' in prod_list:
header = self.get_map_header()
# gamma
image = self.get_gamma_map(Emin=Egmin, Emax=Egmax, Energy_density=False, Normalize=False).to_value('cm-2 s-1 sr-1')
maps(image, header, self._output_dir+'/PLOT_MAP_gamma.pdf', label='$\\gamma$-ray, '+Egstrlim+' (cm$^{-2}$ s$^{-1}$ sr$^{-1}$)',
coord=self._coord, theta_500=self._theta500, theta_trunc=self._theta_truncation, logscale=True)
if not self._silent: print('----- Plot done: gamma map')
# neutrino
image = self.get_neutrino_map(Emin=Egmin, Emax=Egmax, Energy_density=False, Normalize=False, flavor='all').to_value('cm-2 s-1 sr-1')
maps(image, header, self._output_dir+'/PLOT_MAP_neutrino.pdf', label='$\\nu$, '+Egstrlim+' (cm$^{-2}$ s$^{-1}$ sr$^{-1}$)',
coord=self._coord, theta_500=self._theta500, theta_trunc=self._theta_truncation, logscale=True)
if not self._silent: print('----- Plot done: neutrino map')
# IC
image = self.get_ic_map(Emin=Egmin, Emax=Egmax, Energy_density=False, Normalize=False).to_value('cm-2 s-1 sr-1')
maps(image, header, self._output_dir+'/PLOT_MAP_inverseCompton.pdf', label='IC, '+Egstrlim+' (cm$^{-2}$ s$^{-1}$ sr$^{-1}$)',
coord=self._coord, theta_500=self._theta500, theta_trunc=self._theta_truncation, logscale=True)
if not self._silent: print('----- Plot done: IC map')
# Synchrotron
image = self.get_synchrotron_map(freq0=freq0, Normalize=False).to_value('Jy sr-1')
maps(image, header, self._output_dir+'/PLOT_MAP_synchrotron.pdf', label='Synchrotron, '+str(freq0)+' (Jy sr$^{-1}$)',
coord=self._coord, theta_500=self._theta500, theta_trunc=self._theta_truncation, logscale=True)
if not self._silent: print('----- Plot done: Synchrotron map')
# SZ ymap
image = self.get_sz_map(Compton_only=True, Normalize=False).to_value('adu')
maps(image*1e6, header, self._output_dir+'/PLOT_MAP_SZy.pdf',
label='Compton parameter $\\times 10^{6}$', coord=self._coord, theta_500=self._theta500,
theta_trunc=self._theta_truncation, logscale=True)
if not self._silent: print('----- Plot done: SZ ymap')
# Xray
if os.path.exists(self._output_dir+'/XSPEC_table.txt'):
image = self.get_xray_map(output_type='C').to_value('s-1 cm-2 sr-1')
maps(image, header, self._output_dir+'/PLOT_MAP_X.pdf', label='X-ray (s$^{-1}$ cm$^{-2}$ sr$^{-1}$)',
coord=self._coord, theta_500=self._theta500, theta_trunc=self._theta_truncation, logscale=True)
if not self._silent: print('----- Plot done: Xray map')
else:
print('!!! WARNING: XSPEC_table.txt not generated, skip PLOT_MAP_X')