From bbcd8d989de4b58488ea1643e2f9044afc0fdd51 Mon Sep 17 00:00:00 2001 From: Joep Vanlier Date: Tue, 20 Aug 2024 17:51:42 +0200 Subject: [PATCH] calibration: don't allow zero diffusion constant --- .../pylake/force_calibration/power_spectrum_calibration.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lumicks/pylake/force_calibration/power_spectrum_calibration.py b/lumicks/pylake/force_calibration/power_spectrum_calibration.py index 9ef823451..5ab528af8 100644 --- a/lumicks/pylake/force_calibration/power_spectrum_calibration.py +++ b/lumicks/pylake/force_calibration/power_spectrum_calibration.py @@ -404,7 +404,11 @@ def fit_power_spectrum( power_spectrum.power, power_spectrum.num_points_per_block, initial_params=np.array([anl_fit_res.fc, anl_fit_res.D, *model._filter.initial_values]), - lower_bounds=np.array([0.0, 0.0, *model._filter.lower_bounds()]), + # The lower bound on the diffusion constant is needed to ensure that the robust + # fitter does not encounter a singularity when the diffusion constant goes to zero. + # Sometimes this can momentarily occur during the fitting procedure (during numerical + # differentiation). + lower_bounds=np.array([0.0, 1e-100, *model._filter.lower_bounds()]), upper_bounds=np.array( [np.inf, np.inf, *model._filter.upper_bounds(power_spectrum.sample_rate)] ),