def mock_real_galaxy(): """Mock real galaxy.""" dm = np.loadtxt(TEST_DATA_REAL_PATH / "dark.dat") s = np.loadtxt(TEST_DATA_REAL_PATH / "star.dat") g = np.loadtxt(TEST_DATA_REAL_PATH / "gas_.dat") gal = core.Galaxy( m_s=s[:, 0] * 1e10 * u.M_sun, x_s=s[:, 1] * u.kpc, y_s=s[:, 2] * u.kpc, z_s=s[:, 3] * u.kpc, vx_s=s[:, 4] * (u.km / u.s), vy_s=s[:, 5] * (u.km / u.s), vz_s=s[:, 6] * (u.km / u.s), m_dm=dm[:, 0] * 1e10 * u.M_sun, x_dm=dm[:, 1] * u.kpc, y_dm=dm[:, 2] * u.kpc, z_dm=dm[:, 3] * u.kpc, vx_dm=dm[:, 4] * (u.km / u.s), vy_dm=dm[:, 5] * (u.km / u.s), vz_dm=dm[:, 6] * (u.km / u.s), m_g=g[:, 0] * 1e10 * u.M_sun, x_g=g[:, 1] * u.kpc, y_g=g[:, 2] * u.kpc, z_g=g[:, 3] * u.kpc, vx_g=g[:, 4] * (u.km / u.s), vy_g=g[:, 5] * (u.km / u.s), vz_g=g[:, 6] * (u.km / u.s), ) return gal
def mock_galaxy(disc_particles_all, halo_particles): """Mock galaxy.""" (mass_s, pos_s, vel_s, mass_g, pos_g, vel_g) = disc_particles_all mass_dm, pos_dm, vel_dm = halo_particles(N_part=100, seed=42) g = core.Galaxy( m_s=mass_s * u.M_sun, x_s=pos_s[:, 0] * u.kpc, y_s=pos_s[:, 1] * u.kpc, z_s=pos_s[:, 2] * u.kpc, vx_s=vel_s[:, 0] * (u.km / u.s), vy_s=vel_s[:, 1] * (u.km / u.s), vz_s=vel_s[:, 2] * (u.km / u.s), m_dm=mass_dm * u.M_sun, x_dm=pos_dm[:, 0] * u.kpc, y_dm=pos_dm[:, 1] * u.kpc, z_dm=pos_dm[:, 2] * u.kpc, vx_dm=vel_dm[:, 0] * (u.km / u.s), vy_dm=vel_dm[:, 1] * (u.km / u.s), vz_dm=vel_dm[:, 2] * (u.km / u.s), m_g=mass_g * u.M_sun, x_g=pos_g[:, 0] * u.kpc, y_g=pos_g[:, 1] * u.kpc, z_g=pos_g[:, 2] * u.kpc, vx_g=vel_g[:, 0] * (u.km / u.s), vy_g=vel_g[:, 1] * (u.km / u.s), vz_g=vel_g[:, 2] * (u.km / u.s), ) return g
def test_all_potential_inputs(pot_name, npart, random_galaxy_params): """Test of potential inputs.""" seed = 42 random = np.random.RandomState(seed=seed) pot = random.random_sample(size=npart) params = random_galaxy_params(stars=10, dm=20, gas=30, seed=42) params[pot_name] = pot with pytest.raises(ValueError): core.Galaxy(**params)
def test_potential_validator(random_galaxy_params): seed = 42 random = np.random.RandomState(seed=seed) pot_star = random.random_sample(size=10) pot_drk = random.random_sample(size=20) pot_gas = random.random_sample(size=30) params = random_galaxy_params(stars=10, dm=20, gas=30, seed=42) params["pot_s"] = pot_star params["pot_dm"] = pot_drk params["pot_g"] = pot_gas with pytest.raises(ValueError): core.Galaxy(**params).potential_energy()
def test_same_size_inputs(shorten, random_galaxy_params): """Test of inputs lengths.""" params = random_galaxy_params(stars=10, dm=20, gas=30, seed=42) params[shorten] = params[shorten][:-1] with pytest.raises(ValueError): core.Galaxy(**params)