diff options
author | Aaron LI <aaronly.me@outlook.com> | 2017-02-20 12:11:25 +0800 |
---|---|---|
committer | Aaron LI <aaronly.me@outlook.com> | 2017-02-20 12:11:25 +0800 |
commit | cba36462e9e70f45341e432074c726dda5e31092 (patch) | |
tree | 0bc9885d0ff86b563e0fb5321c56d51d5687ba70 /bin/fit_sbp.sh | |
parent | 2a069ed00d6f1c83153be9174c296e5540f37d30 (diff) | |
download | chandra-acis-analysis-cba36462e9e70f45341e432074c726dda5e31092.tar.bz2 |
Move shell/python scripts from 'mass_profile/' to 'bin/'
Diffstat (limited to 'bin/fit_sbp.sh')
-rwxr-xr-x | bin/fit_sbp.sh | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/bin/fit_sbp.sh b/bin/fit_sbp.sh new file mode 100755 index 0000000..5989ff1 --- /dev/null +++ b/bin/fit_sbp.sh @@ -0,0 +1,61 @@ +#!/bin/sh +# +# Handy script for SBP fitting. +# This script wraps the 'fit_beta_sbp' and 'fit_dbeta_sbp', +# and automatically determine the sbp model according to the config file. +# +# Weitian LI +# 2013-02-20 +# +# Change logs: +# 2017-02-07, Weitian LI +# * Use `sbp_cfg` from command line argument, instead of the one specified +# in the `mass.conf` +# * Update the variable names according to the updated config files +# * Some cleanups +# + +if [ $# -ne 2 ]; then + echo "usage: $0 <sbp.conf> <mass.conf>" + exit 1 +fi + +sbp_cfg="$1" +mass_cfg="$2" + +if [ "$0" = `basename $0` ]; then + script_path=`which $0` + base_path=`dirname ${script_path}` +else + base_path=`dirname $0` +fi + +nh=`grep '^nh' ${mass_cfg} | awk '{ print $2 }'` +abund=`grep '^abund' ${mass_cfg} | awk '{ print $2 }'` +tprofile_data=`grep '^tprofile_data' ${mass_cfg} | awk '{ print $2 }'` +tprofile_cfg=`grep '^tprofile_cfg' ${mass_cfg} | awk '{ print $2 }'` + +z=`grep '^z' ${sbp_cfg} | awk '{ print $2 }'` +cm_per_pixel=`cosmo_calc ${z} | grep 'cm/pixel' | awk -F':' '{ print $2 }'` +sed -i'' "s/^cm_per_pixel.*$/cm_per_pixel ${cm_per_pixel}/" ${sbp_cfg} +cfunc_profile=`grep '^cfunc_profile' ${sbp_cfg} | awk '{ print $2 }'` +tprofile=`grep '^tprofile' ${sbp_cfg} | awk '{ print $2 }'` + +if grep -q '^beta2' ${sbp_cfg}; then + MODEL="double-beta" + PROG=fit_dbeta_sbp +else + MODEL="single-beta" + PROG=fit_beta_sbp +fi + +${base_path}/fit_wang2012_model ${tprofile_data} ${tprofile_cfg} \ + ${cm_per_pixel} 2> /dev/null +cp wang2012_dump.qdp ${tprofile} +if [ ! -f ${cfunc_profile} ]; then + ${base_path}/calc_coolfunc.sh ${tprofile} ${abund} ${nh} ${z} \ + ${cfunc_profile} +fi +${base_path}/${PROG} ${sbp_cfg} +echo "## MODEL: ${MODEL}" +echo "## z: ${z}" |