From 7317b5776a11f4499ee5ba954c1b7692f30057c2 Mon Sep 17 00:00:00 2001 From: "Sergey E. Koposov" Date: Wed, 27 Nov 2024 18:37:04 +0000 Subject: [PATCH] avoid overflow messages by clipping before exponentiation --- py/rvspecfit/vel_fit.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/py/rvspecfit/vel_fit.py b/py/rvspecfit/vel_fit.py index e1e8c67..842f430 100644 --- a/py/rvspecfit/vel_fit.py +++ b/py/rvspecfit/vel_fit.py @@ -94,6 +94,8 @@ def firstguess(specdata, class VSiniMapper: def __init__(self, min_vsini, max_vsini): + self.log_min_vsini = np.log(min_vsini) + self.log_max_vsini = np.log(max_vsini) self.min_vsini = min_vsini self.max_vsini = max_vsini @@ -106,7 +108,7 @@ def inverse(self, x): """ Undo the transformation. Return proper vsini """ - return np.clip(np.exp(x), self.min_vsini, self.max_vsini) + return np.exp(np.clip(x, self.log_min_vsini, self.log_max_vsini)) class ParamMapper: