Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,21 @@ The following optional dependencies are needed for some of the foreground modell
* `multiprocessing`
* `GPy`

INSTALLATION IN A CONDA ENVIRONMENT

conda create -n fast-env python=3.8 pyccl=2.3.0 scikit-learn scikit-image healpy lmfit -c bccp -c conda-forge -y

git clone https://github.com/philbull/FastBox.git

cd Fastbox

python setup.py install

If want to use katbeam model:

pip install git+https://github.com/ska-sa/katbeam.git


## Current features

- Gaussian and log-normal density fields for any cosmology
Expand Down
1 change: 1 addition & 0 deletions docs/power.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
::: fastbox.power
10 changes: 4 additions & 6 deletions examples/example_box.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
import numpy as np
import pylab as plt
from fastbox.box import CosmoBox, default_cosmo
from nbodykit.algorithms.fftpower import FFTPower
from nbodykit.lab import ArrayMesh
from numpy import fft
import sys

Expand All @@ -29,7 +27,7 @@
plt.colorbar()
plt.show()

sys.exit(0)
#sys.exit(0)


# Trim negative values
Expand Down Expand Up @@ -65,7 +63,7 @@
plt.show()


sys.exit(0)
#sys.exit(0)

# Gaussian box with beam smoothing and foreground cut
transfer_fn = lambda k_perp, k_par: \
Expand Down Expand Up @@ -103,7 +101,7 @@
plt.show()


sys.exit(0)
#sys.exit(0)


# Log-normal box
Expand All @@ -127,7 +125,7 @@
#plt.errorbar(re_k, re_pk, yerr=re_stddev, fmt=".", color='r')
plt.plot(re_k, re_pk, 'r.', label="P(k) from density field")
plt.plot(lnre_k, lnre_pk, 'gx', label="P(k) from log-normal")
plt.xscale('log')
plt.xscale('log')ples
plt.yscale('log')
plt.legend(loc='lower left', frameon=False)

Expand Down
49 changes: 17 additions & 32 deletions examples/example_endtoend.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
import fastbox
from fastbox.box import CosmoBox, default_cosmo
from fastbox.foregrounds import ForegroundModel
from nbodykit.lab import ArrayMesh
from nbodykit.algorithms.fftcorr import FFTCorr
from nbodykit.algorithms.fftpower import FFTPower
import time, sys
#from nbodykit.algorithms.fftpower import FFTPower
#import time, sys
from fastbox.beams import KatBeamModel
import time

#-------------------------------------------------------------------------------
# Realise density field in redshift space
Expand Down Expand Up @@ -72,27 +72,32 @@

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

#-------------------------------------------------------------------------------
# Beam convolution
#-------------------------------------------------------------------------------
print("(3) Beam convolving...")

freqs = box.freq_array(redshift=0.8)
kbm = KatBeamModel(box, model='L')
data_cube = kbm.convolve_fft(data_cube,pol='I')

print("Beam convolved succesfully!")
#-------------------------------------------------------------------------------
# Add noise
#-------------------------------------------------------------------------------
print("(3) Adding noise...")
print("(4) Adding noise...")
t0 = time.time()

# Generate homogeneous radiometer noise
noise_model = fastbox.noise.NoiseModel(box)
noise_cube = noise_model.realise_radiometer_noise(Tinst=18., tp=2., fov=1.,
Ndish=64) # FIXME: Long integration time!
Ndish=64)

# Add to data cube
data_cube += noise_cube

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

#-------------------------------------------------------------------------------
# Beam convolution
#-------------------------------------------------------------------------------

# FIXME


#-------------------------------------------------------------------------------
Expand All @@ -109,7 +114,6 @@
cleaned_cube8, U_fg, amp_fg = fastbox.filters.pca_filter(data_cube,
nmodes=12,
return_filter=True)
#cleaned_cube = data_cube # FIXME

print("\t(4) Cleaning foregrounds complete (%3.3f sec)" % (time.time()-t0))
#-------------------------------------------------------------------------------
Expand Down Expand Up @@ -196,26 +200,7 @@

plt.xscale('log')
plt.yscale('log')
#plt.show()
plt.show()

#sys.exit(0)

# Plot correlation functions and vanilla theoretical prediction
plt.figure()
plt.subplot(111)
r = corr_true['r']
h = box.cosmo['h']

rr = np.linspace(2., 200., 300)
xi = ccl.correlation_multipole(box.cosmo, a=box.scale_factor, l=0, s=rr, beta=0.)

plt.subplot(111)
plt.plot(rr, rr**2. * xi * tracer.signal_amplitude()**2., 'k-')
plt.plot(r, r**2. * corr_true['corr'], 'r.', label="True field")
plt.plot(r, r**2. * corr_proc4['corr'], 'bx', label="4 modes")
plt.plot(r, r**2. * corr_proc4_hp['corr'], 'ys', label="4 modes (high-pass)")
plt.plot(r, r**2. * corr_proc8['corr'], 'g+', label="4 modes")
plt.xlabel("r", fontsize=16)
plt.ylabel(r"$r^2 \xi(r)$", fontsize=16)

plt.show()
383 changes: 383 additions & 0 deletions examples/gal_tracer.ipynb

Large diffs are not rendered by default.

Loading