diff options
Diffstat (limited to 'make_overdensity_config.py')
-rwxr-xr-x | make_overdensity_config.py | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/make_overdensity_config.py b/make_overdensity_config.py new file mode 100755 index 0000000..7ff0a2f --- /dev/null +++ b/make_overdensity_config.py @@ -0,0 +1,53 @@ +#!/usr/bin/env python3 +# +# Make the configuration file for `calc_overdensity.py` +# +# Aaron LI +# Created: 2016-07-13 +# Updated: 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() |