blob: aeca9c1ed1326b5f8a64edde114c7d5795c0261e (
plain)
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
|
#!/usr/bin/env python3
#
# Copyright (c) 2016 Aaron LI
# MIT license
#
# Make the configuration file for `calc_overdensity.py`
#
# Created: 2016-07-13
#
import glob
import argparse
from info import get_redshift
sample_config = """
## Configuration file for `calc_overdensity.py`
# redshift of the source (critical density)
redshift = %(redshift).6f
"""
def make_config(info):
cfg_data = {
"redshift": get_redshift(info),
}
cfg = sample_config % cfg_data
return cfg
def main():
parser = argparse.ArgumentParser(
description="Make the config for 'calc_overdensity.py'")
parser.add_argument("-j", "--json", dest="json", required=False,
help="the *_INFO.json file " +
"(default: find ../*_INFO.json)")
parser.add_argument("outfile", nargs="?", default="overdensity.conf",
help="filename of the output overdensity config " +
"(default: overdensity.conf)")
args = parser.parse_args()
# default "*_INFO.json"
info_json = glob.glob("../*_INFO.json")[0]
if args.json:
info_json = args.json
config = make_config(info_json)
open(args.outfile, "w").write(config)
if __name__ == "__main__":
main()
|