Skip to content

Commit

Permalink
Polar Delta error
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
igresh committed Aug 13, 2024
1 parent 406695f commit db71f40
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions refellips/objectiveSE.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
"""
Expand Down

0 comments on commit db71f40

Please sign in to comment.