convolve_fft: convert to delta function if risk of loosing peak information
@@ -162,6 +162,22 @@ class NodeInterpolator (Distribution):
def convolve_fft(cls, node_interp, branch_interp, fft_grid_size=FFT_FWHM_GRID_SIZE, inverse_time=True):
dt = max(branch_interp.one_mutation*0.005, min(node_interp.fwhm, branch_interp.fwhm)/fft_grid_size)
+ ratio = node_interp.fwhm/branch_interp.fwhm
+ if ratio < 1/100 and dt > 4*node_interp.fwhm/fft_grid_size:
+ print("convolve_fft: entering delta function mode")
+ ## node distribution is much narrower than the branch distribution, proceed as if node distribution is
+ ## a delta distribution
+ bl = branch_interp.x
+ x = bl + node_interp._peak_pos
+ return Distribution(x, branch_interp(bl), min_width=min(node_interp.min_width, branch_interp.min_width), is_log=True)
+ elif ratio >100 and dt > 4*branch_interp.fwhm/fft_grid_size:
+ ## branch distribution is much narrower than the node distribution, proceed as if branch distribution is
+ ## a delta distribution
+ print("convolve_fft: entering delta function mode")
+ bl = node_interp.x
+ x = bl + branch_interp._peak_pos
+ return Distribution(x, node_interp(bl), min_width=min(node_interp.min_width, branch_interp.min_width), is_log=True)
+ else:
b_effsupport = branch_interp.effective_support
n_effsupport = node_interp.effective_support
