From b08d3e041c095becd9a84ef62e827d4219b24923 Mon Sep 17 00:00:00 2001 From: Aaron LI Date: Tue, 7 Jun 2016 17:19:27 +0800 Subject: mass_profile: merge 'calc_lx_{d,}beta.sh' => 'calc_lxfx.sh' * Rename 'calc_lxfx_simple.sh' to 'calc_lxfx_wrapper.sh' * Update 'calc_lxfx_wrapper.sh' accordingly * Update README.md accordingly --- mass_profile/calc_lx_beta.sh | 161 ---------------------------------- mass_profile/calc_lx_dbeta.sh | 161 ---------------------------------- mass_profile/calc_lxfx.sh | 176 ++++++++++++++++++++++++++++++++++++++ mass_profile/calc_lxfx_simple.sh | 75 ---------------- mass_profile/calc_lxfx_wrapper.sh | 76 ++++++++++++++++ 5 files changed, 252 insertions(+), 397 deletions(-) delete mode 100755 mass_profile/calc_lx_beta.sh delete mode 100755 mass_profile/calc_lx_dbeta.sh create mode 100755 mass_profile/calc_lxfx.sh delete mode 100755 mass_profile/calc_lxfx_simple.sh create mode 100755 mass_profile/calc_lxfx_wrapper.sh (limited to 'mass_profile') diff --git a/mass_profile/calc_lx_beta.sh b/mass_profile/calc_lx_beta.sh deleted file mode 100755 index b007b4f..0000000 --- a/mass_profile/calc_lx_beta.sh +++ /dev/null @@ -1,161 +0,0 @@ -#!/bin/sh - -echo "### \$#: $#" -echo "### `pwd -P`" -if [ $# -gt 1 ] -then - : -else - echo "Usage:$0 [c]" - echo "If central value only, append a \"c\"" - exit -fi -export PATH="/usr/local/bin:/usr/bin:/bin:$PATH" -export PGPLOT_FONT="${HEADAS}/lib/grfont.dat" - -# blist file -# (energy bands to calc cooling function data) -BLIST="blist.txt" -[ -e "${BLIST}" ] && mv -f ${BLIST} ${BLIST}_bak -cat > ${BLIST} << _EOF_ -bolo -0.7 7 -0.1 2.4 -_EOF_ - -cfg_file=$1 -rout=$2 -base_path=`dirname $0` -echo $base_path -#initialize sbp config file -sbp_cfg=`grep '^sbp_cfg' $cfg_file|awk '{print $2}'` -#initialize profile type name -t_profile_type=`grep '^t_profile' $cfg_file|awk '{print $2}'` -#initialize data file name -t_data_file=`grep '^t_data_file' $cfg_file|awk '{print $2}'` -#initialize sbp data file -sbp_data_file=`grep '^sbp_file' $sbp_cfg | awk '{ print $2 }'` -#initialize the temperature profile file -T_file=`grep '^T_file' $sbp_cfg|awk '{print $2}'` -#initialize the rmin_kpc for nfw mass profile fitting -nfw_rmin_kpc=`grep '^nfw_rmin_kpc' $cfg_file|awk '{print $2}'` -#echo $t_profile_type -cm_per_pixel=`grep '^cm_per_pixel' $sbp_cfg|awk '{print $2}'` -da=`python -c "print($cm_per_pixel/(.492/3600/180*3.1415926))"` - -#determine which temperature profile to be used, and fit the T profile -if [ "$t_profile_type" = "wang2012" ]; then - t_param_file=`grep t_param_file $cfg_file|awk '{print $2}'` - $base_path/fit_wang2012_model $t_data_file $t_param_file $cm_per_pixel 2> /dev/null - mv -f wang2012_dump.qdp ${T_file} -else - echo temperature profile name invalid! - exit -fi - -cfunc_file=`grep '^cfunc_file' ${sbp_cfg} |awk '{print $2}'` -z=`grep '^z' ${sbp_cfg}|awk '{print $2}'` -dl=`python -c "print($da*(1+$z)**2)"` -abund=`grep '^abund' ${cfg_file} |awk '{print $2}'` -nh=`grep '^nh' ${cfg_file} |awk '{print $2}'` -$base_path/coolfunc_calc.sh ${T_file} $abund $nh $z $cfunc_file -#$base_path/coolfunc_calc_bolo.sh ${T_file} $abund $nh $z cfunc_bolo.dat -#$base_path/coolfunc_calc_0.7-7.sh ${T_file} $abund $nh $z cfunc_0.7-7.dat -#$base_path/coolfunc_calc_0.1-2.4.sh ${T_file} $abund $nh $z cfunc_0.1-2.4.dat -$base_path/coolfunc_calc_erg.sh ${T_file} $abund $nh $z "cfunc_" ${BLIST} -mv flux_cnt_ratio.txt flux_cnt_ratio_center.txt -#fit sbp -prog="calc_lx_beta" -lx_res="lx_beta_param.txt" -$base_path/${prog} $sbp_cfg $rout cfunc_bolo.dat cfunc_0.7-7.dat cfunc_0.1-2.4.dat 2> /dev/null -LX1=`grep 'Lx1' $lx_res |awk '{print $2}'` -LX2=`grep 'Lx2' $lx_res |awk '{print $2}'` -LX3=`grep 'Lx3' $lx_res |awk '{print $2}'` -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 $cfunc_file -#exit - -#store central value -mv ${lx_res} ${lx_res%.txt}_center.txt -mv lx_sbp_fit.qdp lx_sbp_fit_center.qdp -mv lx_rho_fit.dat lx_rho_fit_center.dat - -#rm -f summary_lx.dat -#calculate cooling time -#echo $dl - -## calculate center values -if [ $# -eq 3 ]; then - $base_path/analyze_lx.py - $base_path/analyze_fx.py - exit 0 -fi - - -########################################################### -#100 times of Monte-carlo simulation to determine error -#just repeat above steps -for i in `seq 1 100`; do - echo $t_data_file - $base_path/shuffle_T.py $t_data_file temp_shuffled_t.dat - $base_path/shuffle_sbp.py $sbp_data_file temp_shuffled_sbp.dat - #t_data_file=temp_shuffled_t.dat - #exit - - if [ "$t_profile_type" = "wang2012" ]; then - t_param_file=`grep t_param_file $cfg_file|awk '{print $2}'` - $base_path/fit_wang2012_model temp_shuffled_t.dat $t_param_file $cm_per_pixel 2> /dev/null - mv -f wang2012_dump.qdp ${T_file} - else - echo temperature profile name invalid! - exit - fi - - echo >temp_sbp.cfg - - cat $sbp_cfg | while read l; do - if echo $l|grep sbp_file >/dev/null - then - echo sbp_file temp_shuffled_sbp.dat >>temp_sbp.cfg - elif echo $l|grep T_file >/dev/null - then - echo T_file ${T_file} >>temp_sbp.cfg - else - echo $l >>temp_sbp.cfg - fi - done - - #exit - - echo "### `pwd -P`" - echo "### $i ###" - - $base_path/coolfunc_calc.sh ${T_file} $abund $nh $z $cfunc_file - #$base_path/coolfunc_calc_bolo.sh ${T_file} $abund $nh $z cfunc_bolo.dat - #$base_path/coolfunc_calc_0.7-7.sh ${T_file} $abund $nh $z cfunc_0.7-7.dat - #$base_path/coolfunc_calc_0.1-2.4.sh ${T_file} $abund $nh $z cfunc_0.1-2.4.dat - $base_path/coolfunc_calc_erg.sh ${T_file} $abund $nh $z "cfunc_" ${BLIST} - $base_path/$prog temp_sbp.cfg $rout cfunc_bolo.dat cfunc_0.7-7.dat cfunc_0.1-2.4.dat 2> /dev/null - #grep Lx $lx_res |awk '{print $2}' >>summary_lx.dat - LX1=`grep 'Lx1' $lx_res |awk '{print $2}'` - LX2=`grep 'Lx2' $lx_res |awk '{print $2}'` - LX3=`grep 'Lx3' $lx_res |awk '{print $2}'` - 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 -done # end of 'for' - -# analyze lx & fx -$base_path/analyze_lx.py -$base_path/analyze_fx.py - -exit 0 - diff --git a/mass_profile/calc_lx_dbeta.sh b/mass_profile/calc_lx_dbeta.sh deleted file mode 100755 index 104e4b3..0000000 --- a/mass_profile/calc_lx_dbeta.sh +++ /dev/null @@ -1,161 +0,0 @@ -#!/bin/sh - -echo "### \$#: $#" -echo "### `pwd -P`" -if [ $# -gt 1 ] -then - : -else - echo "Usage:$0 [c]" - echo "If central value only, append a \"c\"" - exit -fi -export PATH="/usr/local/bin:/usr/bin:/bin:$PATH" -export PGPLOT_FONT="${HEADAS}/lib/grfont.dat" - -# blist file -# (energy bands to calc cooling function data) -BLIST="blist.txt" -[ -e "${BLIST}" ] && mv -f ${BLIST} ${BLIST}_bak -cat > ${BLIST} << _EOF_ -bolo -0.7 7 -0.1 2.4 -_EOF_ - -cfg_file=$1 -rout=$2 -base_path=`dirname $0` -echo $base_path -#initialize sbp config file -sbp_cfg=`grep '^sbp_cfg' $cfg_file|awk '{print $2}'` -#initialize profile type name -t_profile_type=`grep '^t_profile' $cfg_file|awk '{print $2}'` -#initialize data file name -t_data_file=`grep '^t_data_file' $cfg_file|awk '{print $2}'` -#initialize sbp data file -sbp_data_file=`grep '^sbp_file' $sbp_cfg | awk '{ print $2 }'` -#initialize the temperature profile file -T_file=`grep '^T_file' $sbp_cfg|awk '{print $2}'` -#initialize the rmin_kpc for nfw mass profile fitting -nfw_rmin_kpc=`grep '^nfw_rmin_kpc' $cfg_file|awk '{print $2}'` -#echo $t_profile_type -cm_per_pixel=`grep '^cm_per_pixel' $sbp_cfg|awk '{print $2}'` -da=`python -c "print($cm_per_pixel/(.492/3600/180*3.1415926))"` - -#determine which temperature profile to be used, and fit the T profile -if [ "$t_profile_type" = "wang2012" ]; then - t_param_file=`grep t_param_file $cfg_file|awk '{print $2}'` - $base_path/fit_wang2012_model $t_data_file $t_param_file $cm_per_pixel 2> /dev/null - mv -f wang2012_dump.qdp ${T_file} -else - echo temperature profile name invalid! - exit -fi - -cfunc_file=`grep '^cfunc_file' ${sbp_cfg} |awk '{print $2}'` -z=`grep '^z' ${sbp_cfg}|awk '{print $2}'` -dl=`python -c "print($da*(1+$z)**2)"` -abund=`grep '^abund' ${cfg_file} |awk '{print $2}'` -nh=`grep '^nh' ${cfg_file} |awk '{print $2}'` -$base_path/coolfunc_calc.sh ${T_file} $abund $nh $z $cfunc_file -#$base_path/coolfunc_calc_bolo.sh ${T_file} $abund $nh $z cfunc_bolo.dat -#$base_path/coolfunc_calc_0.7-7.sh ${T_file} $abund $nh $z cfunc_0.7-7.dat -#$base_path/coolfunc_calc_0.1-2.4.sh ${T_file} $abund $nh $z cfunc_0.1-2.4.dat -$base_path/coolfunc_calc_erg.sh ${T_file} $abund $nh $z "cfunc_" ${BLIST} -mv flux_cnt_ratio.txt flux_cnt_ratio_center.txt -#fit sbp -prog="calc_lx_dbeta" -lx_res="lx_dbeta_param.txt" -$base_path/${prog} $sbp_cfg $rout cfunc_bolo.dat cfunc_0.7-7.dat cfunc_0.1-2.4.dat 2> /dev/null -LX1=`grep 'Lx1' $lx_res |awk '{print $2}'` -LX2=`grep 'Lx2' $lx_res |awk '{print $2}'` -LX3=`grep 'Lx3' $lx_res |awk '{print $2}'` -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 $cfunc_file -#exit - -#store central value -mv ${lx_res} ${lx_res%.txt}_center.txt -mv lx_sbp_fit.qdp lx_sbp_fit_center.qdp -mv lx_rho_fit.dat lx_rho_fit_center.dat - -#rm -f summary_lx.dat -#calculate cooling time -#echo $dl - -## calculate center values -if [ $# -eq 3 ]; then - $base_path/analyze_lx.py - $base_path/analyze_fx.py - exit 0 -fi - - -########################################################### -#100 times of Monte-carlo simulation to determine error -#just repeat above steps -for i in `seq 1 100`; do - echo $t_data_file - $base_path/shuffle_T.py $t_data_file temp_shuffled_t.dat - $base_path/shuffle_sbp.py $sbp_data_file temp_shuffled_sbp.dat - #t_data_file=temp_shuffled_t.dat - #exit - - if [ "$t_profile_type" = "wang2012" ]; then - t_param_file=`grep t_param_file $cfg_file|awk '{print $2}'` - $base_path/fit_wang2012_model temp_shuffled_t.dat $t_param_file $cm_per_pixel 2> /dev/null - mv -f wang2012_dump.qdp ${T_file} - else - echo temperature profile name invalid! - exit - fi - - echo >temp_sbp.cfg - - cat $sbp_cfg | while read l; do - if echo $l|grep sbp_file >/dev/null - then - echo sbp_file temp_shuffled_sbp.dat >>temp_sbp.cfg - elif echo $l|grep T_file >/dev/null - then - echo T_file ${T_file} >>temp_sbp.cfg - else - echo $l >>temp_sbp.cfg - fi - done - - #exit - - echo "### `pwd -P`" - echo "### $i ###" - - $base_path/coolfunc_calc.sh ${T_file} $abund $nh $z $cfunc_file - #$base_path/coolfunc_calc_bolo.sh ${T_file} $abund $nh $z cfunc_bolo.dat - #$base_path/coolfunc_calc_0.7-7.sh ${T_file} $abund $nh $z cfunc_0.7-7.dat - #$base_path/coolfunc_calc_0.1-2.4.sh ${T_file} $abund $nh $z cfunc_0.1-2.4.dat - $base_path/coolfunc_calc_erg.sh ${T_file} $abund $nh $z "cfunc_" ${BLIST} - $base_path/$prog temp_sbp.cfg $rout cfunc_bolo.dat cfunc_0.7-7.dat cfunc_0.1-2.4.dat 2> /dev/null - #grep Lx $lx_res |awk '{print $2}' >>summary_lx.dat - LX1=`grep 'Lx1' $lx_res |awk '{print $2}'` - LX2=`grep 'Lx2' $lx_res |awk '{print $2}'` - LX3=`grep 'Lx3' $lx_res |awk '{print $2}'` - 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 -done # end of 'for' - -# analyze lx & fx -$base_path/analyze_lx.py -$base_path/analyze_fx.py - -exit 0 - diff --git a/mass_profile/calc_lxfx.sh b/mass_profile/calc_lxfx.sh new file mode 100755 index 0000000..a943a42 --- /dev/null +++ b/mass_profile/calc_lxfx.sh @@ -0,0 +1,176 @@ +#!/bin/sh +# +# Wrapper script used to calculate the luminosity (Lx) and flux (Fx) data, +# which invokes the programming 'calc_lx_beta' (single-beta SBP) or +# 'calc_lx_dbeta' (double-beta SBP). +# +# Output: +# * lx_result.txt +# * fx_result.txt +# +# Author: Junhua GU +# Created: 2013-06-24 +# +# Weitian LI +# 2016-06-07 +# + +if [ $# -eq 2 ] || [ $# -eq 3 ]; then + : +else + echo "usage:" + echo " `basename $0` [c]" + echo "" + echo "arguments:" + echo " : main config file used for mass calculation" + echo " : outer/cut radius within which to calculate Lx & Fx" + echo " e.g., r500, r200 (unit: kpc)" + echo " [c]: optional; if specified, do not calculate the errors" + exit 1 +fi +export PATH="/usr/local/bin:/usr/bin:/bin:$PATH" +export PGPLOT_FONT="${HEADAS}/lib/grfont.dat" + +cfg_file="$1" +rout="$2" +case "$3" in + [cC]) + F_C="YES" + ;; + *) + F_C="NO" + ;; +esac + +base_path=$(dirname $(realpath $0)) + +## Extract settings/values from the config file +# model name of the temperature profile +t_profile_type=`grep '^t_profile' $cfg_file | awk '{ print $2 }'` +# parameter file for temperature profile fitting +t_param_file=`grep '^t_param_file' $cfg_file | awk '{ print $2 }'` +# data points of the temperature profile +t_data_file=`grep '^t_data_file' $cfg_file | awk '{ print $2 }'` +# config file for SBP fitting +sbp_cfg=`grep '^sbp_cfg' $cfg_file | awk '{ print $2 }'` +# SBP flux data +sbp_data_file=`grep '^sbp_file' $sbp_cfg | awk '{ print $2 }'` +# fitted temperature profile +T_file=`grep '^T_file' $sbp_cfg | awk '{ print $2 }'` +# filename of the cooling function data +cfunc_file=`grep '^cfunc_file' $sbp_cfg |awk '{ print $2 }'` +nfw_rmin_kpc=`grep '^nfw_rmin_kpc' $cfg_file | awk '{ print $2 }'` +cm_per_pixel=`grep '^cm_per_pixel' $sbp_cfg | awk '{ print $2 }'` +z=`grep '^z' $sbp_cfg | awk '{ print $2 }'` +nh=`grep '^nh' $cfg_file |awk '{ print $2 }'` +abund=`grep '^abund' $cfg_file |awk '{ print $2 }'` +da=`python -c "print($cm_per_pixel/(0.492/3600/180*3.1415926))"` +dl=`python -c "print($da*(1+$z)**2)"` + +if grep -q '^beta2' $sbp_cfg; then + MODEL="dbeta" +else + MODEL="beta" +fi + +if [ "$t_profile_type" = "wang2012" ]; then + ${base_path}/fit_wang2012_model $t_data_file $t_param_file $cm_per_pixel 2> /dev/null + mv -f wang2012_dump.qdp ${T_file} +else + echo "ERROR: unsupported temperature profile: ${t_profile_type}" + exit 11 +fi + +# energy bands for which the cooling function data will be calculated +BLIST="blist.txt" +[ -e "${BLIST}" ] && mv -f ${BLIST} ${BLIST}_bak +cat > ${BLIST} << _EOF_ +bolo +0.7 7 +0.1 2.4 +_EOF_ + +${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} +mv flux_cnt_ratio.txt flux_cnt_ratio_center.txt + +PROG="calc_lx_${MODEL}" +LXF_RES="lx_${MODEL}_param.txt" +${base_path}/${PROG} ${sbp_cfg} ${rout} \ + cfunc_bolo.dat \ + cfunc_0.7-7.dat \ + cfunc_0.1-2.4.dat 2> /dev/null +LX1=`grep '^Lx1' ${LX_RES} | awk '{ print $2 }'` +LX2=`grep '^Lx2' ${LX_RES} | awk '{ print $2 }'` +LX3=`grep '^Lx3' ${LX_RES} | awk '{ print $2 }'` +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 + +# save the calculated central values +mv ${LX_RES} ${LX_RES%.txt}_center.txt +mv lx_sbp_fit.qdp lx_sbp_fit_center.qdp +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 + exit 0 +fi + + +########################################################### +# Estimate the errors of Lx and Fx by Monte Carlo simulation +MC_TIMES=100 +for i in `seq 1 ${MC_TIMES}`; do + $base_path/shuffle_T.py $t_data_file temp_shuffled_t.dat + $base_path/shuffle_sbp.py $sbp_data_file temp_shuffled_sbp.dat + + if [ "$t_profile_type" = "wang2012" ]; then + ${base_path}/fit_wang2012_model temp_shuffled_t.dat $t_param_file $cm_per_pixel 2> /dev/null + mv -f wang2012_dump.qdp ${T_file} + else + echo "ERROR: unsupported temperature profile: ${t_profile_type}" + exit 11 + fi + + echo >temp_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 + elif echo "${l}" | grep -q '^T_file' >/dev/null; then + echo "T_file ${T_file}" >>temp_sbp.cfg + else + echo "${l}" >>temp_sbp.cfg + fi + done + + echo "### `pwd -P`" + echo "### $i ###" + ${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} \ + cfunc_bolo.dat \ + cfunc_0.7-7.dat \ + cfunc_0.1-2.4.dat 2> /dev/null + LX1=`grep '^Lx1' ${LX_RES} | awk '{ print $2 }'` + LX2=`grep '^Lx2' ${LX_RES} | awk '{ print $2 }'` + LX3=`grep '^Lx3' ${LX_RES} | awk '{ print $2 }'` + 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 +done # end of 'for' + +# analyze lx & fx +${base_path}/analyze_lx.py +${base_path}/analyze_fx.py + +exit 0 diff --git a/mass_profile/calc_lxfx_simple.sh b/mass_profile/calc_lxfx_simple.sh deleted file mode 100755 index 4b6d632..0000000 --- a/mass_profile/calc_lxfx_simple.sh +++ /dev/null @@ -1,75 +0,0 @@ -#!/bin/sh -# -########################################################### -# to calculate the Lx Fx data -# based on 'loop_lx.sh', but to calculate one src per time -# -# LIweitiaNux -# 2013/10/30 -########################################################### - - -full_path=`readlink -f $0` -base_dir=`dirname $full_path` - -if [ $# -lt 2 ]; then - printf "usage:\n" - printf " `basename $0` [c] < 500 | 200 > ...\n" - exit 1 -fi - -cfg_file="$1" -pre_results="final_result.txt" - -case "$2" in - [cC]*) - F_C="YES" - shift - ;; - *) - F_C="NO" - ;; -esac - -shift -echo "delta: $@" # 'printf' not work - -if [ "${F_C}" = "YES" ]; then - printf "MODE: center\n" -fi - -# exit - -if [ ! -r "${cfg_file}" ]; then - printf "ERROR: global cfg not accessible\n" -elif [ ! -r "${pre_results}" ]; then - printf "ERROR: previous '${pre_results}' not accessible\n" -else - sbp_cfg=`grep '^sbp_cfg' $cfg_file | awk '{ print $2 }'` - ## - for delta in $@; do - if grep -q '^beta2' $sbp_cfg; then - MODEL="dbeta" - else - MODEL="beta" - fi - rout=`grep "^r${delta}" ${pre_results} | sed -e 's/=/ /' | awk '{ print $2 }'` - if [ "${F_C}" = "YES" ]; then - lx_res="lx_result_${delta}_c.txt" - fx_res="fx_result_${delta}_c.txt" - CMD="$base_dir/calc_lx_${MODEL}.sh $cfg_file $rout c" - else - lx_res="lx_result_${delta}.txt" - fx_res="fx_result_${delta}.txt" - CMD="$base_dir/calc_lx_${MODEL}.sh $cfg_file $rout" - fi - [ -e "${lx_res}" ] && mv -f ${lx_res} ${lx_res}_bak - [ -e "${fx_res}" ] && mv -f ${fx_res} ${fx_res}_bak - ${CMD} - mv -f lx_result.txt ${lx_res} - mv -f fx_result.txt ${fx_res} - done -fi - -exit 0 - diff --git a/mass_profile/calc_lxfx_wrapper.sh b/mass_profile/calc_lxfx_wrapper.sh new file mode 100755 index 0000000..7dea0d0 --- /dev/null +++ b/mass_profile/calc_lxfx_wrapper.sh @@ -0,0 +1,76 @@ +#!/bin/sh +# +# Calculate the Lx & Fx data. +# +# Based on 'loop_lx.sh', but only process one source +# +# Weitian LI +# 2013-10-30 +# + + +full_path=`readlink -f $0` +base_dir=`dirname $full_path` + +if [ $# -lt 2 ]; then + printf "usage:\n" + printf " `basename $0` [c] < 500 | 200 > ...\n" + exit 1 +fi + +cfg_file="$1" +pre_results="final_result.txt" + +case "$2" in + [cC]*) + F_C="YES" + shift + ;; + *) + F_C="NO" + ;; +esac + +shift +echo "delta: $@" # 'printf' not work + +if [ "${F_C}" = "YES" ]; then + printf "MODE: center\n" +fi + +# exit + +if [ ! -r "${cfg_file}" ]; then + printf "ERROR: global cfg not accessible\n" + exit 11 +elif [ ! -r "${pre_results}" ]; then + printf "ERROR: previous '${pre_results}' not accessible\n" + exit 12 +else + sbp_cfg=`grep '^sbp_cfg' $cfg_file | awk '{ print $2 }'` + ## + for delta in $@; do + if grep -q '^beta2' $sbp_cfg; then + MODEL="dbeta" + else + MODEL="beta" + fi + rout=`grep "^r${delta}" ${pre_results} | sed -e 's/=/ /' | awk '{ print $2 }'` + if [ "${F_C}" = "YES" ]; then + lx_res="lx_result_${delta}_c.txt" + fx_res="fx_result_${delta}_c.txt" + CMD="$base_dir/calc_lxfx.sh $cfg_file $rout c" + else + lx_res="lx_result_${delta}.txt" + fx_res="fx_result_${delta}.txt" + CMD="$base_dir/calc_lxfx.sh $cfg_file $rout" + fi + [ -e "${lx_res}" ] && mv -f ${lx_res} ${lx_res}_bak + [ -e "${fx_res}" ] && mv -f ${fx_res} ${fx_res}_bak + ${CMD} + mv -f lx_result.txt ${lx_res} + mv -f fx_result.txt ${fx_res} + done +fi + +exit 0 -- cgit v1.2.2