From 411948044a254ff0ea5961a3a9c3fdd1e6cf3a7a Mon Sep 17 00:00:00 2001 From: Aaron LI Date: Fri, 17 Feb 2017 00:56:58 +0800 Subject: Rename 'coolfunc_calc.sh' and 'coolfunc_calc_erg.sh' * coolfunc_calc.sh -> calc_coolfunc.sh * coolfunc_calc_erg.sh -> calc_coolfunc_bands.sh --- mass_profile/calc_coolfunc.sh | 111 ++++++++++++++++++++++++++++++++++ mass_profile/calc_coolfunc_bands.sh | 116 ++++++++++++++++++++++++++++++++++++ mass_profile/calc_lxfx.sh | 10 +--- mass_profile/coolfunc_calc.sh | 110 ---------------------------------- mass_profile/coolfunc_calc_erg.sh | 116 ------------------------------------ mass_profile/fit_mass.sh | 6 +- mass_profile/fit_sbp.sh | 2 +- 7 files changed, 233 insertions(+), 238 deletions(-) create mode 100755 mass_profile/calc_coolfunc.sh create mode 100755 mass_profile/calc_coolfunc_bands.sh delete mode 100755 mass_profile/coolfunc_calc.sh delete mode 100755 mass_profile/coolfunc_calc_erg.sh (limited to 'mass_profile') diff --git a/mass_profile/calc_coolfunc.sh b/mass_profile/calc_coolfunc.sh new file mode 100755 index 0000000..f67f8c2 --- /dev/null +++ b/mass_profile/calc_coolfunc.sh @@ -0,0 +1,111 @@ +#!/bin/sh +## +## Calculate the 'cooling function' profile with respect to the +## given 'temperature profile' and the average abundance, redshift, +## and column density nH, using the XSPEC model 'wabs*apec'. +## +## Weitian LI +## Created: 2012-08-17 +## +## Change logs: +## 2017-02-17, Weitian LI +## * Rename from 'coolfunc_calc.sh' to 'calc_coolfunc.sh' +## * Clean up that do not calculate and output +## 2017-02-16, Weitian LI +## * Do not calculate and output 'flux_cnt_ratio.txt' +## + +## cmdline arguments {{{ +if [ $# -ne 5 ]; then + printf "usage:\n" + printf " `basename $0` \n" + exit 1 +fi +TPROFILE=$1 +ABUNDANCE=$2 +N_H=$3 +REDSHIFT=$4 +COOLFUNC_DAT=$5 +NORM=`cosmo_calc ${REDSHIFT} | grep 'norm.*cooling_function' | awk -F':' '{ print $2 }'` + +if [ ! -r "${TPROFILE}" ]; then + printf "ERROR: given tprofile '${TPROFILE}' NOT accessiable\n" + exit 2 +fi +[ -e "${COOLFUNC_DAT}" ] && rm -f ${COOLFUNC_DAT} +## arguments }}} + +## specify variable name outside while loop +## otherwise the inside vars invisible +XSPEC_CF_XCM="_calc_coolfunc.xcm" +[ -e "${XSPEC_CF_XCM}" ] && rm -f ${XSPEC_CF_XCM} + +## generate xspec script {{{ +cat >> ${XSPEC_CF_XCM} << _EOF_ +## XSPEC Tcl script +## Calculate the cooling function profile w.r.t the temperature profile. +## +## Generated by: `basename $0` +## Date: `date` + +set xs_return_results 1 +set xs_echo_script 0 +# set tcl_precision 12 +## set basic data {{{ +set nh ${N_H} +set redshift ${REDSHIFT} +set abundance ${ABUNDANCE} +set norm ${NORM} +## basic }}} + +## xspec related {{{ +# debug settings {{{ +chatter 0 +# debug }}} +query yes +abund grsa +dummyrsp 0.01 100.0 4096 linear +# load model 'wabs*apec' to calc cooling function +model wabs*apec & \${nh} & 1.0 & \${abundance} & \${redshift} & \${norm} & /* +## xspec }}} + +## set input and output filename & open files +set tpro_fn "${TPROFILE}" +set cf_fn "${COOLFUNC_DAT}" +if { [ file exists \${cf_fn} ] } { + exec rm -fv \${cf_fn} +} + +## open files +set tpro_fd [ open \${tpro_fn} r ] +set cf_fd [ open \${cf_fn} w ] + +_EOF_ + +cat >> ${XSPEC_CF_XCM} << _EOF_ +## read data from tprofile line by line +while { [ gets \${tpro_fd} tpro_line ] != -1 } { + scan \${tpro_line} "%f %f" radius temperature + #puts "radius: \${radius}, temperature: \${temperature}" + # set temperature value + newpar 2 \${temperature} + # calc flux & tclout + flux 0.7 7.0 + tclout flux 1 + scan \${xspec_tclout} "%f %f %f %f" _ _ _ cf_photon + #puts "cf: \${cf_photon}" + puts \${cf_fd} "\${radius} \${cf_photon}" +} + +## close opened files +close \${tpro_fd} +close \${cf_fd} + +## exit +tclexit +_EOF_ +## xcm generation }}} + +## invoke xspec to calc +printf "invoking XSPEC to calculate cooling function profile ...\n" +xspec - ${XSPEC_CF_XCM} > /dev/null diff --git a/mass_profile/calc_coolfunc_bands.sh b/mass_profile/calc_coolfunc_bands.sh new file mode 100755 index 0000000..9fa0196 --- /dev/null +++ b/mass_profile/calc_coolfunc_bands.sh @@ -0,0 +1,116 @@ +#!/bin/sh +## +## Calculate the 'cooling function' profile for each of the energy band +## specified in a bands file, with respect to the given 'temperature profile' +## and the average abundance, redshift, and column density nH, using the +## XSPEC model 'wabs*apec'. +## +## Weitian LI +## Updated: 2016-06-08 +## + +## cmdline arguments {{{ +if [ $# -ne 6 ]; then + printf "usage:\n" + printf " `basename $0` \n" + exit 1 +fi +TPROFILE=$1 +ABUNDANCE=$2 +N_H=$3 +REDSHIFT=$4 +COOLFUNC_PREFIX=$5 +BLIST=$6 +NORM=`cosmo_calc ${REDSHIFT} | grep 'norm.*cooling_function' | awk -F':' '{ print $2 }'` + +if [ ! -r "${TPROFILE}" ]; then + printf "ERROR: given tprofile '${TPROFILE}' NOT accessiable\n" + exit 2 +fi +## arguments }}} + +## specify variable name outside while loop +## otherwise the inside vars invisible +XSPEC_CF_XCM="_calc_coolfunc_bands.xcm" +[ -e "${XSPEC_CF_XCM}" ] && rm -f ${XSPEC_CF_XCM} + +## generate xspec script {{{ +cat >> ${XSPEC_CF_XCM} << _EOF_ +## XSPEC Tcl script +## Calculate the cooling function profile w.r.t the temperature profile, +## for each specified energy band. +## +## Generated by: `basename $0` +## Date: `date` + +set xs_return_results 1 +set xs_echo_script 0 +# set tcl_precision 12 +## set basic data {{{ +set nh ${N_H} +set redshift ${REDSHIFT} +set abundance ${ABUNDANCE} +set norm ${NORM} +## basic }}} + +## xspec related {{{ +# debug settings {{{ +chatter 0 +# debug }}} +query yes +abund grsa +dummyrsp 0.01 100.0 4096 linear +# load model 'wabs*apec' to calc cooling function +# (nh=0.0: do not consider aborption ???) +model wabs*apec & 0.0 & 1.0 & \${abundance} & \${redshift} & \${norm} & +## xspec }}} + +## set input and output filename +set tpro_fn "${TPROFILE}" +set blist_fn "${BLIST}" +set cf_prefix "${COOLFUNC_PREFIX}" +set blist_fd [ open \${blist_fn} r ] + +## loop over each energy band +while { [ gets \${blist_fd} blist_line ] != -1 } { + if { "\${blist_line}" == "bolo" } { + set e1 0.01 + set e2 100.0 + set name_suffix bolo + } else { + set e1 [ lindex \${blist_line} 0 ] + set e2 [ lindex \${blist_line} 1 ] + set name_suffix "\${e1}-\${e2}" + } + set cf_fn "\${cf_prefix}\${name_suffix}.dat" + if { [ file exists \${cf_fn} ] } { + exec rm -fv \${cf_fn} + } + set cf_fd [ open \${cf_fn} w ] + set tpro_fd [ open \${tpro_fn} r ] + + ## read data from tprofile line by line + while { [ gets \${tpro_fd} tpro_line ] != -1 } { + scan \${tpro_line} "%f %f" radius temperature + #puts "radius: \${radius}, temperature: \${temperature}" + # set temperature value + newpar 2 \${temperature} + # calc flux & tclout + flux \${e1} \${e2} + tclout flux 1 + scan \${xspec_tclout} "%f" cf_erg + #puts "cf: \${cf_erg}" + puts \${cf_fd} "\${radius} \${cf_erg}" + } + close \${tpro_fd} + close \${cf_fd} +} + +## exit +tclexit +_EOF_ +## xcm generation }}} + +## invoke xspec to calc +printf "invoking XSPEC to calculate cooling function profile ...\n" +xspec - ${XSPEC_CF_XCM} > /dev/null diff --git a/mass_profile/calc_lxfx.sh b/mass_profile/calc_lxfx.sh index a86acc2..a8cb053 100755 --- a/mass_profile/calc_lxfx.sh +++ b/mass_profile/calc_lxfx.sh @@ -17,12 +17,6 @@ # Weitian LI # 2016-06-07 # -# Change logs: -# 2017-02-17, Weitian LI -# * Remove useless call of 'coolfunc_calc.sh' -# 2017-02-07, Weitian LI -# * Update to use the new style configuration files -# if [ $# -eq 2 ] || [ $# -eq 3 ]; then : @@ -85,7 +79,7 @@ bolo 0.1 2.4 _EOF_ -${base_path}/coolfunc_calc_erg.sh ${tprofile} ${abund} \ +${base_path}/calc_coolfunc_bands.sh ${tprofile} ${abund} \ ${nh} ${z} "cfunc_" ${BLIST} PROG="calc_lx_${MODEL}" @@ -144,7 +138,7 @@ for i in `seq 1 ${MC_TIMES}`; do echo "### `pwd -P`" echo "### ${i} / ${MC_TIMES} ###" - ${base_path}/coolfunc_calc_erg.sh ${tprofile} ${abund} \ + ${base_path}/calc_coolfunc_bands.sh ${tprofile} ${abund} \ ${nh} ${z} "cfunc_" ${BLIST} ${base_path}/${PROG} ${TMP_SBP_CFG} ${rout} \ cfunc_bolo.dat \ diff --git a/mass_profile/coolfunc_calc.sh b/mass_profile/coolfunc_calc.sh deleted file mode 100755 index ab6b4d3..0000000 --- a/mass_profile/coolfunc_calc.sh +++ /dev/null @@ -1,110 +0,0 @@ -#!/bin/sh -## -## Calculate the 'cooling function' profile with respect to the -## given 'temperature profile' and the average abundance, redshift, -## and column density nH, using the XSPEC model 'wabs*apec'. -## -## Weitian LI -## Created: 2012-08-17 -## -## Change logs: -## 2017-02-17, Weitian LI -## * Clean up that do not calculate and output -## 2017-02-16, Weitian LI -## * Do not calculate and output 'flux_cnt_ratio.txt' -## - -## cmdline arguments {{{ -if [ $# -ne 5 ]; then - printf "usage:\n" - printf " `basename $0` \n" - exit 1 -fi -TPROFILE=$1 -ABUNDANCE=$2 -N_H=$3 -REDSHIFT=$4 -COOLFUNC_DAT=$5 -NORM=`cosmo_calc ${REDSHIFT} | grep 'norm.*cooling_function' | awk -F':' '{ print $2 }'` - -if [ ! -r "${TPROFILE}" ]; then - printf "ERROR: given tprofile '${TPROFILE}' NOT accessiable\n" - exit 2 -fi -[ -e "${COOLFUNC_DAT}" ] && rm -f ${COOLFUNC_DAT} -## arguments }}} - -## specify variable name outside while loop -## otherwise the inside vars invisible -XSPEC_CF_XCM="_coolfunc_calc.xcm" -[ -e "${XSPEC_CF_XCM}" ] && rm -f ${XSPEC_CF_XCM} - -## generate xspec script {{{ -cat >> ${XSPEC_CF_XCM} << _EOF_ -## XSPEC Tcl script -## Calculate the cooling function profile w.r.t the temperature profile. -## -## Generated by: `basename $0` -## Date: `date` - -set xs_return_results 1 -set xs_echo_script 0 -# set tcl_precision 12 -## set basic data {{{ -set nh ${N_H} -set redshift ${REDSHIFT} -set abundance ${ABUNDANCE} -set norm ${NORM} -## basic }}} - -## xspec related {{{ -# debug settings {{{ -chatter 0 -# debug }}} -query yes -abund grsa -dummyrsp 0.01 100.0 4096 linear -# load model 'wabs*apec' to calc cooling function -model wabs*apec & \${nh} & 1.0 & \${abundance} & \${redshift} & \${norm} & /* -## xspec }}} - -## set input and output filename & open files -set tpro_fn "${TPROFILE}" -set cf_fn "${COOLFUNC_DAT}" -if { [ file exists \${cf_fn} ] } { - exec rm -fv \${cf_fn} -} - -## open files -set tpro_fd [ open \${tpro_fn} r ] -set cf_fd [ open \${cf_fn} w ] - -_EOF_ - -cat >> ${XSPEC_CF_XCM} << _EOF_ -## read data from tprofile line by line -while { [ gets \${tpro_fd} tpro_line ] != -1 } { - scan \${tpro_line} "%f %f" radius temperature - #puts "radius: \${radius}, temperature: \${temperature}" - # set temperature value - newpar 2 \${temperature} - # calc flux & tclout - flux 0.7 7.0 - tclout flux 1 - scan \${xspec_tclout} "%f %f %f %f" _ _ _ cf_photon - #puts "cf: \${cf_photon}" - puts \${cf_fd} "\${radius} \${cf_photon}" -} - -## close opened files -close \${tpro_fd} -close \${cf_fd} - -## exit -tclexit -_EOF_ -## xcm generation }}} - -## invoke xspec to calc -printf "invoking XSPEC to calculate cooling function profile ...\n" -xspec - ${XSPEC_CF_XCM} > /dev/null diff --git a/mass_profile/coolfunc_calc_erg.sh b/mass_profile/coolfunc_calc_erg.sh deleted file mode 100755 index 02db453..0000000 --- a/mass_profile/coolfunc_calc_erg.sh +++ /dev/null @@ -1,116 +0,0 @@ -#!/bin/sh -## -## Calculate the 'cooling function' profile for each of the energy band -## specified in a bands file, with respect to the given 'temperature profile' -## and the average abundance, redshift, and column density nH, using the -## XSPEC model 'wabs*apec'. -## -## Weitian LI -## Updated: 2016-06-08 -## - -## cmdline arguments {{{ -if [ $# -ne 6 ]; then - printf "usage:\n" - printf " `basename $0` \n" - exit 1 -fi -TPROFILE=$1 -ABUNDANCE=$2 -N_H=$3 -REDSHIFT=$4 -COOLFUNC_PREFIX=$5 -BLIST=$6 -NORM=`cosmo_calc ${REDSHIFT} | grep 'norm.*cooling_function' | awk -F':' '{ print $2 }'` - -if [ ! -r "${TPROFILE}" ]; then - printf "ERROR: given tprofile '${TPROFILE}' NOT accessiable\n" - exit 2 -fi -## arguments }}} - -## specify variable name outside while loop -## otherwise the inside vars invisible -XSPEC_CF_XCM="_coolfunc_calc.xcm" -[ -e "${XSPEC_CF_XCM}" ] && rm -f ${XSPEC_CF_XCM} - -## generate xspec script {{{ -cat >> ${XSPEC_CF_XCM} << _EOF_ -## XSPEC Tcl script -## Calculate the cooling function profile w.r.t the temperature profile, -## for each specified energy band. -## -## Generated by: `basename $0` -## Date: `date` - -set xs_return_results 1 -set xs_echo_script 0 -# set tcl_precision 12 -## set basic data {{{ -set nh ${N_H} -set redshift ${REDSHIFT} -set abundance ${ABUNDANCE} -set norm ${NORM} -## basic }}} - -## xspec related {{{ -# debug settings {{{ -chatter 0 -# debug }}} -query yes -abund grsa -dummyrsp 0.01 100.0 4096 linear -# load model 'wabs*apec' to calc cooling function -# (nh=0.0: do not consider aborption ???) -model wabs*apec & 0.0 & 1.0 & \${abundance} & \${redshift} & \${norm} & -## xspec }}} - -## set input and output filename -set tpro_fn "${TPROFILE}" -set blist_fn "${BLIST}" -set cf_prefix "${COOLFUNC_PREFIX}" -set blist_fd [ open \${blist_fn} r ] - -## loop over each energy band -while { [ gets \${blist_fd} blist_line ] != -1 } { - if { "\${blist_line}" == "bolo" } { - set e1 0.01 - set e2 100.0 - set name_suffix bolo - } else { - set e1 [ lindex \${blist_line} 0 ] - set e2 [ lindex \${blist_line} 1 ] - set name_suffix "\${e1}-\${e2}" - } - set cf_fn "\${cf_prefix}\${name_suffix}.dat" - if { [ file exists \${cf_fn} ] } { - exec rm -fv \${cf_fn} - } - set cf_fd [ open \${cf_fn} w ] - set tpro_fd [ open \${tpro_fn} r ] - - ## read data from tprofile line by line - while { [ gets \${tpro_fd} tpro_line ] != -1 } { - scan \${tpro_line} "%f %f" radius temperature - #puts "radius: \${radius}, temperature: \${temperature}" - # set temperature value - newpar 2 \${temperature} - # calc flux & tclout - flux \${e1} \${e2} - tclout flux 1 - scan \${xspec_tclout} "%f" cf_erg - #puts "cf: \${cf_erg}" - puts \${cf_fd} "\${radius} \${cf_erg}" - } - close \${tpro_fd} - close \${cf_fd} -} - -## exit -tclexit -_EOF_ -## xcm generation }}} - -## invoke xspec to calc -printf "invoking XSPEC to calculate cooling function profile ...\n" -xspec - ${XSPEC_CF_XCM} > /dev/null diff --git a/mass_profile/fit_mass.sh b/mass_profile/fit_mass.sh index a5fadce..f349f24 100755 --- a/mass_profile/fit_mass.sh +++ b/mass_profile/fit_mass.sh @@ -94,8 +94,8 @@ cp -fv ${tprofile_dump} ${tprofile} mv -fv ${tprofile_dump} ${tprofile_center} mv -fv fit_result.qdp ${tprofile_fit_center} -$base_path/coolfunc_calc.sh ${tprofile_center} \ - ${abund} ${nh} ${z} ${cfunc_profile} +${base_path}/calc_coolfunc.sh ${tprofile_center} \ + ${abund} ${nh} ${z} ${cfunc_profile} cfunc_profile_center="coolfunc_profile_center.txt" cp -f ${cfunc_profile} ${cfunc_profile_center} @@ -163,7 +163,7 @@ for i in `seq 1 ${MC_TIMES}`; do printf "## ${i} / ${MC_TIMES} ##\n" printf "## `pwd -P` ##\n" - ${base_path}/coolfunc_calc.sh ${tprofile} ${abund} ${nh} ${z} ${cfunc_profile} + ${base_path}/calc_coolfunc.sh ${tprofile} ${abund} ${nh} ${z} ${cfunc_profile} ${base_path}/${PROG_SBPFIT} ${TMP_SBP_CFG} 2> /dev/null cat ${RES_SBPFIT} ${base_path}/fit_nfw_mass mass_int.dat ${z} ${nfw_rmin_kpc} 2> /dev/null diff --git a/mass_profile/fit_sbp.sh b/mass_profile/fit_sbp.sh index 02ee0d0..5989ff1 100755 --- a/mass_profile/fit_sbp.sh +++ b/mass_profile/fit_sbp.sh @@ -53,7 +53,7 @@ ${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}/coolfunc_calc.sh ${tprofile} ${abund} ${nh} ${z} \ + ${base_path}/calc_coolfunc.sh ${tprofile} ${abund} ${nh} ${z} \ ${cfunc_profile} fi ${base_path}/${PROG} ${sbp_cfg} -- cgit v1.2.2