aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/chandra_pb_flux.sh
diff options
context:
space:
mode:
authorWeitian LI <liweitianux@gmail.com>2014-06-18 22:20:59 +0800
committerWeitian LI <liweitianux@gmail.com>2014-06-18 22:20:59 +0800
commite3923265d0d6949407a83726e9a9bd5d97079221 (patch)
tree9afd8520595f4cf80815b9bccfc3dcf2879ebe47 /scripts/chandra_pb_flux.sh
downloadchandra-acis-analysis-e3923265d0d6949407a83726e9a9bd5d97079221.tar.bz2
Initial commit
Added files: * mass_profile: developed by Junhua GU, modified by Weitian LI * opt_utilities: developed by Junhua GU * tools/cosmo_calc: originated from 'calc_distance', modified * scripts: scripts used to process Chandra ACIS data * files: useful files used in processing * HOWTO_chandra_acis_process.txt * README.md
Diffstat (limited to 'scripts/chandra_pb_flux.sh')
-rwxr-xr-xscripts/chandra_pb_flux.sh43
1 files changed, 43 insertions, 0 deletions
diff --git a/scripts/chandra_pb_flux.sh b/scripts/chandra_pb_flux.sh
new file mode 100755
index 0000000..d6860f8
--- /dev/null
+++ b/scripts/chandra_pb_flux.sh
@@ -0,0 +1,43 @@
+#!/bin/sh
+#
+# chandra particle background
+# 9.5-12.0 keV (channel: 651-822)
+# PI = [ energy(eV) / 14.6 eV + 1 ]
+#
+# LIweitiaNux <liweitianux@gmail.com>
+# July 30, 2012
+#
+# ChangeLog:
+# v1.1: August 2, 2012
+# fix bugs with scientific notation in `bc'
+#
+
+if [ $# -eq 0 ]; then
+ echo "usage:"
+ echo " `basename $0` <spec> ..."
+ exit 1
+fi
+
+## energy range: 9.5 -- 12.0 keV
+CH_LOW=651
+CH_HI=822
+
+echo "CHANNEL: $CH_LOW -- $CH_HI"
+
+while ! [ -z $1 ]; do
+ f=$1
+ shift
+ echo "FILE: $f"
+ punlearn dmstat
+ COUNTS=`dmstat "$f[channel=${CH_LOW}:${CH_HI}][cols counts]" | grep 'sum:' | awk '{ print $2 }'`
+ punlearn dmkeypar
+ EXPTIME=`dmkeypar $f EXPOSURE echo=yes`
+ BACK=`dmkeypar $f BACKSCAL echo=yes`
+ # fix `scientific notation' bug for `bc'
+ EXPTIME_B=`echo ${EXPTIME} | sed 's/[eE]/\*10\^/' | sed 's/+//'`
+ BACK_B=`echo "( ${BACK} )" | sed 's/[eE]/\*10\^/' | sed 's/+//'`
+ PB_FLUX=`echo "scale = 16; ${COUNTS} / ${EXPTIME_B} / ${BACK_B}" | bc -l`
+ echo " counts / exptime / backscal: ${COUNTS} / ${EXPTIME} / ${BACK}"
+ echo " ${PB_FLUX}"
+done
+