make_blanksky.py 文件源码

python
阅读 20 收藏 0 点赞 0 评论 0

项目:chandra-acis-analysis 作者: liweitianux 项目源码 文件源码
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)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号