From d5896c15cbdc06a641ea21a6d59cb7750830a2de Mon Sep 17 00:00:00 2001 From: Aaron LI Date: Wed, 13 Jul 2016 11:47:31 +0800 Subject: Add make_overdensity_config.py and make_sbpdeproj_config.py --- make_overdensity_config.py | 53 +++++++++++++++++++++++++++++++++++++++ make_sbpdeproj_config.py | 62 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 115 insertions(+) create mode 100755 make_overdensity_config.py create mode 100755 make_sbpdeproj_config.py 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() diff --git a/make_sbpdeproj_config.py b/make_sbpdeproj_config.py new file mode 100755 index 0000000..ab4844f --- /dev/null +++ b/make_sbpdeproj_config.py @@ -0,0 +1,62 @@ +#!/usr/bin/env python3 +# +# Make the configuration file for `deproject_sbp.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 `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 = +# 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() -- cgit v1.2.2