Commit 641d439 1 parent 56c6f9e commit 641d439 Copy full SHA for 641d439
File tree 1 file changed +15
-1
lines changed
1 file changed +15
-1
lines changed Original file line number Diff line number Diff line change 1
1
import numpy as np
2
2
import astropy .units as u
3
+ from functools import partial
3
4
4
5
POINT_SOURCE_FLUX_UNIT = (1 / u .GeV / u .s / u .m ** 2 ).unit
5
6
FLUX_UNIT = POINT_SOURCE_FLUX_UNIT / u .sr
6
7
7
8
PDG_COSMIC_RAY_FLUX = 1.8e4 * FLUX_UNIT
8
9
PDG_COSMIC_RAY_E_REF = 1 * u .GeV
10
+ PDG_COSMIC_RAY_INDEX = - 2.7
9
11
10
12
11
13
@u .quantity_input
@@ -14,7 +16,7 @@ def random_power(
14
16
e_min : u .TeV ,
15
17
e_max : u .TeV ,
16
18
size ,
17
- e_ref : u .TeV = 1 * u .TeV ,
19
+ e_ref : u .TeV = 1 * u .TeV ,
18
20
) -> u .TeV :
19
21
r'''
20
22
Draw random numbers from a power law distribution
@@ -458,3 +460,15 @@ def calc_proton_obstime(
458
460
)
459
461
460
462
return (t_ref * phi_sim / flux_normalization ).to (u .hour )
463
+
464
+
465
+ calc_weights_cosmic_rays = partial (
466
+ calc_weights_powerlaw ,
467
+ target_index = PDG_COSMIC_RAY_INDEX ,
468
+ flux_normalization = PDG_COSMIC_RAY_FLUX ,
469
+ e_ref = PDG_COSMIC_RAY_E_REF ,
470
+ )
471
+ calc_weights_cosmic_rays .__doc__ = '''
472
+ Calculate event weights, so that simulated
473
+ events are reweighted to the PDG cosmic rays spectrum
474
+ '''
You can’t perform that action at this time.
0 commit comments