def __init__(self, log10MeV, g=1, m=1, nsim=1, B0=10., seed=None, ppb=10, lambda_min=0.7, lambda_max=35., q=-2.80): self.log10MeV = log10MeV self.B0 = B0 self.nsim = nsim self.g = g self.m = m self.seed = seed self._seed = seed self.ppb = ppb self.pin = np.diag((1.0, 1.0, 0.)) * 0.5 self.q = q self.kL = 2. * np.pi / lambda_max self.kH = 2. * np.pi / lambda_min # self.set_up_energy() self.alp = ALP(self.m, self.g) self.source = Source(z=0.017559, ra='03h19m48.1s', dec='+41d30m42s')
def propagation(self, EGeV, m=1., g=1., B0=10., seed=None, nsim=1): '''Runs the propagation in magnetic fields, copied from me-manu, NGC1257 example notebook. Returns: Probabilities of finding photon (transversal1, 2) and ALP. Currently not used. Rather use read_probs() to use pre-computed probabilities saving time and thus being able to run on standard BIRD-computation slots. ''' alp = ALP(m, g) ngc1275 = Source(z=0.017559, ra='03h19m48.1s', dec='+41d30m42s') pin = np.diag((1., 1., 0.)) * 0.5 lambda_max = 35. lambda_min = 0.7 kL = 2. * np.pi / lambda_max kH = 2. * np.pi / lambda_min m = ModuleList(alp, ngc1275, pin=pin, EGeV=EGeV) print('m:'), m.alp.m print('g:'), m.alp.g print('B:'), B0 m.add_propagation( "ICMGaussTurb", 0, # position of module counted from the source. nsim=nsim, # number of random B-field realizations B0=B0, # rms of B field n0=39., # normalization of electron density n2= 4.05, # second normalization of electron density, see Churazov et al. 2003, Eq. 4 r_abell=500., # extension of the cluster r_core= 80., # electron density parameter, see Churazov et al. 2003, Eq. 4 r_core2= 280., # electron density parameter, see Churazov et al. 2003, Eq. 4 beta= 1.2, # electron density parameter, see Churazov et al. 2003, Eq. 4 beta2= 0.58, # electron density parameter, see Churazov et al. 2003, Eq. 4 eta=0.5, # scaling of B-field with electron denstiy kL= kL, # maximum turbulence scale in kpc^-1, taken from A2199 cool-core cluster, see Vacca et al. 2012 kH= kH, # minimum turbulence scale, taken from A2199 cool-core cluster, see Vacca et al. 2012 q=-2.80, # turbulence spectral index, taken from A2199 cool-core cluster, see Vacca et al. 2012 seed= seed # random seed for reproducability, set to None for random seed. ) m.add_propagation( "EBL", 1, model='dominguez' ) # EBL attenuation comes second, after beam has left cluster m.add_propagation( "GMF", 2, model='jansson12', model_sum='ASS') # finally, the beam enters the Milky Way Field px, py, pa = m.run() self.px = px self.py = py self.pa = pa self.p = px + py
def __init__(self, walkerfile, Mprog=10., cosmo=FlatLambdaCDM(H0=0.7 * 100. * u.km / u.s / u.Mpc, Tcmb0=2.725 * u.K, Om0=0.3)): """ Init the class Parameters ---------- walkerfile: str path to MOSFIT results file which contains the walkers {options} Mprog: float mass of progenitor in solar masses, currently only 10. and 18. solar masses are implemented cosmo: `astropy.cosmology.FlatLambdaCDM` the chosen cosmology. Default: 737 """ with open(walkerfile, 'r') as f: data = json.loads(f.read()) if 'name' not in data: data = data[list(data.keys())[0]] # SN coordinates self._c = SkyCoord(ra=data['ra'][0]['value'], dec=data['dec'][0]['value'], unit=(u.hourangle, u.deg)) self._z = np.mean([ float(data['redshift'][i]['value']) for i in range(len(data['redshift'])) ]) self._src = Source(z=self._z, ra=float(self._c.ra.value), dec=float(self._c.dec.value)) self._cosmo = cosmo # class to compute ALP flux self._Mprog = Mprog self._alp = ALPSNSignal(Mprog=Mprog) # constant to calculate flux: dl = self._cosmo.luminosity_distance(self._z) self.fluxconstant = 1. / 4. / np.pi / dl.to('cm').value**2.
def __init__(self, walkerfile=None, ra=None, dec=None, Mprog=10., z=None, cosmo=FlatLambdaCDM(H0=0.7 * 100. * u.km / u.s / u.Mpc, Tcmb0=2.725 * u.K, Om0=0.3)): """ Init the class Parameters ---------- walkerfile: str or None path to MOSFIT results file which contains the walkers if None, ra, dec, and z have to be provided ra: str or None Right Ascension as string in degrees dec: str or None Declination as string in degrees z: float or None Redshift {options} Mprog: float mass of progenitor in solar masses, currently only 10. and 18. solar masses are implemented cosmo: `astropy.cosmology.FlatLambdaCDM` the chosen cosmology. Default: 737 """ if walkerfile is not None: with open(walkerfile, 'r') as f: data = json.loads(f.read()) if 'name' not in data: data = data[list(data.keys())[0]] self._c = SkyCoord(ra=data['ra'][0]['value'], dec=data['dec'][0]['value'], unit=(u.hourangle, u.deg)) self._z = np.mean([ float(data['redshift'][i]['value']) for i in range(len(data['redshift'])) ]) else: if ra is None or dec is None or z is None: raise ValueError( "No walkerfile given and no ra and dec provided!") self._c = SkyCoord(ra=ra, dec=dec, unit=(u.deg, u.deg)) self._z = z # SN coordinates self._src = Source(z=self._z, ra=float(self._c.ra.value), dec=float(self._c.dec.value)) self._cosmo = cosmo # class to compute ALP flux self._Mprog = Mprog self._alp = ALPSNSignal(Mprog=Mprog) # constant to calculate flux: dl = self._cosmo.luminosity_distance(self._z) self.fluxconstant = 1. / 4. / np.pi / dl.to('cm').value**2.
g_space = np.logspace(-1., 2., num=30, base=10.0, endpoint=True) # in 1e-11 1/GeV m_space = np.logspace(-1., 2., num=30, base=10.0, endpoint=True) # in neV grid = np.zeros((g_space.shape[0], m_space.shape[0], 2)) for i in range(g_space.shape[0]): for j in range(m_space.shape[0]): grid[i, j, :] = g_space[i], m_space[j] grid = grid.reshape((m_space.shape[0] * g_space.shape[0], 2)) # prob dont need those two, later done in for loop #g = grid[input_num, 0] #m = grid[input_num, 1] '''Set up ALP''' ngc1275 = Source(z=0.017559, ra='03h19m48.1s', dec='+41d30m42s') pin = np.diag((1., 1., 0.)) * 0.5 lambda_max = 35. lambda_min = 0.7 kL = 2. * np.pi / lambda_max kH = 2. * np.pi / lambda_min '''Energy binning related stuff goes here''' log10MeV = np.loadtxt(cwd + '/energy_bins.dat') # full_length = log10MeV.shape[0] # half_length = int(np.ceil(full_length / 2)) # if part == 1: # log10MeV = log10MeV[0:half_length] # elif part == 2: # log10MeV = log10MeV[half_length:] EGeV = np.power(10., log10MeV - 3.) nbins = EGeV.shape[0]
# initial polarization pin = np.diag((0.,0.,1.)) # cosmology cosmo = FlatLambdaCDM(H0 = 70., Om0 = 0.3) # loop over the sntable and ALP masses c = OrderedDict() # columns for new table c['name'] = tsn['name'].data c['time'] = [] for t in tsn: src = Source(z = float(t['z']), ra = float(t['ra']), dec = float(t['dec'])) mod = ModuleList(ALP(m=1.,g=args.gref), src, pin = pin, EGeV = EMeV / 1e3) mod.add_propagation("GMF",0, model = 'jansson12', model_sum = 'ASS') c['time'].append(ts) for i,m in enumerate(mneV): if not '{0:.3f}'.format(m) in c.keys(): c['{0:.3f}'.format(m)] = [] mod.alp.m = m px,py,pa = mod.run(multiprocess=2) # calculate photon flux in photons / MeV / s / cm^2: d = cosmo.luminosity_distance(t['z'])