Gundam Example LRG
Example code to estimate a 2D projected correlation function using a sample of SDSS Luminous Red Galaxies.
[1]:
from astropy.table import Table
from gundam import gundam as gun
[2]:
# DEFINE PARAMETERS
galf = "../../tests/data/DR7-lrg.fits" # Galaxy sample
ranf = "../../tests/data/DR7-lrg-rand.fits" # Random sample
outfn = "../../tests/data/ex_LRG" # Name for output files
[3]:
par = gun.packpars(kind="pcf", file=galf, file1=ranf, outfn=outfn)
par.autogrid = False # Automatic SK grid size
par.mxh1 = 60 # SK size in dec
par.mxh2 = 240 # SK size in ra
par.mxh3 = 24 # SK size in z
par.nsepp = 78 # Number of bins of projected separation rp
par.seppmin = 0.01 # Minimum rp in Mpc/h
par.dsepp = 0.5 # Bin size of rp (in log space)
par.logsepp = 0 # Use linear bins instead of log bins
par.nsepv = 60 # Number of bins of LOS separation pi
par.dsepv = 0.5 # Bin size of pi (in linear space)
par.doboot = True # Do bootstrap error estimates
par.omegam = 0.25 # Omega matter
par.omegal = 0.75 # Omega lambda
par.h0 = 100 # Hubble constant [km/s/Mpc]
par.calcdist = True # Calculate comov. dist.
par.estimator = "LS" # Choose Landy-Szalay estimator for the PCF
par.description = "LumRedGxs" # Description label
[4]:
# READ DATA FILES
print("Reading file: ", galf)
gals = Table.read(galf)
if "wei" not in gals.colnames:
gals["wei"] = 1.0 # If not present, set weights to 1
print("Reading file: ", ranf)
rans = Table.read(ranf)
if "wei" not in rans.colnames:
rans["wei"] = 1.0 # If not present, set weights to 1
Reading file: ../../tests/data/DR7-lrg.fits
Reading file: ../../tests/data/DR7-lrg-rand.fits
[5]:
# CALCULATE THE CORRELATION
nt = 4 # Threads to use
cnt = gun.pcf(gals, rans, par, nthreads=nt)
START! 06/13/24 15:13:39
Name of output set to : ../../tests/data/ex_LRG
Calling Information ================================================
table = ../../tests/data/DR7-lrg.fits
table_nrows = 105831
table1 = ../../tests/data/DR7-lrg-rand.fits
table1_nrows = 832474
nthreads = 4
write = True
plot = False
=====================================================================
Comov_dist_tab compute time (s) : 0.553
Comov_dist_tab1 compute time (s) : 0.682
Sample boundaries : (0.00000, 360.00000, -11.24575, 70.27845, 464.68988, 1273.97723)
Sample seems to cross RA=0 : True
Custom RA boundaries : None
SK Autogrid : OFF
SK grid size [dec,ra,dcom] : [60, 240, 24]
SK grid1 size [dec,ra,dcom] : [60, 240, 24]
Pixsort time (s) : 0.496
SK-LL tables build time (s) : 0.039
==== Counting DD pairs in 60 DEC strips =====
[for progress updates check ../../tests/data/ex_LRG.fortran.log]
Done with DD calculations. Looptime (s) : 0.436
==== Counting DD pairs in 60 DEC strips ====
1 16 2 28 3 4 5 6 7 8 37 9 17 29 10 38 11 18 30 39 12 40 31 19 13 41 14 32 20 42 33 15 21 43 22 23 44 48 24 34 49 45 50 35 25 46 51 47 52 36 26 55 53 56 57 54 58 59 60 27
==== Counting RR pairs in 60 DEC strips =====
[for progress updates check ../../tests/data/ex_LRG.fortran.log]
Done with RR calculations. Looptime (s) : 3.730
==== Counting RR pairs in 60 DEC strips ====
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
==== Counting DR pairs in 60 DEC strips =====
[for progress updates check ../../tests/data/ex_LRG.fortran.log]
==== Counting DR pairs in 60 DEC strips
Done with DR calculations. Looptime (s) : 1.129
Computing proj. correlation function.....[tpcf_wrp()]
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
DONE! 06/13/24 15:13:47
Loop | Total time (s) : 5.29 | 7.68
> w(rp) PCF saved in : ../../tests/data/ex_LRG.wrp
> ASCII counts saved in : ../../tests/data/ex_LRG.dd
> ASCII counts saved in : ../../tests/data/ex_LRG.rr
> ASCII counts saved in : ../../tests/data/ex_LRG.dr
> PARAMS saved in : ../../tests/data/ex_LRG.par
> COUNTS object saved in : ../../tests/data/ex_LRG.cnt
[6]:
# NOW PLOT THE 2-DIMENSIONAL PCF
gun.cntplot2D(cnt, write=True)
/home/docs/checkouts/readthedocs.org/user_builds/gundam/envs/stable/lib/python3.10/site-packages/gundam/gundam.py:1436: RuntimeWarning: invalid value encountered in log10
logxi = np.log10(xi)