Exemplo n.º 1
0
def test_box_coordinates():
    """Check that pixel and frequency coordinates are returned."""

    # Realise Gaussian box
    np.random.seed(22)
    box = CosmoBox(cosmo=default_cosmo,
                   box_scale=(1e3, 1e3, 1e3),
                   nsamp=16,
                   realise_now=True,
                   redshift=0.8)

    # Check pixel array
    ang_x, ang_y = box.pixel_array()
    ang_x2, ang_y2 = box.pixel_array(redshift=0.82)
    # ^Higher z, so further away, so smaller angle

    # Check for valid output
    assert np.all(~np.isnan(ang_x))
    assert np.all(~np.isnan(ang_y))
    assert np.all(~np.isnan(ang_x2))
    assert np.all(~np.isnan(ang_y2))

    # Square box => equal pixel sizes
    assert np.isclose(ang_x[1] - ang_x[0], ang_y[1] - ang_y[0])

    # Check that higher redshift pixels are smaller
    assert ang_x[1] - ang_x[0] > ang_x2[1] - ang_x2[0]
    assert ang_y[1] - ang_y[0] > ang_y2[1] - ang_y2[0]

    # Check that frequency array goes in descending order (highest z coord =>
    # lowest frequency)
    assert np.all(np.diff(box.freq_array()) < 0.)  # negative differences
    assert np.all(
        np.diff(box.freq_array(redshift=2.)) < 0.)  # negative differences
Exemplo n.º 2
0
#-------------------------------------------------------------------------------
# Add foregrounds
#-------------------------------------------------------------------------------
print("(2) Adding foregrounds...")
t0 = time.time()

# Create new foreground model
fg = ForegroundModel(box)
fg_map = fg.realise_foreground_amp(amp=57.,
                                   beta=1.1,
                                   monopole=10.,
                                   smoothing_scale=4.,
                                   redshift=box.redshift)  # in mK

# Construct spectral index map
ang_x, ang_y = box.pixel_array(redshift=box.redshift)
alpha = fg.realise_spectral_index(mean_spec_idx=2.07,
                                  std_spec_idx=0.0002,
                                  smoothing_scale=15.,
                                  redshift=box.redshift)

# Construct foreground datacube
fg_cube = fg.construct_cube(fg_map,
                            alpha,
                            freq_ref=130.,
                            redshift=box.redshift)

# Add to data cube
data_cube = signal_cube + fg_cube

print("\t(2) Adding foregrounds complete (%3.3f sec)" % (time.time() - t0))