aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/ciao_mkimg_det.sh
diff options
context:
space:
mode:
authorAaron LI <aaronly.me@outlook.com>2015-11-08 10:43:41 +0800
committerAaron LI <aaronly.me@outlook.com>2015-11-08 10:43:41 +0800
commitf793a4529761a0a0742bbc6f49d8eca7a357ee9a (patch)
treeb9c5e76f3a42108553847685253374edb118f096 /scripts/ciao_mkimg_det.sh
parent079a815cda3ff2f892fa70988e53ae9d2bbfc579 (diff)
downloadchandra-acis-analysis-f793a4529761a0a0742bbc6f49d8eca7a357ee9a.tar.bz2
Add scripts "ciao_img_rotcrop.sh" and "ciao_mkimg_det.sh".
Writen for ZHANG Chenhao to generate rotated and cropped image for power spectrum analysis. WARNING: the image generated by "ciao_mkimg_det.sh" in the DET coordinate is very different than that in SKY coordinate. Watch out for scientific usage!!!
Diffstat (limited to 'scripts/ciao_mkimg_det.sh')
-rwxr-xr-xscripts/ciao_mkimg_det.sh46
1 files changed, 46 insertions, 0 deletions
diff --git a/scripts/ciao_mkimg_det.sh b/scripts/ciao_mkimg_det.sh
new file mode 100755
index 0000000..3e2d881
--- /dev/null
+++ b/scripts/ciao_mkimg_det.sh
@@ -0,0 +1,46 @@
+#!/bin/sh
+#
+# Make an image from evt2 file by binning the 'TDET' coordinates.
+# If the 'TDET' coordinate information is not available (e.g., blanksky),
+# the 'DET' coordinate is used for binning.
+#
+# Aaron LI
+# 2015/08/21
+#
+
+if [ $# -ne 2 ]; then
+ printf "Usage:\n"
+ printf " `basename $0` <input:evt2> <output:img>\n"
+ exit 1
+fi
+
+EVT2="$1"
+OUTIMG="$2"
+
+# Test whether 'TEDT' coordinate exists?
+if dmlist ${EVT2} cols | grep -q tdet; then
+ COORDX="tdetx"
+ COORDY="tdety"
+else
+ printf "WARNING: tdet coordinate NOT exist! use det instead.\n"
+ COORDX="detx"
+ COORDY="dety"
+fi
+
+# Get TDET/DET coordinate min & max values
+# COORDX:
+punlearn dmstat
+dmstat "${EVT2}[cols ${COORDX}]" >/dev/null 2>&1
+XMIN=`pget dmstat out_min`
+XMAX=`pget dmstat out_max`
+dmstat "${EVT2}[cols ${COORDY}]" >/dev/null 2>&1
+YMIN=`pget dmstat out_min`
+YMAX=`pget dmstat out_max`
+
+BINSPEC="[bin ${COORDX}=${XMIN}:${XMAX}:1,${COORDY}=${YMIN}:${YMAX}:1]"
+
+punlearn dmcopy
+CMD="dmcopy \"${EVT2}${BINSPEC}\" ${OUTIMG}"
+printf "CMD: ${CMD}\n"
+eval ${CMD}
+