def deconvolve(dirty, psf, model, facet, gthreshold, msk=None): if prefix == '': lprefix = "subimage %d" % facet else: lprefix = "%s, subimage %d" % (prefix, facet) if nmoment > 0: moment0 = calculate_image_frequency_moments(dirty) this_peak = numpy.max(numpy.abs( moment0.data[0, ...])) / dirty.data.shape[0] else: ref_chan = dirty.data.shape[0] // 2 this_peak = numpy.max(numpy.abs(dirty.data[ref_chan, ...])) if this_peak > 1.1 * gthreshold: kwargs['threshold'] = gthreshold result, _ = deconvolve_cube(dirty, psf, prefix=lprefix, mask=msk, **kwargs) if result.data.shape[0] == model.data.shape[0]: result.data += model.data return result else: return copy_image(model)
def threshold_list(imagelist, threshold, fractional_threshold, use_moment0=True, prefix=''): """ Find actual threshold for list of results, optionally using moment 0 :param imagelist: :param threshold: Absolute threshold :param fractional_threshold: Fractional threshold :param use_moment0: Use moment 0 for threshold :return: """ peak = 0.0 for i, result in enumerate(imagelist): if use_moment0: moments = calculate_image_frequency_moments(result) this_peak = numpy.max(numpy.abs(moments.data[0, ...] / result.shape[0])) peak = max(peak, this_peak) log.info("threshold_list: using moment 0, sub_image %d, peak = %f," % (i, this_peak)) else: ref_chan = result.data.shape[0] // 2 this_peak = numpy.max(numpy.abs(result.data[ref_chan])) peak = max(peak, this_peak) log.info("threshold_list: using refchan %d , sub_image %d, peak = %f," % (ref_chan, i, this_peak)) actual = max(peak * fractional_threshold, threshold) if use_moment0: log.info("threshold_list %s: Global peak in moment 0 = %.6f, sub-image clean threshold will be %.6f" % (prefix, peak, actual)) else: log.info("threshold_list %s: Global peak = %.6f, sub-image clean threshold will be %.6f" % (prefix, peak, actual)) return actual