ztv.py 文件源码

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

项目:CAAPR 作者: Stargrazer82301 项目源码 文件源码
def load_hdulist_from_fitsfile(self, filename):
        """
        The purpose of wrapping fits.open inside this routine is to put 
        all the warning suppressions, flags, etc in one place.
        """
        with warnings.catch_warnings():
            warnings.simplefilter('ignore')
            max_n_tries = 5
            pause_time_between_tries_sec = 1.
            cur_try = 0
            not_yet_successful = True
            while (cur_try < max_n_tries) and not_yet_successful:
                try:
                    hdulist = fits.open(filename, ignore_missing_end=True)
                    not_yet_successful = False
                except:  # I've only seen IOerror, but might as well catch for all errors and re-try
                    time.sleep(pause_time_between_tries_sec)
                cur_try += 1
        return hdulist
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号