diff options
author | Aaron LI <aaronly.me@outlook.com> | 2017-02-23 22:23:29 +0800 |
---|---|---|
committer | Aaron LI <aaronly.me@outlook.com> | 2017-02-23 22:23:29 +0800 |
commit | 26d46a1c14a7a84910e9fa6fc16e524521afe26e (patch) | |
tree | cb9db29a8a925c4639ff2079900e95f1e1a75332 | |
parent | c244b711e92e8f396f8611c0fe30ac84160d9684 (diff) | |
download | chandra-acis-analysis-26d46a1c14a7a84910e9fa6fc16e524521afe26e.tar.bz2 |
event2image.py: Use 'logging' instead of 'print'
-rwxr-xr-x | bin/event2image.py | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/bin/event2image.py b/bin/event2image.py index 66fdf91..e41368d 100755 --- a/bin/event2image.py +++ b/bin/event2image.py @@ -5,13 +5,11 @@ """ Make image by binning the event file, and update the manifest. - -TODO: use logging module instead of print() """ -import sys import argparse import subprocess +import logging from _context import acispy from acispy.manifest import get_manifest @@ -20,6 +18,10 @@ from acispy.acis import ACIS from acispy.header import write_keyword +logging.basicConfig(level=logging.INFO) +logger = logging.getLogger(__name__) + + def make_image(infile, outfile, chips, erange, fov, clobber=False): """ Make image by binning the event file. @@ -43,6 +45,8 @@ def make_image(infile, outfile, chips, erange, fov, clobber=False): fregion = "sky=region(%s[ccd_id=%s])" % (fov, chips) fenergy = "energy=%s" % erange fbin = "bin sky=::1" + logger.info("Make image: %s[%s][%s][%s]" % + (infile, fregion, fenergy, fbin)) subprocess.check_call(["punlearn", "dmcopy"]) subprocess.check_call([ "dmcopy", "infile=%s[%s][%s][%s]" % (infile, fregion, fenergy, fbin), @@ -56,7 +60,7 @@ def main(): parser.add_argument("-L", "--elow", dest="elow", type=int, default=700, help="lower energy limit [eV] of the output image " + "(default: 700 [eV])") - parser.add_argument("-H", "--ehigh", dest="ehigh", type=int, + parser.add_argument("-H", "--ehigh", dest="ehigh", type=int, default=7000, help="upper energy limit [eV] of the output image " + "(default: 7000 [eV])") parser.add_argument("-i", "--infile", dest="infile", @@ -65,8 +69,6 @@ def main(): parser.add_argument("-o", "--outfile", dest="outfile", help="output image filename (default: " + "build in format 'img_c<chip>_e<elow>-<ehigh>.fits')") - parser.add_argument("-v", "--verbose", dest="verbose", action="store_true", - help="show verbose information") parser.add_argument("-C", "--clobber", dest="clobber", action="store_true", help="overwrite existing file") args = parser.parse_args() @@ -88,12 +90,11 @@ def main(): else: outfile = "img_c{chips}_e{erange}.fits".format( chips=chips, erange=erange) - if args.verbose: - print("infile:", infile, file=sys.stderr) - print("outfile:", outfile, file=sys.stderr) - print("fov:", fov, file=sys.stderr) - print("chips:", chips, file=sys.stderr) - print("erange:", erange, file=sys.stderr) + logger.info("infile: %s" % infile) + logger.info("outfile: %s" % outfile) + logger.info("fov: %s" % fov) + logger.info("chips: %s" % chips) + logger.info("erange: %s" % erange) make_image(infile, outfile, chips, erange, fov, args.clobber) chips_all = ACIS.get_chips_str(infile) |