From 564c9c4de6df9f4fdb00686828a115548c730229 Mon Sep 17 00:00:00 2001 From: Aaron LI Date: Tue, 7 Jun 2016 19:07:13 +0800 Subject: Merge analyze_{lf}x.py => analyze_lxfx.py and update. * Merge analyze_{lf}x.py => analyze_lxfx.py * Update analyze_lxfx.py to use arguments * Update calc_lxfx.sh accordingly * Add "output" comments to calc_lxfx.sh --- mass_profile/analyze_fx.py | 32 -------------------------------- mass_profile/analyze_lx.py | 32 -------------------------------- mass_profile/analyze_lxfx.py | 32 ++++++++++++++++++++++++++++++++ mass_profile/calc_lxfx.sh | 34 ++++++++++++++++++++-------------- 4 files changed, 52 insertions(+), 78 deletions(-) delete mode 100755 mass_profile/analyze_fx.py delete mode 100755 mass_profile/analyze_lx.py create mode 100755 mass_profile/analyze_lxfx.py (limited to 'mass_profile') diff --git a/mass_profile/analyze_fx.py b/mass_profile/analyze_fx.py deleted file mode 100755 index 4f72f57..0000000 --- a/mass_profile/analyze_fx.py +++ /dev/null @@ -1,32 +0,0 @@ -#!/usr/bin/env python - -import sys -import math -import numpy - -fx1_array=[] -fx2_array=[] -fx3_array=[] -for i in open('summary_fx.dat'): - x1,x2,x3=i.split() - x1=float(x1) - x2=float(x2) - x3=float(x3) - fx1_array.append(x1) - fx2_array.append(x2) - fx3_array.append(x3) - - -fx1_array=numpy.array(fx1_array) -fx2_array=numpy.array(fx2_array) -fx3_array=numpy.array(fx3_array) - - -f=open('fx_result.txt','w') -f.write("Fx(bolot)= %4.2E +/- %4.2E erg/s/cm^2\n"%(fx1_array[0],fx1_array.std())) -print("Fx(bolot)= %4.2E +/- %4.2E erg/s/cm^2"%(fx1_array[0],fx1_array.std())) -f.write("Fx(0.7-7)= %4.2E +/- %4.2E erg/s/cm^2\n"%(fx2_array[0],fx2_array.std())) -print("Fx(0.7-7)= %4.2E +/- %4.2E erg/s/cm^2"%(fx2_array[0],fx2_array.std())) -f.write("Fx(0.1-2.4)= %4.2E +/- %4.2E erg/s/cm^2\n"%(fx3_array[0],fx3_array.std())) -print("Fx(0.1-2.4)= %4.2E +/- %4.2E erg/s/cm^2"%(fx3_array[0],fx3_array.std())) - diff --git a/mass_profile/analyze_lx.py b/mass_profile/analyze_lx.py deleted file mode 100755 index c3d4030..0000000 --- a/mass_profile/analyze_lx.py +++ /dev/null @@ -1,32 +0,0 @@ -#!/usr/bin/env python - -import sys -import math -import numpy - -lx1_array=[] -lx2_array=[] -lx3_array=[] -for i in open('summary_lx.dat'): - x1,x2,x3=i.split() - x1=float(x1) - x2=float(x2) - x3=float(x3) - lx1_array.append(x1) - lx2_array.append(x2) - lx3_array.append(x3) - - -lx1_array=numpy.array(lx1_array) -lx2_array=numpy.array(lx2_array) -lx3_array=numpy.array(lx3_array) - - -f=open('lx_result.txt','w') -f.write("Lx(bolo)= %4.2E +/- %4.2E erg/s\n"%(lx1_array[0],lx1_array.std())) -print("Lx(bolo)= %4.2E +/- %4.2E erg/s"%(lx1_array[0],lx1_array.std())) -f.write("Lx(0.7-7)= %4.2E +/- %4.2E erg/s\n"%(lx2_array[0],lx2_array.std())) -print("Lx(0.7-7)= %4.2E +/- %4.2E erg/s"%(lx2_array[0],lx2_array.std())) -f.write("Lx(0.1-2.4)= %4.2E +/- %4.2E erg/s\n"%(lx3_array[0],lx3_array.std())) -print("Lx(0.1-2.4)= %4.2E +/- %4.2E erg/s"%(lx3_array[0],lx3_array.std())) - diff --git a/mass_profile/analyze_lxfx.py b/mass_profile/analyze_lxfx.py new file mode 100755 index 0000000..c3d4030 --- /dev/null +++ b/mass_profile/analyze_lxfx.py @@ -0,0 +1,32 @@ +#!/usr/bin/env python + +import sys +import math +import numpy + +lx1_array=[] +lx2_array=[] +lx3_array=[] +for i in open('summary_lx.dat'): + x1,x2,x3=i.split() + x1=float(x1) + x2=float(x2) + x3=float(x3) + lx1_array.append(x1) + lx2_array.append(x2) + lx3_array.append(x3) + + +lx1_array=numpy.array(lx1_array) +lx2_array=numpy.array(lx2_array) +lx3_array=numpy.array(lx3_array) + + +f=open('lx_result.txt','w') +f.write("Lx(bolo)= %4.2E +/- %4.2E erg/s\n"%(lx1_array[0],lx1_array.std())) +print("Lx(bolo)= %4.2E +/- %4.2E erg/s"%(lx1_array[0],lx1_array.std())) +f.write("Lx(0.7-7)= %4.2E +/- %4.2E erg/s\n"%(lx2_array[0],lx2_array.std())) +print("Lx(0.7-7)= %4.2E +/- %4.2E erg/s"%(lx2_array[0],lx2_array.std())) +f.write("Lx(0.1-2.4)= %4.2E +/- %4.2E erg/s\n"%(lx3_array[0],lx3_array.std())) +print("Lx(0.1-2.4)= %4.2E +/- %4.2E erg/s"%(lx3_array[0],lx3_array.std())) + diff --git a/mass_profile/calc_lxfx.sh b/mass_profile/calc_lxfx.sh index a943a42..1bce198 100755 --- a/mass_profile/calc_lxfx.sh +++ b/mass_profile/calc_lxfx.sh @@ -7,6 +7,9 @@ # Output: # * lx_result.txt # * fx_result.txt +# * summary_lx.dat +# * summary_fx.dat +# * lx_beta_param.txt / lx_dbeta_param.txt # # Author: Junhua GU # Created: 2013-06-24 @@ -107,8 +110,8 @@ FX1=`grep '^Fx1' ${LX_RES} | awk '{ print $2 }'` FX2=`grep '^Fx2' ${LX_RES} | awk '{ print $2 }'` FX3=`grep '^Fx3' ${LX_RES} | awk '{ print $2 }'` -echo $LX1 $LX2 $LX3 >summary_lx.dat -echo $FX1 $FX2 $FX3 >summary_fx.dat +echo "${LX1} ${LX2} ${LX3}" >summary_lx.dat +echo "${FX1} ${FX2} ${FX3}" >summary_fx.dat # save the calculated central values mv ${LX_RES} ${LX_RES%.txt}_center.txt @@ -118,8 +121,8 @@ mv lx_rho_fit.dat lx_rho_fit_center.dat # only calculate the central values if [ "${F_C}" = "YES" ]; then echo "Calculate the central values only ..." - ${base_path}/analyze_lx.py - ${base_path}/analyze_fx.py + ${base_path}/analyze_lxfx.py "Lx" summary_lx.dat lx_result.txt ${BLIST} + ${base_path}/analyze_lxfx.py "Fx" summary_fx.dat fx_result.txt ${BLIST} exit 0 fi @@ -139,19 +142,22 @@ for i in `seq 1 ${MC_TIMES}`; do exit 11 fi - echo >temp_sbp.cfg + # clear ${TMP_SBP_CFG} + TMP_SBP_CFG="temp_sbp.cfg" + # : > ${TMP_SBP_CFG} + [ -e "${TMP_SBP_CFG}" ] && rm -f ${TMP_SBP_CFG} cat ${sbp_cfg} | while read l; do if echo "${l}" | grep -q '^sbp_file' >/dev/null; then - echo "sbp_file temp_shuffled_sbp.dat" >>temp_sbp.cfg + echo "sbp_file temp_shuffled_sbp.dat" >> ${TMP_SBP_CFG} elif echo "${l}" | grep -q '^T_file' >/dev/null; then - echo "T_file ${T_file}" >>temp_sbp.cfg + echo "T_file ${T_file}" >> ${TMP_SBP_CFG} else - echo "${l}" >>temp_sbp.cfg + echo "${l}" >> ${TMP_SBP_CFG} fi done echo "### `pwd -P`" - echo "### $i ###" + echo "### $i / ${MC_TIMES} ###" ${base_path}/coolfunc_calc.sh ${T_file} $abund $nh $z $cfunc_file ${base_path}/coolfunc_calc_erg.sh ${T_file} $abund $nh $z "cfunc_" ${BLIST} ${base_path}/${PROG} temp_sbp.cfg ${rout} \ @@ -165,12 +171,12 @@ for i in `seq 1 ${MC_TIMES}`; do FX2=`grep '^Fx2' ${LX_RES} | awk '{ print $2 }'` FX3=`grep '^Fx3' ${LX_RES} | awk '{ print $2 }'` - echo $LX1 $LX2 $LX3 >>summary_lx.dat - echo $FX1 $FX2 $FX3 >>summary_fx.dat + echo "${LX1} ${LX2} ${LX3}" >>summary_lx.dat + echo "${FX1} ${FX2} ${FX3}" >>summary_fx.dat done # end of 'for' -# analyze lx & fx -${base_path}/analyze_lx.py -${base_path}/analyze_fx.py +# analyze Lx & Fx Monte Carlo results +${base_path}/analyze_lxfx.py "Lx" summary_lx.dat lx_result.txt ${BLIST} +${base_path}/analyze_lxfx.py "Fx" summary_fx.dat fx_result.txt ${BLIST} exit 0 -- cgit v1.2.2