@@ -15,13 +15,27 @@ def histograms_energy_zenith(
15
15
when dividing these matrices you get the some response which,
16
16
when normalised correctly, corresponds to the collection area.
17
17
18
- returns hist_all, hist_selected, energy_edges, zenith_edges
18
+ Parameters
19
+ ----------
20
+ all_events: pd.DataFrame
21
+ DataFrame with all simulated events.
22
+ Must contain columns named 'zenith' and 'energy'
23
+ selected_events: pd.DataFrame
24
+ DataFrame with events that survived event selection.
25
+ Must contain columns named 'zenith' and 'energy'
26
+ bins_energy: int or array-like
27
+ either number of bins or bin edges for the histogram in energy
28
+ log: bool
29
+ flag indicating whether log10 should be applied to the energy.
30
+
31
+ returns: hist_all, hist_selected, energy_edges, zenith_edges
19
32
'''
20
33
21
- all_events_energy = all_events ['energy' ].apply (np .log10 )
22
- all_events_zenith = all_events ['zenith' ].apply (np .rad2deg )
34
+ if log :
35
+ all_events_energy = all_events ['energy' ].apply (np .log10 )
36
+ selected_events_energy = selected_events ['energy' ].apply (np .log10 )
23
37
24
- selected_events_energy = selected_events [ 'energy ' ].apply (np .log10 )
38
+ all_events_zenith = all_events [ 'zenith ' ].apply (np .rad2deg )
25
39
selected_events_zenith = selected_events ['zenith' ].apply (np .rad2deg )
26
40
27
41
hist_all , energy_edges , zenith_edges = np .histogram2d (
@@ -43,14 +57,28 @@ def histograms_energy(
43
57
all_events ,
44
58
selected_events ,
45
59
bins_energy ,
60
+ target = 'corsika_evt_header_total_energy' ,
46
61
log = True ,
47
62
):
48
63
'''
49
64
calculate the matrices from the analysed and the simulated events.
50
65
when dividing these matrices you get the some response which,
51
66
when normalised correctly, corresponds to the collection area.
52
67
53
- returns hist_all, hist_selected, energy_edges
68
+ Parameters
69
+ ----------
70
+ all_events: pd.DataFrame
71
+ DataFrame with all simulated events.
72
+ Must contain column named 'energy'
73
+ selected_events: pd.DataFrame
74
+ DataFrame with events that survived event selection.
75
+ Must contain column named 'energy'
76
+ bins_energy: int or array-like
77
+ either number of bins or bin edges for the histogram in energy
78
+ log: bool
79
+ flag indicating whether log10 should be applied to the energy.
80
+
81
+ returns: hist_all, hist_selected, energy_edges
54
82
'''
55
83
56
84
if log is True :
@@ -79,6 +107,7 @@ def collection_area_energy(
79
107
selected_events ,
80
108
bins_energy ,
81
109
impact ,
110
+ target = 'corsika_evt_header_total_energy' ,
82
111
log = True ,
83
112
sample_fraction = None ,
84
113
):
@@ -88,19 +117,24 @@ def collection_area_energy(
88
117
Parameters
89
118
----------
90
119
all_events: pd.DataFrame
91
- DataFrame with all simulated events, must contain column "energy"
120
+ DataFrame with all simulated events.
92
121
selected_events: pd.DataFrame
93
- DataFrame with events that survived event selection,
94
- must contain column "energy"
122
+ DataFrame with events that survived event selection.
95
123
bins_energy: int or array-like
96
124
either number of bins or bin edges for the histogram in energy
97
125
impact: astropy Quantity of type length
98
126
The maximal simulated impact parameter
127
+ target: string
128
+ The key name of the energy variable. Default 'corsika_evt_header_total_energy'
129
+ for getting the collection area vs the true energy.
130
+ log: bool
131
+ flag indicating whether log10 should be applied to the energy.
99
132
sample_fraction: float or None
100
133
If not None, the fraction of `all_events` that was analysed
101
134
to create `selected_events`
102
135
'''
103
136
137
+ selected_events ['energy' ] = selected_events [target ].copy ()
104
138
hist_all , hist_selected , energy_edges = histograms_energy (
105
139
all_events ,
106
140
selected_events ,
0 commit comments