From 86e7ecd4a9382128f96cd345120485aeba25177f Mon Sep 17 00:00:00 2001 From: Aaron LI Date: Mon, 11 Jul 2016 22:27:38 +0800 Subject: calc_coolfunc.py: Use a default config to allow a minimal user config --- calc_coolfunc.py | 48 ++++++++++++++++++++++++++---------------------- 1 file changed, 26 insertions(+), 22 deletions(-) diff --git a/calc_coolfunc.py b/calc_coolfunc.py index a9bee09..32a7ada 100755 --- a/calc_coolfunc.py +++ b/calc_coolfunc.py @@ -4,9 +4,11 @@ # # Aaron LI # Created: 2016-06-19 -# Updated: 2016-07-04 +# Updated: 2016-07-11 # # Change logs: +# 2016-07-11: +# * Use a default config to allow a minimal user config # 2016-07-04: # * Use "AstroParams" # * Update to use 3-column temperature profile @@ -39,27 +41,40 @@ using the XSPEC `flux` command, and the cooling function has dimension of [ FLUX / EM ]. See also the documentation of `deproject_sbp.py` for more details. +""" + + +import argparse +import subprocess +import sys +import os +from datetime import datetime + +import numpy as np +import astropy.units as au +from astropy.cosmology import FlatLambdaCDM +from configobj import ConfigObj + +from astro_params import AstroParams -Sample configuration file: ------------------------------------------------------------- +config_default = """ ## Configuration file for `calc_coolfunc.py` -## 2016-07-04 # temperature profile fitted & extrapolated by model: [r, T] t_profile = t_profile.txt # average abundance (unit: solar) -abundance = +abundance = -1 # abundance table (default: grsa) abund_table = grsa # redshift of the object -redshift = +redshift = -1 # H column density (unit: 10^22 cm^-2) -nh = +nh = -1 # energy range within which to calculate the cooling function (unit: keV) energy_low = 0.7 @@ -70,22 +85,8 @@ xspec_script = coolfunc.xcm # output file of the cooling function profile: [r, CF] coolfunc = coolfunc_profile.txt ------------------------------------------------------------- """ -import argparse -import subprocess -import sys -import os -from datetime import datetime - -import numpy as np -import astropy.units as au -from astropy.cosmology import FlatLambdaCDM -from configobj import ConfigObj - -from astro_params import AstroParams - def gen_xspec_script(outfile, data): """ @@ -181,7 +182,10 @@ def main(): help="config for cooling function calculation " + "(default: coolfunc.conf)") args = parser.parse_args() - config = ConfigObj(args.config) + + config = ConfigObj(config_default.splitlines()) + config_user = ConfigObj(args.config) + config.merge(config_user) redshift = config.as_float("redshift") config_data = { -- cgit v1.2.2