summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAaron LI <aaronly.me@outlook.com>2017-02-13 22:50:50 +0800
committerAaron LI <aaronly.me@outlook.com>2017-02-13 22:50:50 +0800
commit0663a5cfe5733be2ae57f9ec094d7d53aa255b74 (patch)
treea4279efaf8d184f608b6e28b1853cbdc19712f6a
parent179d9b1d00cdcd772da687f02f56bfd8bc52a1f6 (diff)
downloadcexcess-0663a5cfe5733be2ae57f9ec094d7d53aa255b74.tar.bz2
ds9_image.sh: Use "manifest.py" from "chandra-acis-analysis"
-rwxr-xr-xds9_image.sh98
1 files changed, 31 insertions, 67 deletions
diff --git a/ds9_image.sh b/ds9_image.sh
index a65db22..d4538d1 100755
--- a/ds9_image.sh
+++ b/ds9_image.sh
@@ -1,22 +1,29 @@
#!/bin/sh
#
-# Copyright (c) 2016 Aaron LI
+# 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 easier save.
+# 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
-# Updated: 2016-05-08
+#
+# Change logs:
+# 2017-02-13:
+# * Use `manifest.py` from `chandra-acis-analysis`
+# * Some cleanups
#
# Default parameters
-FILE_PATTERN="img_c*_fill.fits"
-REG_FILE=${REG_FILE:-r500.reg}
-REG_FORMAT=${REG_FORMAT:-ds9}
-REG_FOV=${REG_FOV:-skyfov.fits}
-SMOOTH_RADIUS=${SMOOTH_RADIUS:-4}
+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
@@ -28,78 +35,35 @@ case "$1" in
esac
-analyze_path() {
- # extract `obs id' and `source name' from path
- echo "$@" | awk '
- # main part
- {
- if (NF==1) {
- ## oi & name
- input=($1 "/")
- if (input ~ /_oi/) {
- ## PATTERN: .../$name_oi$oi/...
- idx_oi = match(input, /oi[0-9]+/) + 2; # "2" skip the "oi"
- len_oi = RLENGTH - 2;
- oi = substr(input, idx_oi, len_oi);
- idx_name = match(input, /\/[a-zA-Z0-9.+-]+_oi/) + 1;
- len_name = RLENGTH - 4;
- name = substr(input, idx_name, len_name);
- owner = "lwt";
- }
- else {
- ## PATTERN: .../$name/$oi/...
- idx_oi = match(input, /\/[0-9]+\//) + 1;
- len_oi = RLENGTH - 2;
- oi = substr(input, idx_oi, len_oi);
- idx_name1 = match(input, /\/[a-zA-Z0-9_.+-]+\/[0-9]+\//);
- len_name1 = RLENGTH;
- name1 = substr(input, idx_name1, len_name1);
- idx_name = match(name1, /\/[a-zA-Z0-9_.+-]+\//) + 1;
- len_name = RLENGTH - 2;
- name = substr(name1, idx_name, len_name);
- owner = "zzh";
- }
- ## output
- printf("input: %s\n", input)
- printf("oi: %s\nname: %s\nowner: %s\n", oi, name, owner)
- }
- else {
- printf("*** WARNING: invalid input: %s\n", $0)
- }
- }
- # END { }
- '
-}
-
-
-INIT_DIR=`pwd -P`
+INIT_DIR=$(pwd -P)
while [ ! -z "$1" ]; do
imgdir="$1"
shift
cd ${imgdir}
echo "====== ${PWD} ======"
- NAME=`analyze_path "${PWD}" | grep '^name:' | awk '{ print $2 }'`
- FILE=`\ls ${FILE_PATTERN}`
- [ -z "${FILE}" ] && continue
+ FILE=$(manifest.py getpath img_fill)
+ if [ -z "${FILE}" ]; then
+ echo "*** WARNING: no image file found ***"
+ continue
+ fi
echo "FITS file: ${FILE}"
#
- PNG_SUFFIX=`echo "${FILE%.fits}" | sed -e 's/_c7//' -e 's/_c0-3//'`
- PNG_FILE="${NAME}_${PNG_SUFFIX}.png"
+ 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
- if [ -f "${REG_FOV}" ]; then
- DS9_REG_FOV="-regions color green -regions ${REG_FOV}"
- fi
+ FOV=$(manifest.py getpath fov)
+ DS9_REG_FOV="-regions color green -regions ${REG_FOV}"
#
ds9 ${FILE} \
-bin factor 1 \
- -smooth radius ${SMOOTH_RADIUS} -smooth yes \
- -scale asinh \
- -cmap sls \
- -geometry 1288x1026-0+0 \
- -regions format ${REG_FORMAT} \
- -regions color white -regions ${REG_FILE} ${DS9_REG_FOV}
+ -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