Skip to content
This repository has been archived by the owner on Oct 14, 2023. It is now read-only.

Unrelated errors in latitude detection (sometimes) #1290

Closed
Yash-10 opened this issue Jul 23, 2021 · 3 comments
Closed

Unrelated errors in latitude detection (sometimes) #1290

Yash-10 opened this issue Jul 23, 2021 · 3 comments

Comments

@Yash-10
Copy link
Member

Yash-10 commented Jul 23, 2021

Since the latitude detector uses the cartesian_to_ellipsoidal method directly and also because cartesian_to_ellipsoidal calculates the longitude and height at the same time, sometimes the latitude detector returns a zero division error in this line:

h = z / np.sin(lat) - (1 - e2) * v

Since this is not an error due to latitude calculation but an error in a different calculation (here, h the height), it might be confusing and/or unnecessary to raise this error when using the latitude event.

Reproducible example

tofs = [10, 1000, 3000, 4000] << u.s
orbit = Orbit.circular(Earth, 150 * u.km)

thresh_lat = 60 * u.deg
latitude_cross_event = LatitudeCrossEvent(orbit, thresh_lat, terminal=False)
events = [latitude_cross_event]

rr, _ = cowell(
    Earth.k,
    orbit.r,
    orbit.v,
    tofs,
    events=events,
    f=f,
)

Possible ideas

  • Make three separate methods, each for lat, lon, and h to prevent unrelated error pop-up
  • Also, if spheroid locations can be converted into a "class", it could be easy to access the lat, on, and h attributes.
@astrojuanlu
Copy link
Member

If np.sin(lat) == 0, it means that lat == 0. But therefore, z == 0, and so z / np.sin(lat) should have some sultion? I vote for trying to handle this case in a numerically correct way

@Yash-10
Copy link
Member Author

Yash-10 commented Aug 7, 2021

@astrojuanlu Do you think this issue was solved by #1292?

@astrojuanlu
Copy link
Member

Indeed!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants