-
Notifications
You must be signed in to change notification settings - Fork 0
/
cosmo_run.sh
147 lines (135 loc) · 3.5 KB
/
cosmo_run.sh
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
#This script is meant to be run in sequencially
#CAREFUL: If ran in parallel things will get messed
#up
#It runs cosmosis and writes the C_l's in the file
#.Cl_out.dat
#The ordering of the bins is logged in
#.log_ordering.dat
#Parameters:
#
#$1: dndz_filename
#$2: lmin
#$3: lmax
#$4: om_m
#$5: w
#$6: h
#$7: A_s
#$8: om_b
#$9: n_s
#${10}: galbias
#find out how many redshift bins dndz_filename has
num_cols=$(awk '{print NF}' $1 | sort -nu | tail -n 1)
echo $num_cols
#pad with zeros in front and back of the dndz file
python pad_dndz.py $1
cat <<EOT >> .explanatory.ini
h = $6
T_cmb = 2.726
Omega_b = $8
N_ur = 3.046
Omega_cdm = $4
Omega_dcdmdr = 0.0
Gamma_dcdm = 0.0
N_ncdm = 0
Omega_k = 0.
Omega_Lambda = 0.70
w0_fld = $5
wa_fld = 0.
cs2_fld = 1
YHe = BBN
recombination = RECFAST
reio_parametrization = reio_camb
z_reio = 10.
reionization_exponent = 1.5
reionization_width = 1.5
helium_fullreio_redshift = 3.5
helium_fullreio_width = 0.5
annihilation = 0.
annihilation_variation = 0.
annihilation_z = 1000
annihilation_zmax = 2500
annihilation_zmin = 30
annihilation_f_halo = 20
annihilation_z_halo = 8
on the spot = yes
decay = 0.
output = sCl
number count contributions =
non linear = HALOFIT
modes = s
ic = ad
gauge = synchronous
P_k_ini type = analytic_Pk
k_pivot = 0.05
A_s = $7
n_s = $9
alpha_s = 0.
l_max_lss = $3
selection=yourfile
selection_mean = $(python -c "print ','.join([str(0.1 + 0.01*m) for m in range($num_cols-1)])")
selection_width = $(python -c "print ','.join([str(0.2 + 0.02*m) for m in range($num_cols-1)])")
non_diagonal=$(python -c "print $num_cols - 2")
selection_bias =0
selection_magnification_bias = 0
l_switch_limber_for_nc_local_over_z = 1
l_switch_limber_for_nc_los_over_z = 1
selection_filename=$1
selection_biask_arr=0.0
selection_bias0_arr= ${10}
selection_bias1_arr=0.
root = .output
headers = yes
format = class
write background = no
write thermodynamics = no
write primordial = no
write parameters = yeap
input_verbose = 1
background_verbose = 1
thermodynamics_verbose = 1
perturbations_verbose = 1
transfer_verbose = 1
primordial_verbose = 1
spectra_verbose = 1
nonlinear_verbose = 1
lensing_verbose = 1
output_verbose = 1
EOT
#cleanup the parameter and
#input files for cosmosis
#even if the run fails
{ # this is my bash try block
./class .explanatory.ini &&
rm .explanatory.ini
rm .outputparameters.ini
rm .outputunused_parameters
} || { # this is catch block
rm .explanatory.ini
rm .outputparameters.ini
rm .outputunused_parameters
}
#This part takes all the calculated cl's from
#cosmosis and pastes them into a convinient
#file. It also outputs a log of the bin ordering
#imposed
awk 'NR==7{print}' .outputcl.dat | grep -o '[0-9]\{1,5\}]' | tr -d ] > .prelim_log_ordering.dat
awk 'NR%2==1{print}' .prelim_log_ordering.dat > .prelim_first_column.dat
awk 'NR%2==0{print}' .prelim_log_ordering.dat > .prelim_second_column.dat
paste .prelim_first_column.dat .prelim_second_column.dat > .log_ordering.dat
rm .prelim_first_column.dat
rm .prelim_second_column.dat
rm .prelim_log_ordering.dat
mv .outputcl.dat .Cl_out.dat
#now interpolate the Cl's accordingly
#divide the prefactor l(l + 1)/(2*pi)
#if third argument is lensing then transform lensing potential powerspectrum
#to kappa power spectrum, if nolensing then don't transform (e.g. if galaxy clustering)
# python divide_prefact.py .outputcl.dat .pre_outputcl.dat lensing
# rm .outputcl.dat
# mv .pre_outputcl.dat .outputcl.dat
#
#
# python interpolate_cl.py .outputcl.dat .Cl_out_interp.dat $2 $3
#
# rm .outputcl.dat
# mv .Cl_out_interp.dat .Cl_out.dat