diff options
-rwxr-xr-x | mass_profile/coolfunc_calc.sh | 8 | ||||
-rwxr-xr-x | mass_profile/coolfunc_calc_erg.sh | 134 |
2 files changed, 57 insertions, 85 deletions
diff --git a/mass_profile/coolfunc_calc.sh b/mass_profile/coolfunc_calc.sh index 9a01648..66e9123 100755 --- a/mass_profile/coolfunc_calc.sh +++ b/mass_profile/coolfunc_calc.sh @@ -24,9 +24,9 @@ TPROFILE=$1 ABUND_VAL=$2 N_H=$3 REDSHIFT=$4 -NORM=`cosmo_calc ${REDSHIFT} | grep 'norm.*cooling_function' | awk -F':' '{ print $2 }'` COOLFUNC_DAT=$5 COOLFUNC_DAT_RATIO="flux_cnt_ratio.txt" +NORM=`cosmo_calc ${REDSHIFT} | grep 'norm.*cooling_function' | awk -F':' '{ print $2 }'` if [ ! -r "${TPROFILE}" ]; then printf "ERROR: given tprofile '${TPROFILE}' NOT accessiable\n" @@ -44,7 +44,7 @@ XSPEC_CF_XCM="_coolfunc_calc.xcm" ## generate xspec script {{{ cat >> ${XSPEC_CF_XCM} << _EOF_ ## XSPEC Tcl script -## Calculate the cooling function profile w.r.t the temperature profile +## Calculate the cooling function profile w.r.t the temperature profile. ## ## Generated by: `basename $0` ## Date: `date` @@ -147,8 +147,8 @@ cat >> ${XSPEC_CF_XCM} << _EOF_ ## exit tclexit _EOF_ -## generate xcm }}} +## xcm generation }}} ## invoke xspec to calc -printf "invoking XSPEC to calculate cooling function data ...\n" +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 index d884302..cd44160 100755 --- a/mass_profile/coolfunc_calc_erg.sh +++ b/mass_profile/coolfunc_calc_erg.sh @@ -1,20 +1,13 @@ #!/bin/sh -# -# unalias -a -# -########################################################### -## Task: ## -## Calc `cooling function' data according to ## -## given `temperature profile' ## -## ## -## NOTE: ## -## given `tprofile': <radius> <temperature> ## -## calc `cooling function' by invoking `XSPEC' ## -## using model `wabs*apec' ## -## ## -## LIweitiaNux <liweitianux@gmail.com> ## -## August 17, 2012 ## -########################################################### +## +## 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 @@ -22,26 +15,18 @@ if [ $# -ne 6 ]; then printf " `basename $0` <tprofile> <avg_abund> <nH> <redshift> <coolfunc_prefix> <band_list>\n" exit 1 fi -base_path=`dirname $0` TPROFILE=$1 ABUND_VAL=$2 N_H=$3 REDSHIFT=$4 -BLIST=$6 -NORM=`$base_path/calc_distance $REDSHIFT|grep norm|awk '{print $2}'` - -echo $NORM - - COOLFUNC_PREFIX=$5 -#COOLFUNC_DAT_RATIO=flux_cnt_ratio.txt +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 -#[ -e "${COOLFUNC_DAT}" ] && rm -f ${COOLFUNC_DAT} -#[ -e "${COOLFUNC_DAT_RATIO}" ] && rm -f ${COOLFUNC_DAT_RATIO} ## arguments }}} ## specify variable name outside while loop @@ -52,15 +37,15 @@ XSPEC_CF_XCM="_coolfunc_calc.xcm" ## generate xspec script {{{ cat >> ${XSPEC_CF_XCM} << _EOF_ ## XSPEC Tcl script -## calc cooling function data +## Calculate the cooling function profile w.r.t the temperature profile, +## for each specified energy band. ## -## generated by: `basename $0` -## date: `date` +## Generated by: `basename $0` +## Date: `date` set xs_return_results 1 set xs_echo_script 0 # set tcl_precision 12 -dummyrsp .01 100 4096 ## set basic data {{{ set nh ${N_H} set redshift ${REDSHIFT} @@ -74,72 +59,59 @@ chatter 0 # debug }}} query yes abund grsa -dummyrsp 0.3 11.0 1024 +dummyrsp 0.01 100.0 4096 linear # load model 'wabs*apec' to calc cooling function -#model wabs*apec & \${nh} & 1.0 & \${abund_val} & \${redshift} & \${norm} & -model wabs*apec & 0 & 1.0 & \${abund_val} & \${redshift} & \${norm} & +# (nh=0.0: do not consider aborption ???) +model wabs*apec & 0.0 & 1.0 & \${abund_val} & \${redshift} & \${norm} & ## xspec }}} ## set input and output filename set tpro_fn "${TPROFILE}" set blist_fn "${BLIST}" set cf_prefix "${COOLFUNC_PREFIX}" -##set cff_fn "${COOLFUNC_DAT_RATIO}" - -#if { [ file exists \${cff_fn} ] } { -# exec rm -fv \${cff_fn} -#} - -## open files set blist_fd [ open \${blist_fn} r ] -#set cff_fd [ open \${cff_fn} w ] +## loop over each energy band while { [ gets \${blist_fd} blist_line ] != -1 } { -if { "\${blist_line}" == "bolo" } { set e1 .01; set e2 100.0; set name_suffix bolo } { set e1 [ lindex \${blist_line} 0 ]; set e2 [ lindex \${blist_line} 1]; set name_suffix "\${e1}-\${e2}" } -## read data from tprofile line by line -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 ] -while { [ gets \${tpro_fd} tpro_line ] != -1 } { - # gets one line - scan \${tpro_line} "%f %f" radius temp_val - #puts "radius: \${radius}, temperature: \${temp_val}" - # set temperature value - newpar 2 \${temp_val} - # calc flux & tclout - flux \${e1} \${e2} - tclout flux 1 - scan \${xspec_tclout} "%f %f %f %f" cf_data holder holder holder - #puts "cf_data: \${cf_data}" - puts \${cf_fd} "\${radius} \${cf_data}" -# flux 0.01 100.0 -# tclout flux 1 -# scan \${xspec_tclout} "%f %f %f %f" cff_data holder holder holder -# puts \${cff_fd} "\${radius} [expr \${cff_data}/\${cf_data}]" -} -close \${tpro_fd} -close \${cf_fd} + 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 } { + # gets one line + scan \${tpro_line} "%f %f" radius temp_val + #puts "radius: \${radius}, temperature: \${temp_val}" + # set temperature value + newpar 2 \${temp_val} + # calc flux & tclout + flux \${e1} \${e2} + tclout flux 1 + scan \${xspec_tclout} "%f %f %f %f" cf_data holder holder holder + #puts "cf_data: \${cf_data}" + puts \${cf_fd} "\${radius} \${cf_data}" + } + close \${tpro_fd} + close \${cf_fd} } -## close opened files ## exit tclexit _EOF_ - -## extract xcm }}} +## xcm generation }}} ## invoke xspec to calc -printf "invoking XSPEC to calculate cooling function data ...\n" -# xspec - ${XSPEC_CF_XCM} +printf "invoking XSPEC to calculate cooling function profile ...\n" xspec - ${XSPEC_CF_XCM} > /dev/null - -## clean -# if [ -e "${XSPEC_CF_XCM}" ]; then -# rm -f ${XSPEC_CF_XCM} -# fi - -exit 0 - |