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

Slicing or indexing Geocentric position+velocity array corrupts the velocity #241

Closed
dmopalmer opened this issue Feb 22, 2019 · 0 comments
Closed
Assignees

Comments

@dmopalmer
Copy link
Contributor

dmopalmer commented Feb 22, 2019

If you have an array of Geocentric position and velocity (e.g. from a satellite.at(timearray)), taking a slice or element out of it loses some of the type context and also converts the velocities to nan.

import skyfield.api
import os
import numpy as np

loader = skyfield.api.Loader(os.path.expanduser("~/.config/skyfield"))
ts = loader.timescale()

stations_url = 'http://celestrak.com/NORAD/elements/stations.txt'
satellites = loader.tle(stations_url)
satellite = satellites['ISS (ZARYA)']
# print(satellite)

now = ts.now()
nowandthen = ts.tai_jd(now.tai + np.arange(2)/86400)

atbyseconds = satellite.at(nowandthen)


print("Unsliced, sliced, and indexed:\n")
for posandvel in (atbyseconds, atbyseconds[:], atbyseconds[0]):
    print(type(posandvel), posandvel)
    print("Position")
    print(posandvel.position.km)
    print("Velocity")
    print(posandvel.velocity.km_per_s)
    print("-------------------------------------------")

Result:

Unsliced, sliced, and indexed:
<class 'skyfield.positionlib.Geocentric'> <Geocentric position and velocity at date t center=399 target=<object object at 0x10fe16ef0>>
Position
[[6161.12839736 6159.77530714]
 [2749.56861045 2754.20941124]
 [ 735.51733732  729.5672061 ]]
Velocity
[[-1.34916969 -1.3570354 ]
 [ 4.64268485  4.63917042]
 [-5.95007741 -5.95101607]]
-------------------------------------------
<class 'skyfield.positionlib.Geocentric'> <Geocentric position and velocity at date t>
Position
[[6161.12839736 6159.77530714]
 [2749.56861045 2754.20941124]
 [ 735.51733732  729.5672061 ]]
Velocity
[[nan nan]
 [nan nan]
 [nan nan]]
-------------------------------------------
<class 'skyfield.positionlib.Geocentric'> <Geocentric position and velocity at date t>
Position
[6161.12839736 2749.56861045  735.51733732]
Velocity
[nan nan nan]
-------------------------------------------
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants