File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11import numpy as np
22import astropy .units as u
3+ from functools import partial
34
45POINT_SOURCE_FLUX_UNIT = (1 / u .GeV / u .s / u .m ** 2 ).unit
56FLUX_UNIT = POINT_SOURCE_FLUX_UNIT / u .sr
67
78PDG_COSMIC_RAY_FLUX = 1.8e4 * FLUX_UNIT
89PDG_COSMIC_RAY_E_REF = 1 * u .GeV
10+ PDG_COSMIC_RAY_INDEX = - 2.7
911
1012
1113@u .quantity_input
@@ -14,7 +16,7 @@ def random_power(
1416 e_min : u .TeV ,
1517 e_max : u .TeV ,
1618 size ,
17- e_ref : u .TeV = 1 * u .TeV ,
19+ e_ref : u .TeV = 1 * u .TeV ,
1820) -> u .TeV :
1921 r'''
2022 Draw random numbers from a power law distribution
@@ -458,3 +460,15 @@ def calc_proton_obstime(
458460 )
459461
460462 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