Initial import
This commit is contained in:
commit
56a50eead3
820 changed files with 192077 additions and 0 deletions
111
scripts/ini_generator/gen_subcat_conf.py
Normal file
111
scripts/ini_generator/gen_subcat_conf.py
Normal file
|
@ -0,0 +1,111 @@
|
|||
#+
|
||||
# ARES/HADES/BORG Package -- ./scripts/ini_generator/gen_subcat_conf.py
|
||||
# Copyright (C) 2014-2020 Guilhem Lavaux <guilhem.lavaux@iap.fr>
|
||||
# Copyright (C) 2009-2020 Jens Jasche <jens.jasche@fysik.su.se>
|
||||
#
|
||||
# Additional contributions from:
|
||||
# Guilhem Lavaux <guilhem.lavaux@iap.fr> (2023)
|
||||
#
|
||||
#+
|
||||
import sys
|
||||
import os.path
|
||||
import argparse
|
||||
|
||||
pp = argparse.ArgumentParser()
|
||||
pp.add_argument('--output', type=str, required=True)
|
||||
pp.add_argument('--configs', type=str, required=True)
|
||||
pp.add_argument('--header', type=str, required=True)
|
||||
args = pp.parse_args()
|
||||
out_ini= args.output
|
||||
all_config_files=args.configs.split(':')
|
||||
|
||||
|
||||
|
||||
subcat_id=0
|
||||
|
||||
PATTERN="""datafile=%(catalog)s
|
||||
maskdata=%(mask)s
|
||||
"""
|
||||
|
||||
def apply_cut_magnitude(CAT_config, j):
|
||||
CUT_PATTERN="""galaxy_bright_absolute_magnitude_cut=%(absmag_bright)15.15lf
|
||||
galaxy_faint_absolute_magnitude_cut=%(absmag_faint)15.15lf
|
||||
"""
|
||||
Nsubcat = CAT_config['num_subcat']
|
||||
DeltaMag = (CAT_config['absmag_max'] - CAT_config['absmag_min'])
|
||||
MagMin = CAT_config['absmag_min']
|
||||
absmag_bright = DeltaMag * j / Nsubcat + MagMin
|
||||
absmag_faint = DeltaMag * (j+1) / Nsubcat + MagMin
|
||||
f.write(CUT_PATTERN % {'absmag_bright':absmag_bright,'absmag_faint':absmag_faint})
|
||||
|
||||
def apply_cut_distance(CAT_config, j):
|
||||
CUT_PATTERN="""file_dmin=%(dmin)15.15lf
|
||||
file_dmax=%(dmax)15.15lf
|
||||
"""
|
||||
Nsubcat = CAT_config['num_subcat']
|
||||
DeltaMag = (CAT_config['d_max'] - CAT_config['d_min'])
|
||||
MagMin = CAT_config['d_min']
|
||||
dmin = DeltaMag * j / Nsubcat + MagMin
|
||||
dmax = DeltaMag * (j+1) / Nsubcat + MagMin
|
||||
f.write(CUT_PATTERN % {'dmin':dmin,'dmax':dmax})
|
||||
|
||||
def execfile(filename, globals=None, locals=None):
|
||||
if globals is None:
|
||||
globals = sys._getframe(1).f_globals
|
||||
if locals is None:
|
||||
locals = sys._getframe(1).f_locals
|
||||
with open(filename, "r") as fh:
|
||||
exec(fh.read()+"\n", globals, locals)
|
||||
|
||||
with open(out_ini, mode="wt") as f:
|
||||
|
||||
with open(args.header, mode="rt") as fh:
|
||||
f.write(fh.read())
|
||||
f.write("\n")
|
||||
|
||||
print("All configs = %r" % all_config_files)
|
||||
for config_file in all_config_files:
|
||||
path_config,_ = os.path.split(config_file)
|
||||
def file_subs(s):
|
||||
return os.path.join(path_config,s)
|
||||
|
||||
config_locals={}
|
||||
config_globals={'FILE':file_subs}
|
||||
|
||||
print("Analyze %s" % config_file)
|
||||
execfile(config_file, config_globals, config_locals)
|
||||
|
||||
CAT_config = config_locals['CONFIG']
|
||||
del config_locals['CONFIG']
|
||||
|
||||
CAT_config['catalog'] = os.path.join(path_config,CAT_config['catalog'])
|
||||
if CAT_config['cutter']=='magnitude':
|
||||
cut_function = apply_cut_magnitude
|
||||
elif CAT_config['cutter']=='distance':
|
||||
cut_function = apply_cut_distance
|
||||
else:
|
||||
print("Unknown cutter '%s'" % CAT_config['cutter'])
|
||||
sys.exit(1)
|
||||
|
||||
Nsubcat = CAT_config['num_subcat']
|
||||
for j in range(Nsubcat):
|
||||
f.write("[catalog_%(subcat_id)d]\n" % {'subcat_id':subcat_id})
|
||||
for k,v in config_locals.items():
|
||||
if type(v)==str:
|
||||
f.write("%s=%s\n" % (k,v))
|
||||
elif type(v)==tuple:
|
||||
if len(v) > 0:
|
||||
f.write((("%s=" + "%r,"*len(v)) % ((k,) + v))[:-1] + "\n")
|
||||
else:
|
||||
f.write("%s=%r\n" % (k,v))
|
||||
cut_function(CAT_config, j)
|
||||
f.write(PATTERN % CAT_config)
|
||||
if (j==CAT_config.get('ref_subcat',-1)):
|
||||
f.write("refbias=true\n")
|
||||
else:
|
||||
f.write("refbias=false\n")
|
||||
f.write("\n")
|
||||
|
||||
subcat_id += 1
|
||||
|
||||
f.write("[run]\nNCAT=%d\n\n" % subcat_id)
|
44
scripts/ini_generator/header.ini
Normal file
44
scripts/ini_generator/header.ini
Normal file
|
@ -0,0 +1,44 @@
|
|||
[system]
|
||||
console_output=logares.txt
|
||||
VERBOSE_LEVEL = 2
|
||||
N0 = 256
|
||||
N1 = 256
|
||||
N2 = 256
|
||||
|
||||
L0 = 600
|
||||
L1 = 600
|
||||
L2 = 600
|
||||
|
||||
corner0 = -300
|
||||
corner1 = -300
|
||||
corner2 = -300
|
||||
|
||||
NUM_MODES=100
|
||||
N_MC=10000
|
||||
|
||||
|
||||
test_mode=true
|
||||
|
||||
# If true, the initial power spectrum of the chain is set to the cosmological one
|
||||
seed_cpower=true
|
||||
|
||||
# Indicate which samplers should be blocked for testing purposes
|
||||
#messenger_signal_blocked=false
|
||||
#power_sampler_a_blocked=false
|
||||
#power_sampler_b_blocked=false
|
||||
#bias_sampler_blocked=false
|
||||
|
||||
[cosmology]
|
||||
omega_r = 0
|
||||
omega_k = 0
|
||||
omega_m = 0.30
|
||||
omega_b = 0.045
|
||||
omega_q = 0.70
|
||||
w = -1
|
||||
wprime = 0
|
||||
n_s = 1
|
||||
sigma8 = 0.80
|
||||
h100 = 0.65
|
||||
beta = 0.51
|
||||
z0 = 0
|
||||
|
25
scripts/ini_generator/template_sdss_main.py
Normal file
25
scripts/ini_generator/template_sdss_main.py
Normal file
|
@ -0,0 +1,25 @@
|
|||
#+
|
||||
# ARES/HADES/BORG Package -- ./scripts/ini_generator/template_sdss_main.py
|
||||
# Copyright (C) 2014-2020 Guilhem Lavaux <guilhem.lavaux@iap.fr>
|
||||
# Copyright (C) 2009-2020 Jens Jasche <jens.jasche@fysik.su.se>
|
||||
#
|
||||
# Additional contributions from:
|
||||
# Guilhem Lavaux <guilhem.lavaux@iap.fr> (2023)
|
||||
#
|
||||
#+
|
||||
CONFIG=dict(
|
||||
absmag_min=-23.,absmag_max = -17.,
|
||||
num_subcat=6,catalog='sdss_ares_cat.txt',
|
||||
mask='SDSSDR7MASK_4096.fits', ref_subcat=0,
|
||||
cutter='magnitude'
|
||||
)
|
||||
|
||||
radial_selection = 'schechter'
|
||||
schechter_mstar = -20.44
|
||||
schechter_alpha = -1.05
|
||||
schechter_sampling_rate = 2000
|
||||
schechter_dmax = 1000
|
||||
bias = 1
|
||||
nmean = 1
|
||||
galaxy_bright_apparent_magnitude_cut = 13.5
|
||||
galaxy_faint_apparent_magnitude_cut = 17.6
|
Loading…
Add table
Add a link
Reference in a new issue