orbital icon indicating copy to clipboard operation
orbital copied to clipboard

KeplerianElements.from_state_vector() RuntimeError

Open garbagetrash opened this issue 3 years ago • 0 comments

Initializing Eutelsat 117 West B from TLE provided in Celestrak for 7/11/2021 I get the error output shown below. I print out the r and v used in elements.py for the RuntimeError check just above the check (around line 149.) You can see that everything is passing except for the r.z value, which is off by just a bit more than 0.1 mm. I'm increasing the error limit to 1e-3 (1 mm) for my use as that level of error is acceptable for my application.

$ python bug_report.py 
Velocity(x=2543.4512779206098, y=1727.4460679597057, z=-0.002894147431130707) [ 2.54345128e+03  1.72744607e+03 -2.89414719e-03]
Position(x=23690484.727244586, y=-34881289.01751084, z=1241.3622029999844) [ 2.36904847e+07 -3.48812890e+07  1.24136210e+03]
Traceback (most recent call last):
  File "bug_report.py", line 8, in <module>
    elements = KeplerianElements.from_tle(tle1, tle2, earth)
  File "/home/<user>/.local/lib/python3.8/site-packages/orbital/elements.py", line 168, in from_tle
    return cls.from_state_vector(r, v, body=body, ref_epoch=ref_epoch)
  File "/home/<user>/.local/lib/python3.8/site-packages/orbital/elements.py", line 150, in from_state_vector
    raise RuntimeError(
RuntimeError: Failed to set orbital elements for velocity. Please file a bug report at https://github.com/RazerM/orbital/issues
$
$
$ cat bug_report.py 
from orbital.elements import KeplerianElements
from orbital.bodies import earth

tle = "EUTELSAT 117 WEST B"
tle1 = "1 41589U 16038B   21192.36582182 -.00000005  00000-0  00000-0 0  9991"
tle2 = "2 41589   0.0115 155.4241 0000363 329.5012 179.2540  1.00272119 18608"

elements = KeplerianElements.from_tle(tle1, tle2, earth)

print(elements)
# elements.py, around line 149
        # Now check that the computed properties for position and velocity are
        # reasonably close to the inputs.
        # 1e-4 is a large uncertainty, but we don't want to throw an error
        # within small differences (e.g. 1e-4 m is 0.1 mm)
        print(self.v, v)
        print(self.r, r)
        if (abs(self.v - v) > 1e-4).any() or (abs(self.r - r) > 1e-4).any():
            raise RuntimeError(
                'Failed to set orbital elements for velocity. Please file a bug'
                ' report at https://github.com/RazerM/orbital/issues')

        return self

garbagetrash avatar Jul 11 '21 19:07 garbagetrash