diff options
author | Aaron LI <aly@aaronly.me> | 2019-01-11 23:57:05 +0800 |
---|---|---|
committer | Aaron LI <aly@aaronly.me> | 2019-01-11 23:57:05 +0800 |
commit | 6b11a5e445db1d50e931e3ed328b5b8d4d1c2efb (patch) | |
tree | d3110db96f77bbf39f09619800e661326f741f99 | |
parent | bfcab7c9b017d98fa54dc7cc245bd9c757dd8f61 (diff) | |
download | atoolbox-6b11a5e445db1d50e931e3ed328b5b8d4d1c2efb.tar.bz2 |
astro/ds9saveimg.sh: save an image of a FITS file with regions
This script helps to save an image of a FITS file with regions loaded.
It is intended to batch save lots of pair of FITS images and region
files.
-rwxr-xr-x | astro/ds9saveimg.sh | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/astro/ds9saveimg.sh b/astro/ds9saveimg.sh new file mode 100755 index 0000000..13cbac1 --- /dev/null +++ b/astro/ds9saveimg.sh @@ -0,0 +1,46 @@ +#!/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} \ + -width 768 -height 768 \ + -zoom to fit \ + -scale linear -scale mode 99.9 \ + -cmap sls \ + -regions format ds9 -regions ${REG} \ + -title ${TITLE} & +PID=$! +echo "Launched ds9 as PID=${PID}" + +retry=1 +while [ ${retry} -ne 0 ]; do + sleep 1 + # Bring the window to the front and snapshot to an image file + wmctrl -a ${TITLE} + xpaset -p ${TITLE} saveimage png ${IMG} + retry=$? +done +echo "${TITLE}: ${FITS} + ${REG} => ${IMG}" + +#echo 'paused ...' && read _ +kill ${PID} |