def compute_bad_pixel_map(bpm_files, dtype=np.uint8):
'''
Compute a combined bad pixel map provided a list of files
Parameters
----------
bpm_files : list
List of names for the bpm files
dtype : data type
Data type for the final bpm
Returns
bpm : array_like
Combined bad pixel map
'''
# check that we have files
if len(bpm_files) == 0:
raise ValueError('No bad pixel map files provided')
# get shape
shape = fits.getdata(bpm_files[0]).shape
# star with empty bpm
bpm = np.zeros((shape[-2], shape[-1]), dtype=np.uint8)
# fill if files are provided
for f in bpm_files:
data = fits.getdata(f)
bpm = np.logical_or(bpm, data)
bpm = bpm.astype(dtype)
return bpm
评论列表
文章目录