This repository has been archived by the owner on Mar 17, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
/
BackgroundPlotter_All.py
88 lines (59 loc) · 3.22 KB
/
BackgroundPlotter_All.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
#!/usr/bin/env python
""" Plot the background components from the class LEOBackgroundGenerator
And save it as a pdf
"""
__author__ = 'Paolo Cumani'
import matplotlib.pyplot as plt
import numpy as np
import argparse
from LEOBackgroundGenerator import LEOBackgroundGenerator as LEO
# Instantiate the parser
pars = argparse.ArgumentParser(description='Plot the background'
+ ' components from the class'
+ ' LEOBackgroundGenerator')
pars.add_argument('-i', '--inclination', type=float, nargs='?',
default=0., help='Inclination of the orbit in degree [0.]')
pars.add_argument('-a', '--altitude', type=float, nargs='?',
default=550., help='Altitude of the orbit in km [550.]')
pars.add_argument('-o', '--outputpdf', type=str, nargs='?',
default="FullSpectrum", help='Name of the output pdf [FullSpectrum]')
args = pars.parse_args()
Energies = np.logspace(1, 8, num=1000000, endpoint=True, base=10.0)
LeoBack = LEO(args.altitude, args.inclination)
LeoBackfunc = [LeoBack.AtmosphericNeutrons, LeoBack.CosmicPhotons,
LeoBack.PrimaryProtons, LeoBack.SecondaryProtonsUpward,
LeoBack.PrimaryAlphas, LeoBack.PrimaryElectrons,
LeoBack.PrimaryPositrons, LeoBack.SecondaryElectrons,
LeoBack.SecondaryPositrons, LeoBack.AlbedoPhotons,
LeoBack.GalacticCenter, LeoBack.GalacticDisk]
Title = ["Atmospheric Neutrons", "Cosmic Photons", "Primary Protons",
"Secondary Protons", "Primary Alphas", "Primary Electrons",
"Primary Positrons", "Secondary Electrons", "Secondary Positrons",
"Albedo Photons", "Galactic Center", "Galactic Disk"]
colors = ['darkred', 'darkorange', 'darkgreen', 'steelblue', 'darkblue',
'orchid', 'red', 'darkgrey', 'mediumseagreen', 'black',
'gold', 'hotpink']
dash = [(5, 0), (5, 2), (5, 2, 1, 2), (2, 1), (5, 5), (5, 3, 3, 3),
(5, 10), (5, 3, 3, 3), (5, 5, 5, 5), (3, 5),
(9, 2), (7, 3)]
fig1, ax1 = plt.subplots(nrows=1, ncols=1, sharex=True, figsize=(12, 8))
plt.minorticks_on()
ax1.grid(color='lightgrey', which='major', linestyle='-', linewidth=1)
ax1.grid(color='lightgrey', which='minor', linestyle='--', linewidth=1)
for i in range(0, len(LeoBackfunc)):
masknan = np.logical_and(~np.isnan(LeoBackfunc[i](Energies)), LeoBackfunc[i](Energies) > 0.)
ax1.loglog(Energies[masknan]/1000,
10000*1000*LeoBackfunc[i](Energies)[masknan],
color=colors[i], linestyle='--', dashes=dash[i], label=Title[i])
handles, labels = ax1.get_legend_handles_labels()
ax1.set_xlim([Energies[0]/1000, Energies[-1]/1000])
ax1.set_ylim([10**(-6), 10**7])
ax1.title.set_text("Background spectrum in a low Earth orbit (LEO)")
ax1.title.set_size(20)
ax1.set_ylabel(r'Flux / m$^{-2}$s$^{-1}$MeV$^{-1}$sr$^{-1}$',
verticalalignment='bottom', labelpad=20, fontsize=15)
legend = ax1.legend(handles, labels, loc='upper right',
prop={'size': 15}, fancybox=True)
legend.get_frame().set_alpha(0.9)
ax1.set_xlabel(r'Energy / MeV', verticalalignment='center', labelpad=20, fontsize=15)
fig1.savefig(args.outputpdf+".pdf", bbox_inches='tight')