aboutsummaryrefslogtreecommitdiffstats
path: root/bin/calc_centroid.py
diff options
context:
space:
mode:
authorAaron LI <aaronly.me@outlook.com>2017-03-03 20:18:06 +0800
committerAaron LI <aaronly.me@outlook.com>2017-03-03 20:18:06 +0800
commit4b3838ffa302b9e8b32cb2223c53fc0714973cf5 (patch)
treee5744a772a6e68312cd901315e9386c507879bdb /bin/calc_centroid.py
parent71b73143b0b33853a7584a8de8b8b6ddcb77286f (diff)
downloadchandra-acis-analysis-4b3838ffa302b9e8b32cb2223c53fc0714973cf5.tar.bz2
calc_centroid.py: Do not need to use tempfile
Diffstat (limited to 'bin/calc_centroid.py')
-rwxr-xr-xbin/calc_centroid.py15
1 files changed, 6 insertions, 9 deletions
diff --git a/bin/calc_centroid.py b/bin/calc_centroid.py
index 7df71b1..c0bc02d 100755
--- a/bin/calc_centroid.py
+++ b/bin/calc_centroid.py
@@ -14,7 +14,6 @@ import os
import sys
import argparse
import subprocess
-import tempfile
from _context import acispy
from acispy.manifest import get_manifest
@@ -98,14 +97,12 @@ def get_centroid(image, center, radius=50):
(Physical) coordinate of the centroid.
"""
x, y = center
- with tempfile.NamedTemporaryFile(mode="w+") as fp:
- fp.file.write("circle(%f,%f,%f)\n" % (x, y, radius))
- fp.file.flush()
- subprocess.check_call(["punlearn", "dmstat"])
- subprocess.check_call([
- "dmstat", "infile=%s[sky=region(%s)]" % (image, fp.name),
- "centroid=yes", "media=no", "sigma=no", "clip=no", "verbose=0"
- ])
+ region = "circle(%f,%f,%f)" % (x, y, radius)
+ subprocess.check_call(["punlearn", "dmstat"])
+ subprocess.check_call([
+ "dmstat", "infile=%s[sky=%s]" % (image, region),
+ "centroid=yes", "media=no", "sigma=no", "clip=no", "verbose=0"
+ ])
centroid = subprocess.check_output([
"pget", "dmstat", "out_cntrd_phys"
]).decode("utf-8").strip()