@@ -74,16 +74,45 @@ def power_law(
74
74
return flux_normalization * (energy / e_ref )** (spectral_index )
75
75
76
76
77
+ def power_law_exponential_cutoff (
78
+ energy : u .TeV ,
79
+ flux_normalization : (FLUX_UNIT , POINT_SOURCE_FLUX_UNIT ),
80
+ spectral_index ,
81
+ e_cutoff : u .TeV ,
82
+ e_ref : u .TeV = 1 * u .TeV ,
83
+ ):
84
+ r'''
85
+ A power law with an additional exponential cutoff
86
+
87
+ .. math::
88
+ \phi = \phi_0 \cdot (E / E_{\mathrm{ref}})^{\gamma} \cdot e^{- E / E_{\mathrm{cutoff}}}
89
+
90
+ Parameters
91
+ ----------
92
+ energy: Quantity[energy]
93
+ energy points to evaluate
94
+ flux_normalization: Quantity[m**-2 s**-2 TeV**-1]
95
+ Flux normalization
96
+ spectral_index: float
97
+ Spectral index
98
+ e_ref: Quantity[energy]
99
+ The reference energy
100
+ '''
101
+ tau = np .exp (energy / e_cutoff )
102
+ return power_law (energy , flux_normalization , spectral_index , e_ref ) * tau
103
+
104
+
77
105
@u .quantity_input
78
- def curved_power_law (
106
+ def log_parabola (
79
107
energy : u .TeV ,
80
108
flux_normalization : (FLUX_UNIT , POINT_SOURCE_FLUX_UNIT ),
81
109
a ,
82
110
b ,
83
- e_ref : u .TeV = 1 * u .TeV ,
111
+ e_ref : u .TeV = 1 * u .TeV ,
84
112
):
85
113
r'''
86
- Curved power law
114
+ Log-Parabola power law, power law with an additional energy dependent term
115
+ in the exponent.
87
116
88
117
.. math::
89
118
\phi = \phi_0 \cdot E ^ {a + b \cdot \log_{10}(E)}
@@ -95,13 +124,13 @@ def curved_power_law(
95
124
flux_normalization: float
96
125
Flux normalization
97
126
a: float
98
- Parameter `a` of the curved power law
127
+ Parameter `a` of the curved power law
99
128
b: float
100
- Parameter `b` of the curved power law
129
+ Parameter `b` of the curved power law
101
130
e_ref: Quantity[energy]
102
131
The reference energy
103
132
'''
104
- exp = a + b * np .log10 (( energy / e_ref ) )
133
+ exp = a + b * np .log10 (energy / e_ref )
105
134
return flux_normalization * (energy / e_ref ) ** exp
106
135
107
136
@@ -146,37 +175,41 @@ def li_ma_significance(n_on, n_off, alpha=0.2):
146
175
147
176
148
177
@u .quantity_input
149
- def calc_weight_simple_to_curved (
178
+ def calc_weight_power_to_logparabola (
150
179
energy : u .TeV ,
151
- spectral_index ,
152
- a ,
153
- b ,
180
+ simulated_index ,
181
+ target_a ,
182
+ target_b ,
154
183
e_ref : u .TeV = 1 * u .TeV ,
155
184
):
156
185
'''
157
186
Reweight simulated events from a simulated power law with
158
187
spectral index `spectral_index` to a curved power law with parameters `a` and `b`
159
188
189
+ phi(E) = phi_0 (E / E_ref)^(a + b * log10(E / E_ref))
190
+
160
191
Parameters
161
192
----------
162
193
energy: float or array-like
163
194
Energy of the events
164
- spectral_index : float
195
+ simulated_index : float
165
196
Spectral index of the simulated power law
166
- a : float
197
+ target_a : float
167
198
Parameter `a` of the target curved power law
168
- b : float
199
+ target_b : float
169
200
Parameter `b` of the target curved power law
170
201
'''
171
- return (energy / e_ref ) ** (spectral_index + a + b * np .log10 (energy / e_ref ))
202
+ return (energy / e_ref ) ** (
203
+ target_a + target_b * np .log10 (energy / e_ref ) - simulated_index
204
+ )
172
205
173
206
174
207
@u .quantity_input
175
208
def calc_weight_change_index (
176
209
energy : u .TeV ,
177
210
simulated_index ,
178
211
target_index ,
179
- e_ref : u .TeV = 1 * u .TeV ,
212
+ e_ref : u .TeV = 1 * u .TeV ,
180
213
):
181
214
'''
182
215
Reweight simulated events from one power law index to another
@@ -204,7 +237,7 @@ def calc_gamma_obstime(
204
237
e_ref : u .TeV = 1 * u .TeV ,
205
238
) -> u .s :
206
239
r'''
207
- Calculate the equivalent observation time for a number of simulation enents
240
+ Calculate the equivalent observation time for a number of simulation events
208
241
209
242
The number of events produced by sampling from a power law with
210
243
spectral index γ is given by
0 commit comments