aboutsummaryrefslogtreecommitdiffstats
path: root/mod_ly/lx_simple_gxy_rs.sh
diff options
context:
space:
mode:
authorWeitian LI <liweitianux@gmail.com>2014-06-18 22:20:59 +0800
committerWeitian LI <liweitianux@gmail.com>2014-06-18 22:20:59 +0800
commite3923265d0d6949407a83726e9a9bd5d97079221 (patch)
tree9afd8520595f4cf80815b9bccfc3dcf2879ebe47 /mod_ly/lx_simple_gxy_rs.sh
downloadchandra-acis-analysis-e3923265d0d6949407a83726e9a9bd5d97079221.tar.bz2
Initial commit
Added files: * mass_profile: developed by Junhua GU, modified by Weitian LI * opt_utilities: developed by Junhua GU * tools/cosmo_calc: originated from 'calc_distance', modified * scripts: scripts used to process Chandra ACIS data * files: useful files used in processing * HOWTO_chandra_acis_process.txt * README.md
Diffstat (limited to 'mod_ly/lx_simple_gxy_rs.sh')
-rwxr-xr-xmod_ly/lx_simple_gxy_rs.sh104
1 files changed, 104 insertions, 0 deletions
diff --git a/mod_ly/lx_simple_gxy_rs.sh b/mod_ly/lx_simple_gxy_rs.sh
new file mode 100755
index 0000000..e424f4c
--- /dev/null
+++ b/mod_ly/lx_simple_gxy_rs.sh
@@ -0,0 +1,104 @@
+#!/bin/sh
+#
+unalias -a
+export LC_COLLATE=C
+# fix path for python
+export PATH="/usr/bin:$PATH"
+###########################################################
+## calc lx, based on `calc_lx', modified for gxy ##
+## ##
+## LIweitiaNux <liweitianux@gmail.com> ##
+## November 3, 2012 ##
+###########################################################
+
+## usage, `path_conffile' is the configuration file
+## which contains the `path' to each `repro/mass' directory
+if [ $# -eq 1 ]; then
+ # process dir
+ MDIR="$1"
+elif [ $# -eq 2 ]; then
+ # process dir
+ MDIR="$1"
+ # separate log file
+ MAIN_LOG="`pwd -P`/`basename $2`"
+else
+ printf "usage:\n"
+ printf " `basename $0` <mass_dir> [ <logfile> ]\n"
+ printf "\nNOTE:\n"
+ printf " script cannot handle \`~' in path\n"
+ exit 1
+fi
+
+if [ ! -d "${MDIR}" ]; then
+ printf "## ERROR: given \`${MDIR}' not a directory\n"
+ exit 2
+fi
+if [ -d "${MAIN_LOG}" ]; then
+ printf "## ERROR: given \`${MAIN_LOG}' IS a file\n"
+ exit 3
+fi
+
+## set the path to the script {{{
+if [ "$0" = `basename $0` ]; then
+ script_path=`which $0`
+ base_path=`dirname ${script_path}`
+else
+ base_path=`dirname $0`
+fi
+LX1_SCRIPT="$base_path/luminosity_0.1-2.4_lwt_rs.sh"
+LX2_SCRIPT="$base_path/luminosity_0.5-2_lwt_rs.sh"
+if [ ! -e "${LX1_SCRIPT}" ] || [ ! -e "${LX2_SCRIPT}" ]; then
+ printf "ERROR: \`LX_SCRIPT' not exist\n"
+ exit 250
+fi
+## script path }}}
+
+# result lines
+RES_LINE=100
+
+# process
+cd ${MDIR}
+printf "Entered dir: \``pwd`'\n"
+# mass fitting conf
+MCONF="`ls fitting_mass.conf global.cfg 2> /dev/null | head -n 1`"
+if [ ! -r "${MCONF}" ]; then
+ printf "ERROR: main configuration file not accessiable\n"
+ exit 10
+else
+ printf "## use main configuration file: \`${MCONF}'\n"
+ LOGFILE="lx_gxy_`date '+%Y%m%d%H'`.log"
+ [ -e "${LOGFILE}" ] && mv -fv ${LOGFILE} ${LOGFILE}_bak
+ TOLOG="tee -a ${LOGFILE}"
+ printf "## use logfile: \`${LOGFILE}'\n"
+ if [ ! -z "${MAIN_LOG}" ]; then
+ printf "## separate main logfile: \`${MAIN_LOG}'\n"
+ fi
+ printf "## working directory: \``pwd -P`'\n" | ${TOLOG}
+ printf "## use configuration files: \`${MCONF}'\n" | ${TOLOG}
+ # fitting_mass logfile, get R500 from it
+ MLOG=`ls ${MCONF%.[confgCONFG]*}*.log | tail -n 1`
+ if [ ! -r "${MLOG}" ]; then
+ printf "## ERROR: mass log file not accessiable\n"
+ exit 20
+ fi
+ R500_VAL=`tail -n ${RES_LINE} ${MLOG} | grep '^r500' | head -n 1 | awk '{ print $2 }'`
+ R200_VAL=`tail -n ${RES_LINE} ${MLOG} | grep '^r200' | head -n 1 | awk '{ print $2 }'`
+ if [ -z "${R500_VAL}" ] || [ -z "${R200_VAL}" ]; then
+ printf "## ERROR: cannot get R500 or R200\n"
+ exit 30
+ fi
+ printf "## R200 (kpc): \`${R200_VAL}'\n" | ${TOLOG}
+ printf "## R500 (kpc): \`${R500_VAL}'\n" | ${TOLOG}
+ printf "## CMD: ${LX1_SCRIPT} ${MCONF} ${R200_VAL} ${R500_VAL}\n" | ${TOLOG}
+# printf "## CMD: ${LX2_SCRIPT} ${MCONF} ${R200_VAL} ${R500_VAL}\n" | ${TOLOG}
+ sh ${LX1_SCRIPT} ${MCONF} ${R200_VAL} ${R500_VAL} | ${TOLOG}
+# sh ${LX2_SCRIPT} ${MCONF} ${R200_VAL} ${R500_VAL} | ${TOLOG}
+ ## append results to main log file
+ if [ ! -z "${MAIN_LOG}" ]; then
+ printf "\n" >> ${MAIN_LOG}
+ printf "`pwd -P`\n" >> ${MAIN_LOG}
+ grep '^L[25]00' ${LOGFILE} >> ${MAIN_LOG}
+ fi
+fi
+printf "\n++++++++++++++++++++++++++++++++++++++\n"
+