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
评论列表
文章目录