blob: a83a80a74060738a43bfeb963d3ac79eeb91365e (
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
|
#!/bin/sh
#
# Copyright (c) 2019 Aaron LI <aly@aaronly.me>
# MIT License
#
# Use SAOImage ds9 to open a FITS image, load the regions from a region
# file, and then snapshot the window content to an image file via XPA.
#
# References:
# - http://ds9.si.edu/doc/ref/xpa.html#saveimage
#
NAME="${0##*/}"
if [ $# -ne 2 ]; then
echo "usage: ${NAME} <file.fits> <ds9.reg>"
exit 1
fi
FITS="$1"
REG="$2"
IMG="${FITS%.fits}.png"
TITLE="${NAME%.sh}$$"
ds9 ${FITS} \
-scale linear -scale mode 99.9 \
-cmap sls \
-regions format ds9 -regions ${REG} \
-title ${TITLE} &
PID=$!
echo "Launched ds9 as PID=${PID}"
sleep 2
retry=1
while [ ${retry} -ne 0 ]; do
sleep 1
xpaset -p ${TITLE} width 768 &&
xpaset -p ${TITLE} height 768 &&
xpaset -p ${TITLE} zoom to fit
retry=$?
done
# Bring the window to the front and snapshot to an image file
wmctrl -a ${TITLE}
xpaset -p ${TITLE} saveimage png ${IMG}
echo "${TITLE}: ${FITS} + ${REG} => ${IMG}"
#echo 'paused ...' && read _
kill ${PID}
|