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

[Bug]: Discontinuity in ecef2geodetic() outputs #78

Closed
ghost opened this issue Feb 2, 2023 · 2 comments
Closed

[Bug]: Discontinuity in ecef2geodetic() outputs #78

ghost opened this issue Feb 2, 2023 · 2 comments
Assignees
Labels

Comments

@ghost
Copy link

ghost commented Feb 2, 2023

What happened?

If I use the ecef2geodetic function with x >= 521860, y = 0, and z = 0, I get correct outputs of lat = 0, lon =0, and the appropriate alt.

However, if I use x <= 521850, y = 0, z = 0, I get a lat of 90 (incorrect), lon of 0, and an incorrect altitude.

The difference seems to occur in the calculation of u on line 136 in ecef.py, which is:

u = sqrt(0.5 * (r**2 - E**2) + 0.5 * sqrt((r**2 - E**2) ** 2 + 4 * E**2 * z**2))

If r < E, then u = 0.

This can be reproduced by running the following:

import pymap3d

from numpy import linspace

Xs = linspace(521000, 522000, 101)

for x in Xs:

    lat, lon, alt = pymap3d.ecef2geodetic(x, 0, 0)
    
    print(x)
    print(lat, lon, alt)
    print(" ")

You will see that the discontinuity occurs from x=521850 and x=521860
I don't think this should happen, but I'm not sure what the problem is. The equations seem to match the referenced paper.

Any ideas? Thanks!

Relevant log output

No response

@ghost ghost added the bug label Feb 2, 2023
@ghost
Copy link
Author

ghost commented Feb 2, 2023

Almost forgot (not sure if it matters or not):

In the calculation of Beta, if there is a divide by zero, I get "RuntimeWarning: divide by zero encountered in double_scalars" not a "ZeroDivisionError" and therefore it is not caught by the except statement on line 145.

To fix, I did

import warnings
warnings.filterwarnings('error')

and then changed the except statement to

except (ZeroDivisionError, RuntimeWarning):

@scivision scivision self-assigned this Feb 3, 2023
scivision added a commit that referenced this issue Feb 26, 2023
@scivision
Copy link
Member

Thank you!

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