Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Math domain error when computing elevation in certain corner cases #15

Open
astrojuanlu opened this issue Sep 6, 2018 · 1 comment
Open
Labels

Comments

@astrojuanlu
Copy link
Contributor

We encountered a case of a target that was precisely under the orbit of the satellite and because of rounding errors the argument of the arc sine was greater than 1:

ValueError: math domain error
[...]
  File "orbit_predictor/accuratepredictor.py", line 180, in __iter__
    pass_ = self._refine_pass(ascending_date, descending_date)
  File "orbit_predictor/accuratepredictor.py", line 234, in _refine_pass
    tca = self._find_tca(ascending_date, descending_date)
  File "orbit_predictor/accuratepredictor.py", line 248, in _find_tca
    if self.is_ascending(midpoint):
  File "orbit_predictor/accuratepredictor.py", line 274, in is_ascending
    next_elevation = self._elevation_at(when_utc + ONE_SECOND)
  File "orbit_predictor/accuratepredictor.py", line 265, in _elevation_at
    return self.location.elevation_for(position)
  File "orbit_predictor/locations.py", line 78, in elevation_for
    return asin(top_z / range_sat)

with top_z = 509.4044680189018 and range_sat = 509.40446801890175. There should be something in the code that prevents this, like

    return asin(min(top_z / range_sat, 1.0))
@astrojuanlu
Copy link
Contributor Author

Happening again.

    109         range_sat = sqrt((rx * rx) + (ry * ry) + (rz * rz))
    110 
--> 111         return asin(top_z / range_sat)
    112 
    113     def get_azimuth_elev(self, position):

ipdb> p top_z
489.56483852668225
ipdb> p range_sat
489.5648385266822
ipdb> p top_z / range_sat
1.0000000000000002

@astrojuanlu astrojuanlu pinned this issue Jan 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant