def __init__(self): # module to calculate Pi0 cross section from cparamlib.cparamlib import ID_GAMMA from cparamlib.ParamModel import ParamModel self.param = ParamModel(Tp=0,particle=ID_GAMMA) self.erg_to_gev = float(u.erg/u.GeV) self.millibarn_to_cm2 = float(u.millibarn/u.cm**2)
class PPCrossSection(CrossSection): """ Object to calculate the proton-proton cross section for decaying into gammas. This module using a parameterization of numerical pi0 decay codes described in Kamae et al 2006: http://arxiv.org/abs/astro-ph/0605581 And performs the calculation by wraping the numerical codes they provide in the swig interface to cparamlib To install cparamlib so that it can be accessed through python, please visit this very nice page: http://homepages.spa.umn.edu/~nkarlsson/cparamlib/ """ def __init__(self): # module to calculate Pi0 cross section from cparamlib.cparamlib import ID_GAMMA from cparamlib.ParamModel import ParamModel self.param = ParamModel(Tp=0,particle=ID_GAMMA) self.erg_to_gev = float(u.erg/u.GeV) self.millibarn_to_cm2 = float(u.millibarn/u.cm**2) def __call__(self, proton_energy,photon_energy): """ Computes the proton proton cross section to decay into a gamma. proton_energy is the energy of the incident proton, in units of erg photon_energy is the energy of the resultant gamma, in units of erg The return cross section is d(sigma)/dE where E is the photon energy, sigma is in units of cm**2, and E is in units of erg. Implementation Note: Sigma_incl_tot returns the photon spectrum including all processes. sigma_incl_tot returns dsigma/dlog(E) in units of mb. The two inputs must be in units of GeV and dlog(E) is calculated (I assume) in units of GeV """ photon_energy_gev = photon_energy*self.erg_to_gev proton_energy_gev = proton_energy*self.erg_to_gev # Currently, cparamlib is not vecotrized, so vectorize it here :( if isinstance(proton_energy_gev,np.ndarray): dsigmadloge = np.asarray([self.param.sigma_incl_tot(photon_energy_gev, i) \ for i in proton_energy_gev]) else: dsigmadloge = self.param.sigma_incl_tot(photon_energy_gev, proton_energy_gev) # convert from cross section per log(energy) in units of millibarn # to cross section per(energy) in units of cm^2 dsigmade = self.millibarn_to_cm2*dsigmadloge*(1/photon_energy) return dsigmade