summaryrefslogtreecommitdiffstats
path: root/make_sbpdeproj_config.py
blob: d7cfbf710f284c65c77920e0b7adce6adab9c533 (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
55
56
57
58
59
60
61
62
63
#!/usr/bin/env python3
#
# Copyright (c) 2016 Aaron LI
# MIT license
#
# Make the configuration file for `deproject_sbp.py`
#
# Created: 2016-07-13
#

import glob
import argparse

from info import get_redshift


sample_config = """
## Configuration file for `deproject_sbp.py`

# redshift of the object (for pixel to distance conversion)
redshift = %(redshift).6f

## SBP extrapolation
# cut radius from which the SBP is fitted for extrapolation,
# specified by the ratio w.r.t sbpfit rc (default: 1.2 * rc)
sbpexp_rignore_ratio = 1.2
# or directly specify the ignorance radius (override above) (unit: pixel)
#sbpexp_rignore = <RIGNORE>
# cut radius to which stop the extrapolation (unit: kpc)
sbpexp_rcut = 3000
"""


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 'deproject_sbp.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="sbpdeproj.conf",
                        help="filename of the output config " +
                             "(default: sbpdeproj.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()