From db71f40a0e045a4efa412f408b8ac1899420368b Mon Sep 17 00:00:00 2001 From: Isaac Gresham Date: Tue, 13 Aug 2024 22:30:57 +1000 Subject: [PATCH] Polar Delta error MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Delta is in polar coordinates (0-360˚), this needs to be taken into account when calculating error. This problem is most obvious when data is 359˚ and model is 1˚ (for example). Old implementation calculates residual as 358, whereas the correct residual is 2. The change calculates error as: 2*arcsin(sin(Delta_data/2)-sin(Delta_model/2)) The factor of 2 ensures a functional relationship between error and Delta. The maximum possible residual (unweighted) is 180, which is of the same magnitude as before the change. --- refellips/objectiveSE.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/refellips/objectiveSE.py b/refellips/objectiveSE.py index d4a3f23..0e3f6f2 100644 --- a/refellips/objectiveSE.py +++ b/refellips/objectiveSE.py @@ -178,9 +178,9 @@ def residuals(self, pvals=None): wavelength, aoi, psi_d, delta_d = self.data.data wavelength_aoi = np.c_[wavelength, aoi] - psi, delta = self.model(wavelength_aoi) - return np.r_[psi - psi_d, delta - delta_d] + delta_err = 2*np.rad2deg(np.arcsin(np.sin(np.deg2rad(delta/2)) - np.sin(np.deg2rad(delta_d/2)))) + return np.r_[psi - psi_d, delta_err] def chisqr(self, pvals=None): """