summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAaron LI <aaronly.me@outlook.com>2016-07-11 22:27:38 +0800
committerAaron LI <aaronly.me@outlook.com>2016-07-11 22:27:38 +0800
commit86e7ecd4a9382128f96cd345120485aeba25177f (patch)
treea207482676e187c3f0fa37a4c37ff65d3e01c5d4
parent78462b582ab115b1c78c0a591364c16731154a68 (diff)
downloadcexcess-86e7ecd4a9382128f96cd345120485aeba25177f.tar.bz2
calc_coolfunc.py: Use a default config to allow a minimal user config
-rwxr-xr-xcalc_coolfunc.py48
1 files 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 = <ABUND>
+abundance = -1
# abundance table (default: grsa)
abund_table = grsa
# redshift of the object
-redshift = <REDSHIFT>
+redshift = -1
# H column density (unit: 10^22 cm^-2)
-nh = <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 = {