summaryrefslogtreecommitdiffstats
path: root/ds9_image.sh
blob: d4538d12476899b0c164f090a1f3362d1c99a6dd (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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#!/bin/sh
#
# Copyright (c) 2016-2017 Aaron LI
# MIT license
#
# Use DS9 to visualize the ACIS image, with useful/handy
# arguments/options passed.
# Also touch the output image filename for quicker save.
#
# NOTE:
# Tool `manifest.py` is part of the `chandra-acis-analysis` repository.
#
# Created: 2016-04-16
#
# Change logs:
# 2017-02-13:
#   * Use `manifest.py` from `chandra-acis-analysis`
#   * Some cleanups
#

# Default parameters
DS9_GEOMETRY=${DS9_GEOMETRY:-1288x1026-0+0}
DS9_REG_FORMAT=${DS9_REG_FORMAT:-ds9}
DS9_SMOOTH_RADIUS=${DS9_SMOOTH_RADIUS:-4}
DS9_SCALE=${DS9_SCALE:-asinh}
DS9_CMAP=${DS9_CMAP:-sls}


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


INIT_DIR=$(pwd -P)
while [ ! -z "$1" ]; do
    imgdir="$1"
    shift
    cd ${imgdir}
    echo "====== ${PWD} ======"
    FILE=$(manifest.py getpath img_fill)
    if [ -z "${FILE}" ]; then
        echo "*** WARNING: no image file found ***"
        continue
    fi
    echo "FITS file: ${FILE}"
    #
    PNG_FILE="$(echo "${FILE%.fits}" | sed -e 's/_c7//' -e 's/_c0-3//').png"
    [ ! -f "${PNG_FILE}" ] && touch ${PNG_FILE}
    echo "PNG file: ${PNG_FILE}"
    # FoV region
    FOV=$(manifest.py getpath fov)
    DS9_REG_FOV="-regions color green -regions ${REG_FOV}"
    #
    ds9 ${FILE} \
        -bin factor 1 \
        -smooth radius ${DS9_SMOOTH_RADIUS} -smooth yes \
        -scale ${DS9_SCALE} \
        -cmap ${DS9_CMAP} \
        -geometry ${DS9_GEOMETRY} \
        -regions format ${DS9_REG_FORMAT} \
        -regions color white -regions ${REG_FILE} \
        ${DS9_REG_FOV}
    #
    cd ${INIT_DIR}
done