aboutsummaryrefslogtreecommitdiffstats
path: root/mass_profile/coolfunc_calc.sh
diff options
context:
space:
mode:
authorAaron LI <aaronly.me@outlook.com>2016-06-08 21:38:46 +0800
committerAaron LI <aaronly.me@outlook.com>2016-06-08 21:38:46 +0800
commit2b0f09e67850089441ce4e3cb9f3aaa28beee067 (patch)
treeed63a4739b4edf262b2236c3aa8d8d46fa76ece7 /mass_profile/coolfunc_calc.sh
parent1bb88e9d112c21f65a0bf74d57cc19397f9ed29e (diff)
downloadchandra-acis-analysis-2b0f09e67850089441ce4e3cb9f3aaa28beee067.tar.bz2
Merge 'coolfunc_calc2.sh' into 'coolfunc_calc.sh'
* Merge 'coolfunc_calc{2,}.sh' to reduce duplications * Clean up 'coolfunc_calc.sh' a bit * Use 'cosmo_calc' instead of 'calc_distance' in 'coolfunc_calc.sh' * Update comments/description of 'coolfunc_calc.sh' * Update 'fit_{sbp,nfwmass}.sh' accordingly
Diffstat (limited to 'mass_profile/coolfunc_calc.sh')
-rwxr-xr-xmass_profile/coolfunc_calc.sh102
1 files changed, 59 insertions, 43 deletions
diff --git a/mass_profile/coolfunc_calc.sh b/mass_profile/coolfunc_calc.sh
index c4935b7..9a01648 100755
--- a/mass_profile/coolfunc_calc.sh
+++ b/mass_profile/coolfunc_calc.sh
@@ -1,39 +1,32 @@
#!/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 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
+## Updated: 2016-06-08
+##
## cmdline arguments {{{
-if [ $# -ne 5 ]; then
+if [ $# -eq 5 ]; then
+ :
+elif [ $# -eq 6 ]; then
+ COOLFUNC_BOLO="$6"
+ [ -e "${COOLFUNC_BOLO}" ] && rm -f ${COOLFUNC_BOLO}
+else
printf "usage:\n"
- printf " `basename $0` <tprofile> <avg_abund> <nH> <redshift> <coolfunc_outfile>\n"
+ printf " `basename $0` <tprofile> <avg_abund> <nH> <redshift> <coolfunc_outfile> [coolfunc_bolo]\n"
exit 1
fi
-base_path=`dirname $0`
TPROFILE=$1
ABUND_VAL=$2
N_H=$3
REDSHIFT=$4
-NORM=`$base_path/calc_distance $REDSHIFT|grep norm|awk '{print $2}'`
-
-echo $NORM
-
-
+NORM=`cosmo_calc ${REDSHIFT} | grep 'norm.*cooling_function' | awk -F':' '{ print $2 }'`
COOLFUNC_DAT=$5
-COOLFUNC_DAT_RATIO=flux_cnt_ratio.txt
+COOLFUNC_DAT_RATIO="flux_cnt_ratio.txt"
if [ ! -r "${TPROFILE}" ]; then
printf "ERROR: given tprofile '${TPROFILE}' NOT accessiable\n"
@@ -51,15 +44,14 @@ 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
##
-## 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}
@@ -73,19 +65,18 @@ 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} & /*
## xspec }}}
-## set input and output filename
+## set input and output filename & open files
set tpro_fn "${TPROFILE}"
set cf_fn "${COOLFUNC_DAT}"
set cff_fn "${COOLFUNC_DAT_RATIO}"
if { [ file exists \${cf_fn} ] } {
exec rm -fv \${cf_fn}
}
-
if { [ file exists \${cff_fn} ] } {
exec rm -fv \${cff_fn}
}
@@ -95,6 +86,21 @@ set tpro_fd [ open \${tpro_fn} r ]
set cf_fd [ open \${cf_fn} w ]
set cff_fd [ open \${cff_fn} w ]
+_EOF_
+
+if [ ! -z "${COOLFUNC_BOLO}" ]; then
+ cat >> ${XSPEC_CF_XCM} << _EOF_
+# coolfunc bolometric
+set cfbolo_fn "${COOLFUNC_BOLO}"
+if { [ file exists \${cfbolo_fn} ] } {
+ exec rm -fv \${cfbolo_fn}
+}
+set cfbolo_fd [ open \${cfbolo_fn} w ]
+
+_EOF_
+fi
+
+cat >> ${XSPEC_CF_XCM} << _EOF_
## read data from tprofile line by line
while { [ gets \${tpro_fd} tpro_line ] != -1 } {
# gets one line
@@ -112,27 +118,37 @@ while { [ gets \${tpro_fd} tpro_line ] != -1 } {
tclout flux 1
scan \${xspec_tclout} "%f %f %f %f" cff_data holder holder holder
puts \${cff_fd} "\${radius} [expr \${cff_data}/\${cf_data}]"
+_EOF_
+if [ ! -z "${COOLFUNC_BOLO}" ]; then
+ cat >> ${XSPEC_CF_XCM} << _EOF_
+ # coolfunc bolometric
+ set cfbolo_data \$cff_data
+ #puts "cfbolo_data: \${cfbolo_data}"
+ puts \${cfbolo_fd} "\${radius} \${cfbolo_data}"
+_EOF_
+fi
+cat >> ${XSPEC_CF_XCM} << _EOF_
}
## close opened files
close \${tpro_fd}
close \${cf_fd}
+_EOF_
+
+if [ ! -z "${COOLFUNC_BOLO}" ]; then
+ cat >> ${XSPEC_CF_XCM} << _EOF_
+# coolfunc bolometric
+close \${cfbolo_fd}
+
+_EOF_
+fi
+cat >> ${XSPEC_CF_XCM} << _EOF_
## exit
tclexit
_EOF_
-
-## extract xcm }}}
+## generate xcm }}}
## invoke xspec to calc
printf "invoking XSPEC to calculate cooling function data ...\n"
-# xspec - ${XSPEC_CF_XCM}
xspec - ${XSPEC_CF_XCM} > /dev/null
-
-## clean
-# if [ -e "${XSPEC_CF_XCM}" ]; then
-# rm -f ${XSPEC_CF_XCM}
-# fi
-
-exit 0
-