def get_auto_clim_values(self, *args):
"""
Set min/max of display to n_sigma_below and n_sigma_above background
'cheat' for speed by sampling only a subset of pts
"""
finite_mask = np.isfinite(self.display_image)
n_finite_pts = finite_mask.sum()
if n_finite_pts > 0:
n_pts = 1000
# sample ALL points unless the sampled points will be reasonably nicely distributed. e.g.
# n_pts=1000, n_finite_pts=1999 -> all samples would be clumped in one half.
# factor of 5* means that the 'missing' unsampled clump at the end is <=20% of total pts, which seems reasonable
if n_finite_pts < (5*n_pts):
robust_mean, robust_median, robust_stdev = sigma_clipped_stats(self.display_image[finite_mask])
else:
stepsize = n_finite_pts/n_pts
robust_mean, robust_median, robust_stdev = sigma_clipped_stats(self.display_image[finite_mask].ravel()[0::stepsize])
n_sigma_below = 1.0
n_sigma_above = 6.
return (robust_mean - n_sigma_below * robust_stdev, robust_mean + n_sigma_above * robust_stdev)
else:
return (0., 0.) # no valid pixels
评论列表
文章目录