/
make_simulated_surveys.py
executable file
·165 lines (140 loc) · 7.15 KB
/
make_simulated_surveys.py
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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
#!/usr/bin/env python
# Script for generating simulated surveys for measuring bar fractions as a
# function of stellar mass or gas mass ratio. Outputs are stored in the
# directory specified by baseDirSurv.
from __future__ import print_function
import simulate_surveys
# output directory for simulation results
baseDirSurv = "./data/"
# column headers for output files
colHeaders_logmstar = "# logMstar medFbar sigma_low sigma_high\n"
colHeaders_logfgas = "# log_fgas medFbar sigma_low sigma_high\n"
# random-number-generator seed used for simulations in paper; change for
# different pseudorandom number sequences (set = None to have the seed
# be based on the current time)
randomSeed = 100
# * Simulations measuring f_bar as a function of stellar mass for GZ2-style surveys
# GZoo -- M_star, D < 30 Mpc:
# 10,000 galaxies, to match typical sample sizes in GZ2 and other SDSS surveys
n = 10000
nFWHM = 2.0
zrange_mstar = [0.01, 0.05]
mstar_bincenters, fmed, flow, fhigh = simulate_surveys.GenerateAndObserveNTimes(200, simulate_surveys.dset_d30_sp,
zrange_mstar, n, nFWHM*1.4, 9.0, 11.25, 0.25, useObservedSizes=False, randomSeed=randomSeed)
sigma_minus_2fwhm = fmed - flow
sigma_plus_2fwhm = fhigh - fmed
ff = baseDirSurv + "sim_logMstar_d30_sp_2xfwhm_SDSS_200_dp-sizes.txt"
outf = open(ff, 'w')
outf.write(colHeaders_logmstar)
for i in range(len(fmed)):
outf.write("%.2f %.4f %.4f %.4f\n" % (mstar_bincenters[i], fmed[i], sigma_minus_2fwhm[i], sigma_plus_2fwhm[i]))
outf.close()
print("Output saved to %s." % ff)
# * Simulations measuring f_bar as a function of gas mass ratio for GZ2-style surveys
# GZoo -- f_gas, D < 30 Mpc, log(M_star) > 9.5:
# 2000 galaxies, to match sample size in Masters+2012, Cervantes Sodi 2017
n = 2000
zrange_fgas = [0.01,0.05]
fgas_bincenters, fmed, flow, fhigh = simulate_surveys.GenerateAndObserveNTimes(200, simulate_surveys.dset_d30m95_sp,
zrange_fgas, n, nFWHM*1.4, -2,1,0.5, value='fgas', useObservedSizes=False, useHILimit=False, randomSeed=randomSeed, debug=True)
sigma_minus_2fwhm = fmed - flow
sigma_plus_2fwhm = fhigh - fmed
ff = baseDirSurv + "sim_logfgas_d30_2xfwhm_SDSS_200_dp-sizes.txt"
outf = open(ff, 'w')
outf.write(colHeaders_logfgas)
for i in range(len(fmed)):
outf.write("%.2f %.4f %.4f %.4f\n" % (fgas_bincenters[i], fmed[i], sigma_minus_2fwhm[i], sigma_plus_2fwhm[i]))
outf.close()
print("Output saved to %s." % ff)
# Same, but now including simple H I detection threshold
fgas_bincenters, fmed, flow, fhigh = simulate_surveys.GenerateAndObserveNTimes(200, simulate_surveys.dset_d30m95_sp,
zrange_fgas, n, nFWHM*1.4, -2,1,0.5, value='fgas', useObservedSizes=False, useHILimit=True, randomSeed=randomSeed, debug=True)
sigma_minus_2fwhm = fmed - flow
sigma_plus_2fwhm = fhigh - fmed
ff = baseDirSurv + "sim_logfgas_d30m95_sp_2xfwhm_SDSS_200_HI-limited.txt"
outf = open(ff, 'w')
outf.write(colHeaders_logfgas)
for i in range(len(fmed)):
outf.write("%.2f %.4f %.4f %.4f\n" % (fgas_bincenters[i], fmed[i], sigma_minus_2fwhm[i], sigma_plus_2fwhm[i]))
outf.close()
print("Output saved to %s." % ff)
# * Simulation for f_bar as a function of stellar mass in an
# HST-style survey (e.g., Sheth+2008) -- high-z range
zrange_075 = [0.60,0.84]
n = 1000
mstar_bincenters, fmed, flow, fhigh = simulate_surveys.GenerateAndObserveNTimes(200, simulate_surveys.dset_d30_sp,
zrange_075, n, nFWHM*0.1, 9.0, 11.5, 0.25, useObservedSizes=False, randomSeed=randomSeed)
sigma_minus_2fwhm = fmed - flow
sigma_plus_2fwhm = fhigh - fmed
ff = baseDirSurv + "sim_logMstar_d30_sp_2xfwhm_HST_z0.60-0.84_200_dp-sizes.txt"
outf = open(ff, 'w')
outf.write(colHeaders_logmstar)
for i in range(len(fmed)):
outf.write("%.2f %.4f %.4f %.4f\n" % (mstar_bincenters[i], fmed[i], sigma_minus_2fwhm[i], sigma_plus_2fwhm[i]))
outf.close()
print("Output saved to %s." % ff)
# Same, but now assuming all bars have half their z=0 size
mstar_bincenters, fmed, flow, fhigh = simulate_surveys.GenerateAndObserveNTimes(200, simulate_surveys.dset_d30_sp,
zrange_075, n, nFWHM*0.1, 9.0, 11.5, 0.25, useObservedSizes=False, scaleSizes=0.5, randomSeed=randomSeed)
sigma_minus_2fwhm = fmed - flow
sigma_plus_2fwhm = fhigh - fmed
ff = baseDirSurv + "sim_logMstar_d30_sp_2xfwhm_HST_z0.60-0.84_200_dp-sizes_scale0.5.txt"
outf = open(ff, 'w')
outf.write(colHeaders_logmstar)
for i in range(len(fmed)):
outf.write("%.2f %.4f %.4f %.4f\n" % (mstar_bincenters[i], fmed[i], sigma_minus_2fwhm[i], sigma_plus_2fwhm[i]))
outf.close()
print("Output saved to %s." % ff)
# Simulations for observing S4G sample at intermediate redshifts with HST
# HST-style survey (e.g., Sheth+2008) -- medium-z range
zrange_05 = [0.37,0.60]
n = 1000
mstar_bincenters, fmed, flow, fhigh = simulate_surveys.GenerateAndObserveNTimes(200, simulate_surveys.dset_d30_sp,
zrange_05, n, nFWHM*0.1, 9.0, 11.5, 0.25, useObservedSizes=False, randomSeed=randomSeed)
sigma_minus_2fwhm = fmed - flow
sigma_plus_2fwhm = fhigh - fmed
ff = baseDirSurv + "sim_logMstar_d30_sp_2xfwhm_HST_z0.37-0.60_200_dp-sizes.txt"
outf = open(ff, 'w')
outf.write(colHeaders_logmstar)
for i in range(len(fmed)):
outf.write("%.2f %.4f %.4f %.4f\n" % (mstar_bincenters[i], fmed[i], sigma_minus_2fwhm[i], sigma_plus_2fwhm[i]))
outf.close()
print("Output saved to %s." % ff)
# Same, but now assuming all bars have half their z=0 size
mstar_bincenters, fmed, flow, fhigh = simulate_surveys.GenerateAndObserveNTimes(200, simulate_surveys.dset_d30_sp,
zrange_05, n, nFWHM*0.1, 9.0, 11.5, 0.25, useObservedSizes=False, scaleSizes=0.5, randomSeed=randomSeed)
sigma_minus_2fwhm = fmed - flow
sigma_plus_2fwhm = fhigh - fmed
ff = baseDirSurv + "sim_logMstar_d30_sp_2xfwhm_HST_z0.37-0.60_200_dp-sizes_scale0.5.txt"
outf = open(ff, 'w')
outf.write(colHeaders_logmstar)
for i in range(len(fmed)):
outf.write("%.2f %.4f %.4f %.4f\n" % (mstar_bincenters[i], fmed[i], sigma_minus_2fwhm[i], sigma_plus_2fwhm[i]))
outf.close()
print("Output saved to %s." % ff)
# HST-style survey (e.g., Sheth+2008) -- low-z range
zrange_05 = [0.14,0.37]
n = 1000
mstar_bincenters, fmed, flow, fhigh = simulate_surveys.GenerateAndObserveNTimes(200, simulate_surveys.dset_d30_sp,
zrange_05, n, nFWHM*0.1, 9.0, 11.5, 0.25, useObservedSizes=False, randomSeed=randomSeed)
sigma_minus_2fwhm = fmed - flow
sigma_plus_2fwhm = fhigh - fmed
ff = baseDirSurv + "sim_logMstar_d30_sp_2xfwhm_HST_z0.14-0.37_200_dp-sizes.txt"
outf = open(ff, 'w')
outf.write(colHeaders_logmstar)
for i in range(len(fmed)):
outf.write("%.2f %.4f %.4f %.4f\n" % (mstar_bincenters[i], fmed[i], sigma_minus_2fwhm[i], sigma_plus_2fwhm[i]))
outf.close()
print("Output saved to %s." % ff)
# Same, but now assuming all bars have half their z=0 size
mstar_bincenters, fmed, flow, fhigh = simulate_surveys.GenerateAndObserveNTimes(200, simulate_surveys.dset_d30_sp,
zrange_05, n, nFWHM*0.1, 9.0, 11.5, 0.25, useObservedSizes=False, scaleSizes=0.5, randomSeed=randomSeed)
sigma_minus_2fwhm = fmed - flow
sigma_plus_2fwhm = fhigh - fmed
ff = baseDirSurv + "sim_logMstar_d30_sp_2xfwhm_HST_z0.14-0.37_200_dp-sizes_scale0.5.txt"
outf = open(ff, 'w')
outf.write(colHeaders_logmstar)
for i in range(len(fmed)):
outf.write("%.2f %.4f %.4f %.4f\n" % (mstar_bincenters[i], fmed[i], sigma_minus_2fwhm[i], sigma_plus_2fwhm[i]))
outf.close()
print("Output saved to %s." % ff)