@@ -15,13 +15,27 @@ def histograms_energy_zenith(
1515 when dividing these matrices you get the some response which,
1616 when normalised correctly, corresponds to the collection area.
1717
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
1932 '''
2033
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 )
2337
24- selected_events_energy = selected_events [ 'energy ' ].apply (np .log10 )
38+ all_events_zenith = all_events [ 'zenith ' ].apply (np .rad2deg )
2539 selected_events_zenith = selected_events ['zenith' ].apply (np .rad2deg )
2640
2741 hist_all , energy_edges , zenith_edges = np .histogram2d (
@@ -43,14 +57,28 @@ def histograms_energy(
4357 all_events ,
4458 selected_events ,
4559 bins_energy ,
60+ target = 'corsika_evt_header_total_energy' ,
4661 log = True ,
4762 ):
4863 '''
4964 calculate the matrices from the analysed and the simulated events.
5065 when dividing these matrices you get the some response which,
5166 when normalised correctly, corresponds to the collection area.
5267
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
5482 '''
5583
5684 if log is True :
@@ -79,6 +107,7 @@ def collection_area_energy(
79107 selected_events ,
80108 bins_energy ,
81109 impact ,
110+ target = 'corsika_evt_header_total_energy' ,
82111 log = True ,
83112 sample_fraction = None ,
84113 ):
@@ -88,19 +117,24 @@ def collection_area_energy(
88117 Parameters
89118 ----------
90119 all_events: pd.DataFrame
91- DataFrame with all simulated events, must contain column "energy"
120+ DataFrame with all simulated events.
92121 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.
95123 bins_energy: int or array-like
96124 either number of bins or bin edges for the histogram in energy
97125 impact: astropy Quantity of type length
98126 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.
99132 sample_fraction: float or None
100133 If not None, the fraction of `all_events` that was analysed
101134 to create `selected_events`
102135 '''
103136
137+ selected_events ['energy' ] = selected_events [target ].copy ()
104138 hist_all , hist_selected , energy_edges = histograms_energy (
105139 all_events ,
106140 selected_events ,
0 commit comments