コード例 #1
0
ファイル: test_box.py プロジェクト: philbull/FastBox
def test_box_redshift_space_density():
    """Check that a redshift-space density field can be generated."""

    # Realise Gaussian box and velocity field
    np.random.seed(11)
    box = CosmoBox(cosmo=default_cosmo,
                   box_scale=(1e2, 1e2, 1e2),
                   nsamp=16,
                   realise_now=False)
    box.realise_density()
    box.realise_velocity()

    # Get redshift-space density field
    vel_z = np.fft.ifftn(box.velocity_k[2]).real
    delta_s = box.redshift_space_density(delta_x=box.delta_x,
                                         velocity_z=vel_z,
                                         sigma_nl=200.,
                                         method='linear')

    # Check that redshift-space density field is valid
    assert delta_s.shape == (16, 16, 16)
    # assert delta_s.dtype == np.float64
    assert np.all(~np.isnan(delta_s))
コード例 #2
0
from fastbox.box import CosmoBox, default_cosmo
from numpy import fft

# Gaussian box
np.random.seed(10)
box = CosmoBox(cosmo=default_cosmo,
               box_scale=(1e2, 1e2, 1e2),
               nsamp=128,
               realise_now=False)
box.realise_density()
box.realise_velocity()

# Plot real-space density field
plt.matshow(box.delta_x[0], vmin=-1., vmax=20., cmap='cividis')
plt.title("Real-space")
plt.colorbar()

# Get redshift-space density field
vel_z = fft.ifftn(box.velocity_k[2]).real

delta_s = box.redshift_space_density(delta_x=box.delta_x,
                                     velocity_z=vel_z,
                                     sigma_nl=200.,
                                     method='linear')

plt.matshow(delta_s[0], vmin=-1., vmax=20., cmap='cividis')
plt.title("Redshift-space")
plt.colorbar()

plt.show()
コード例 #3
0
ファイル: example_endtoend.py プロジェクト: philbull/FastBox
# (1b) Rescale tracer by bias [FIXME: Check this is being done in the right order]
tracer = fastbox.tracers.HITracer(box)
delta_hi = box.delta_x * tracer.bias_HI()

# (1c) Transform to a log-normal field
delta_ln = box.lognormal(delta_hi)

# (1d) Calculate radial velocity field (uses Gaussian density field; FIXME)
vel_k = box.realise_velocity(delta_x=box.delta_x, inplace=True)
vel_z = fft.ifftn(
    vel_k[2]).real  # inverse FFT to get real-space radial velocity

# (1e) Transform to redshift space
delta_s = box.redshift_space_density(delta_x=delta_ln.real,
                                     velocity_z=vel_z,
                                     sigma_nl=120.,
                                     method='linear')

# (1f) Scale by mean brightness temperature (in mK), and include mean
signal_cube = tracer.signal_amplitude() * (1. + delta_s)

print("\t(1) Generating box complete (%3.3f sec)" % (time.time() - t0))

#-------------------------------------------------------------------------------
# Add foregrounds
#-------------------------------------------------------------------------------
print("(2) Adding foregrounds...")
t0 = time.time()

# Create new foreground model
fg = ForegroundModel(box)