summaryrefslogtreecommitdiffstats
path: root/compress_fits.sh
blob: dbce197825feea8b2191ab0f02e93bb039854890 (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
46
47
48
49
50
#!/bin/sh
#
# Compress the FITS files that are not used directly.
#
# Aaron LI
# 2016-04-16
#

# whether to compress all big files (useful for dropped sources)
FLAG_ALL="NO"

# compress command
COMPRESS="xz -v"
#COMPRESS="ls -lh"  # test


case "$1" in
    -[hH]*)
        echo "Usage:"
        echo "    `basename $0` [ -a ] <source_dir1> ..."
        exit 1
        ;;
    -[aA]*)
        FLAG_ALL="YES"
        shift
        ;;
esac


while [ ! -z "$1" ]; do
    source="$1"
    shift
    echo "====== ${source} ======"
    find ${source}/ -type f \
        \( -name 'acis*_repro_evt2.fits' -o \
           -name 'pcadf*_asol*.fits' -o \
           -name 'blanksky_*.fits' -o \
           -name '*_tdet.fits' -o \
           -name 'imgcorr_*.fits' \) \
        -exec ${COMPRESS} '{}' \;
    if [ "${FLAG_ALL}" = "YES" ]; then
        echo "*** ALL ***"
        find ${source}/ -type f \
            \( -name 'evt2_*.fits' -o \
               -name 'expmap_*.fits' -o \
               -name 'img_*.fits' \) \
            -exec ${COMPRESS} '{}' \;
    fi
done