def merge_blanksky(infiles, outfile, clobber=False):
"""
Merge multiple blanksky files (e.g., 4 blanksky files for ACIS-I)
into a single file.
"""
if len(infiles) == 1:
logger.info("Only one blanksky file, no need to merge.")
if os.path.exists(outfile) and (not clobber):
raise OSError("File already exists: %s" % outfile)
shutil.move(infiles[0], outfile)
else:
logger.info("Merge multiple blanksky files ...")
clobber = "yes" if clobber else "no"
subprocess.check_call(["punlearn", "dmmerge"])
subprocess.check_call([
"dmmerge", "infile=%s" % ",".join(infiles),
"outfile=%s" % outfile, "clobber=%s" % clobber
])
write_keyword(outfile, keyword="DETNAM", value="ACIS-0123")
for f in infiles:
os.remove(f)
# Add write permission to the background file
st = os.stat(outfile)
os.chmod(outfile, st.st_mode | stat.S_IWUSR)
make_blanksky.py 文件源码
python
阅读 20
收藏 0
点赞 0
评论 0
评论列表
文章目录