summaryrefslogtreecommitdiffstats
path: root/merge_imgdir_zzh.sh
blob: 2cdb6d0c0d9c26a3a1757d60bdcfa2f1666045bf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#!/bin/sh
#
# Clean and merge the two 'img' directories for ZZH's sample data.
#   * 'img': ${name}/${obsid}/evt2/img
#   * 'img2': ${name}/${obsid}/repro/img
# The contents of 'img2' are merged to 'img'.
#
# Aaron LI
# Created: 2016-04-26
#

IMG_DIR="img"
IMG2_DIR="img2"

case "$1" in
    -[hH]*)
        echo "Usage:"
        echo "    `basename $0` <repro_dir1> ..."
        exit 1
        ;;
esac

INIT_DIR=`pwd -P`
while [ ! -z "$1" ]; do
    repro_dir="$1"
    shift
    cd ${INIT_DIR}
    cd ${repro_dir}
    echo "*** ${PWD} ***"
    if [ ! -d "${IMG2_DIR}" ]; then
        echo "WARNING: '${IMG2_DIR}' does not exists; skipped!"
        continue
    fi
    # clean ${IMG_DIR} and ${IMG2_DIR}
    ( cd ${IMG_DIR}; \
        rm -fv _* *.log *bak evt2_*.fits img_*.fits \;
        rm -fv *smooth* *raw* \;
        rm -fv test* tmp* sources* pntsrc* )
    ( cd ${IMG2_DIR}; \
        rm -fv rspec* sbprofile* radius_sbp.txt flux_sbp.txt )
    # merge
    mv -fv ${IMG2_DIR}/* ${IMG_DIR}
    rmdir -v ${IMG2_DIR}
done