def extract_img_background(img_array,
custom_limits=None,
median_diffbelow=200.0,
image_min=None):
'''
This extracts the background of the image array provided:
- masks the array to only values between the median and the min of flux
- then returns the median value in 3 x 3 stamps.
img_array = image to find the background for
custom_limits = use this to provide custom median and min limits for the
background extraction
median_diffbelow = subtract this value from the median to get the upper
bound for background extraction
image_min = use this value as the lower bound for background extraction
'''
if not custom_limits:
backmax = np.median(img_array)-median_diffbelow
backmin = image_min if image_min is not None else np.nanmin(img_array)
else:
backmin, backmax = custom_limits
masked = npma.masked_outside(img_array, backmin, backmax)
backmasked = npma.median(masked)
return backmasked
## IMAGE SECTION FUNCTIONS ##
评论列表
文章目录