def test_concentration_methods(): from plutokore.environments.makino import MakinoProfile from plutokore.environments.king import KingProfile from astropy import units as u from astropy import cosmology conc_methods = [ 'dolag', 'bullock', 'klypin-planck-all', 'klypin-planck-relaxed', 'klypin-wmap-all', 'klypin-wmap-relaxed', 'dutton', 'maccio' ] mass = (10**12.5) * u.M_sun z = 0 for cm in conc_methods: mp = MakinoProfile(mass, z, cosmo=cosmology.Planck15, concentration_method=cm) kp = KingProfile(mass, z, cosmo=cosmology.Planck15, concentration_method=cm) assert mp.concentration != 0.0 assert kp.concentration != 0.0
def main(): fig = plt.figure() ax = fig.add_subplot(111, projection='3d') mass = (10**12.5) * u.M_sun z = 0 makino_env_12p5 = MakinoProfile( mass, z, delta_vir=200, cosmo=cosmology.Planck15, concentration_method='klypin-planck-relaxed') theta_deg = 15 M_x = 25 Q = 1e37 * u.W jet_12p5 = jet.AstroJet(theta_deg, M_x, makino_env_12p5.sound_speed, makino_env_12p5.central_density, Q, makino_env_12p5.gamma) data = pk.simulations.load_timestep_data(452, '../tests/data/pluto/') z = 0.1 beam_width = 5 * u.arcsec uv = jet.get_unit_values(makino_env_12p5, jet_12p5) l = radio.get_luminosity(data, uv, z, beam_width, ) f = radio.get_flux_density(l, z) fc = radio.get_convolved_flux_density(f, z, beam_width) sb = radio.get_surface_brightness(f, data, uv, z, beam_width) cmap = plt.cm.plasma norm = mpl.colors.Normalize(vmin=-3, vmax=0) colors = cmap(norm(np.log10(sb.to(u.mJy).T.value))) k = 0 for i in range(0, 360, 90): #r = np.arange(1, 11) #θ = np.arange(0, 100, 10) r = data.x1[:600] θ = data.x2 φ = np.deg2rad(np.full_like(r, i)) rr, θθ, φφ = np.meshgrid(r, θ, φ) xx = rr * np.sin(θθ) * np.cos(φφ) yy = rr * np.sin(θθ) * np.sin(φφ) zz = rr * np.cos(θθ) #ax.plot(xx[:,:,1], yy[:,:,1], zs=φφ[:,1,1], zdir='z') #ax.plot(xx[:,:,1], yy[:,:,1], zs=zz[:,1,1], color=f'C{k}') #ax.plot(xx[:,:,1].T, yy[:,:,1].T, zs=zz[1,:,1], color=f'C{k}') ax.plot_surface(xx[:,:,1], yy[:,:,1], zz[:,:,1], linewidth=0, antialiased=True, alpha=1, facecolors=colors) ax.set_aspect('equal') k += 1 sc = mpl.cm.ScalarMappable(cmap=cmap, norm=norm) sc.set_array([]) plt.colorbar(sc) plt.show()
def makino_env_12p5(): from plutokore.environments.makino import MakinoProfile mass = (10**12.5) * u.M_sun z = 0 return MakinoProfile( mass, z, delta_vir=200, cosmo=cosmology.Planck15, concentration_method='klypin-planck-relaxed')
def test_default_cosmology(): from plutokore.environments.makino import MakinoProfile from plutokore.environments.king import KingProfile from astropy import units as u from astropy import cosmology mass = (10**12.5) * u.M_sun z = 0 mp = MakinoProfile(mass, z, concentration_method='klypin-planck-relaxed') kp = KingProfile(mass, z, concentration_method='klypin-planck-relaxed') assert mp.cosmo is cosmology.Planck15 assert kp.cosmo is cosmology.Planck15
def test_default_conc_method(): from plutokore.environments.makino import MakinoProfile from plutokore.environments.king import KingProfile from astropy import units as u from astropy import cosmology mass = (10**12.5) * u.M_sun z = 0 mp = MakinoProfile(mass, z) kp = KingProfile(mass, z) assert mp.concentration != 0.0 assert kp.concentration != 0.0
def test_wrong_concentration_method(): from plutokore.environments.makino import MakinoProfile from plutokore.environments.king import KingProfile from astropy import units as u from astropy import cosmology try: mass = (10**12.5) * u.M_sun z = 0 mp = MakinoProfile(mass, z, cosmo=cosmology.Planck15, concentration_method='invalid') assert 0 except ValueError: pass try: kp = KingProfile(mass, z, cosmo=cosmology.Planck15, concentration_method='invalid') assert 0 except ValueError: pass
def main(): fig = plt.figure() ax = fig.add_subplot(111) mass = (10**12.5) * u.M_sun redshift = 0 makino_env_12p5 = MakinoProfile( mass, redshift, delta_vir=200, cosmo=cosmology.Planck15, concentration_method='klypin-planck-relaxed') theta_deg = 15 M_x = 25 Q = 1e37 * u.W jet_12p5 = jet.AstroJet(theta_deg, M_x, makino_env_12p5.sound_speed, makino_env_12p5.central_density, Q, makino_env_12p5.gamma) data = pk.simulations.load_timestep_data(452, '../tests/data/pluto/') redshift = 0.1 beam_width = 5 * u.arcsec uv = jet.get_unit_values(makino_env_12p5, jet_12p5) l = radio.get_luminosity(data, uv, redshift, beam_width, ) f = radio.get_flux_density(l, redshift) #sb = radio.get_surface_brightness(f, data, uv, redshift, beam_width).to(u.Jy).value #sb = radio.convolve_surface_brightness(sb, uv, redshift, beam_width).to(u.Jy) sb = f.to(u.Jy).value xmax=30 xstep=1 zmax=60 zstep=1 ymax = max(xmax, zmax) ystep = min(xstep, zstep) x = np.arange(0, xmax, xstep) z = np.arange(0, zmax, zstep) y = np.arange(-ymax, ymax, ystep) final = np.zeros((x.shape[0], z.shape[0])) raytrace_surface_brightness( r=data.x1, θ=data.x2, x=x, y=y, z=z, final=final, sb=sb ) final = final * u.Jy kpc_per_arcsec = cosmology.Planck15.kpc_proper_per_arcmin(redshift).to(u.kpc / u.arcsec) # beam information sigma_beam_arcsec = beam_width / 2.355 area_beam_kpc2 = (np.pi * (sigma_beam_arcsec * kpc_per_arcsec) **2).to(u.kpc**2) radio_cell_areas = np.full(final.shape, xstep * zstep) # in physical units radio_cell_areas_physical = radio_cell_areas * uv.length**2 # n beams per cell n_beams_per_cell = (radio_cell_areas_physical / area_beam_kpc2).si final = final / n_beams_per_cell final_convolved = radio.convolve_surface_brightness(final, uv, redshift, beam_width) # rr, θθ = np.meshgrid(r, θ) # x = r * np.sin(θθ) * np.cos(φ) # y = r * np.sin(θθ) * np.sin(φ) # z = r * np.cos(θθ) #im = ax.pcolormesh(x, z, np.log10(sb.to(u.mJy).T.value), vmin=-3, vmax=0, cmap='viridis') im = ax.pcolormesh(x, z, np.log10(final_convolved.to(u.mJy).T.value), vmin=-3, vmax=3, cmap='viridis') fig.colorbar(im) ax.set_xlim(0, 30) ax.set_ylim(0, 60) ax.set_aspect('equal') plt.show()