summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xbuild_sample.sh76
1 files changed, 63 insertions, 13 deletions
diff --git a/build_sample.sh b/build_sample.sh
index c7020cf..70263d1 100755
--- a/build_sample.sh
+++ b/build_sample.sh
@@ -6,16 +6,20 @@
#
# Aaron LI
# Created: 2016-03-02
-# Updated: 2016-04-26
+# Updated: 2016-06-06
#
-# Changelog:
+# Change log:
+# 2016-06-06:
+# * Add argument "OWNER"
+# * Split out function "copy_mass_files()"
+# * Copy the `mass` related files
# 2016-04-26:
# * Add flag "UPDATE_MODE"
-# * Choose the correct 'img' directory for ZZH's data
+# * Choose the correct `img` directory for ZZH's data
# * Simplify the argument processing
# 2016-04-15:
+# * Replace "_" with "-" in NAME
# * Add support for zzh's sample
-# * Convert "_" to "-" in NAME
#
analyze_path() {
@@ -62,17 +66,42 @@ analyze_path() {
}
+# copy mass-related files
+copy_mass_files() {
+ _mass_dir="$1"
+ _target_dir="$2"
+ _owner="$3"
+ ( \
+ cd ${repro_dir}/mass; \
+ if [ "${_owner}" = "lwt" ]; then \
+ cp -av fitting_*.conf global.cfg wang2012_param.txt \
+ flux_sbp.txt radius_sbp.txt sbprofile.txt \
+ [a-z]*_center.* summary_*.* final_result.txt \
+ ${target_dir}/; \
+ cp -Lv tcl_temp_profile.txt ${target_dir}/; \
+ else \
+ cp -av global.cfg sbp.cfg param_wang.txt \
+ [a-z]*_center.* summary_*.* \
+ final_result.txt ${target_dir}/; \
+ cp -Lv Tprofile.dat radius.dat sbp2.dat sbp3.dat ${target_dir}/; \
+ fi; \
+ )
+ unset _mass_dir _target_dir _owner
+}
+
+
case "$1" in
-[hH]*)
echo "Usage:"
- echo " `basename $0` <dest_root_dir> <repro_dir1> ..."
+ echo " `basename $0` <lwt|zzh> <dest_root_dir> <repro_dir1> ..."
exit 1
;;
esac
UPDATE_MODE="YES"
-DEST_ROOT="$1"
+OWNER="$1"
+DEST_ROOT="$2"
if [ -n "${UPDATE_MODE}" -a ! -d "${DEST_ROOT}" ]; then
echo "UPDATE MODE: '${DEST_ROOT}' dose not exist"
exit 2
@@ -80,12 +109,11 @@ fi
[ ! -d "${DEST_ROOT}" ] && mkdir -v "${DEST_ROOT}"
INIT_DIR=`pwd -P`
-while [ ! -z "$2" ]; do
- repro_dir="$2"
+while [ ! -z "$3" ]; do
+ repro_dir="$3"
shift
OI=`analyze_path "${repro_dir}" | grep '^oi:' | awk '{ print $2 }'`
NAME=`analyze_path "${repro_dir}" | grep '^name:' | awk '{ print $2 }'`
- OWNER=`analyze_path "${repro_dir}" | grep '^owner:' | awk '{ print $2 }'`
# avoid "_" in name
NAME=`echo "${NAME}" | tr '_' '-'`
echo "********* ${NAME}_oi${OI} *********"
@@ -98,12 +126,15 @@ while [ ! -z "$2" ]; do
fi
[ ! -d "${DEST}/repro" ] && mkdir -pv ${DEST}/repro
cd "${DEST}/repro"
- # simply copy the whole sub-directories
+ # copy the re-processed evt2 files
cp -av ${repro_dir}/acisf*.fits .
cp -av ${repro_dir}/acisf*.lis ${repro_dir}/pcadf*.fits .
+ # copy the INFO.json file if present
cp -av ${repro_dir}/*_INFO.json .
+ # copy the cleaned evt2 files and background files
cp -av ${repro_dir}/evt .
cp -av ${repro_dir}/bkg .
+ # copy the `img` directory
if [ "${OWNER}" = "lwt" ]; then
cp -av ${repro_dir}/img .
elif [ "${OWNER}" = "zzh" ]; then
@@ -115,10 +146,29 @@ while [ ! -z "$2" ]; do
echo "WARNING: '${img_dir}/sbprofile.txt' does not exists"
cp -av ${repro_dir}/img .
fi
+ else
+ echo "ERROR: unknown source owner: ${OWNER}"
fi
- # apply clean up
+ # copy the `mass` related files
+ mkdir ./mass
+ cd ./mass
+ target_dir=`pwd -P`
+ if [ "${OWNER}" = "lwt" ]; then
+ copy_mass_files ${repro_dir}/mass ${target_dir} ${OWNER}
+ elif [ "${OWNER}" = "zzh" ]; then
+ if [ -d "${mass_dir}/../evt2/mass" ]; then
+ copy_mass_files ${repro_dir}/../evt2/mass ${target_dir} ${OWNER}
+ elif [ -d "${repro_dir}/mass" ]; then
+ copy_mass_files ${repro_dir}/mass ${target_dir} ${OWNER}
+ else
+ echo "ERROR: no mass directory found!"
+ fi
+ else
+ echo "ERROR: unknown source owner: ${OWNER}"
+ fi
+ cd ${target_dir}
+ # clean up the copied products
find . \( -iname '*_bak' -o -iname '_tmp*' \) -delete
find . -type l -iname '*.dat' -delete
- cd "${INIT_DIR}"
+ cd ${INIT_DIR}
done
-