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

NotImplementedError: Deep space calculations not supported - Just from running TLE file #71

Open
clmuddjr opened this issue Jan 12, 2021 · 4 comments

Comments

@clmuddjr
Copy link

clmuddjr commented Jan 12, 2021

Dear people:

I want to run through a TLE file and calculate the coordinates of each satellite for a period of time (right now, datetime will only allow 60 seconds, but would like to run it longer).

At first, using Orbital from PyOrbital, I obtained an error that certain satellites could not be found in the TLE file I specified. Then, I realized that Orbital may have been pulling from the Internet (Celestrak) given I had not identified a tle_file. Then, after modifying Orbital, I obtained an error that "Deep space calculations not supported."

This is the code:

`# Some of the packages may not be needed for this portion of code`
`# satfile name is a text file my other code created after filtering through Celestrak 
`# TLE files; the file works with other routines so is not the issue`

from astropy.coordinates import SkyCoord
from astropy import units as u
import astropy.units as u
from astropy.time import Time
from astropy.coordinates import SkyCoord, EarthLocation, AltAz

with open(satfilename) as r:
    filter_sat_coords = []
for line1,line2,line3 in itertools.zip_longest(*[r]*3):

    t = ts.utc(timestring)

    orb2=Orbital(line1, tle_file=satfilename)

    sat_sec_list = []

    for sec in range (0,59):

        date_use = datetime(2020, 11, 2, 5, 18, sec)

        lon_c, lat_c, alt_c =orb2.get_lonlatalt(date_use)

        xx_sec=lon_c
        yy_sec=lat_c
        zz_sec=alt_c

        sat_sec_list_add = (xx_sec, yy_sec, satname, zz_sec)
        sat_sec_list.append(sat_sec_list_add)

    filter_sat_coords.append(sat_sec_list)

f.close()

Problem description

As mentioned above, I get an error for Deep space calculations not supported just from running the TLE file. And, unless I am missing something, I do not see how it happens to be a deep space calculation where I am just trying to calculate each satellites individual coordinates over 60 seconds.

Expected Output

It should just complete the calculations and provide me with two lists: filter_sat_coords and sat_sec_list. When I run it using a single user-selected satellite known to be in the tle file (HST), it works. This code works:

`from pyorbital.orbital import Orbital
from datetime import datetime
# Use current TLEs from the internet:
#orb = Orbital("HST")
orb1 = Orbital(sat1, tle_file=satfilename)
orb2 = Orbital('STARLINK-1011', tle_file=satfilename)
now = datetime.utcnow()
date_use = datetime(2020, 11, 2, 5, 18, 00)
# Get normalized position and velocity of the satellite:
aaa=orb.get_position(now)

# Get longitude, latitude and altitude of the satellite:
# b=orb.get_lonlatalt(now)
b=orb.get_lonlatalt(date_use)
lon_1, lat_1, alt_1 =orb.get_lonlatalt(date_use)
lon_2, lat_2, alt_2 =orb2.get_lonlatalt(date_use)

print (aaa)
print (b)
#print (c)
print (lon_1, lat_1, alt_1)
print (lon_2, lat_2, alt_2)

print("The TLE file is: ", satfilename)
#print (newtablename)

With the result:

Screen Shot 2021-01-12 at 9 30 50 AM

As does:

from astropy.coordinates import SkyCoord
from astropy import units as u
import astropy.units as u
from astropy.time import Time
from astropy.coordinates import SkyCoord, EarthLocation, AltAz

with open(satfilename) as r:
    orb=Orbital(sat1, tle_file=satfilename)
    sat1_sat_sec_list = []
    for sec in range (0,59):

        date_use = datetime(2020, 11, 2, 5, 18, sec)

        lon_c, lat_c, alt_c =orb.get_lonlatalt(date_use)

        xx_sec=lon_c
        yy_sec=lat_c
        zz_sec=alt_c

        sat1_sat_sec_list_add = (xx_sec, yy_sec, zz_sec)
        sat1_sat_sec_list.append(sat1_sat_sec_list_add)

f.close()
len_sec = len(sat1_sat_sec_list)

sat1_lon = []
sat1_lat = []
sat1_alt = []

for i in range (0, len_sec-1):
    sat1_0 = sat1_sat_sec_list[i][0]
    sat1_1 = sat1_sat_sec_list[i][1]
    sat1_2 = sat1_sat_sec_list[i][2]

    sat1_lon_add = (sat1_0)
    sat1_lat_add = (sat1_1)
    sat1_alt_add = (sat1_2)

    sat1_lon.append(sat1_lon_add)
    sat1_lat.append(sat1_lat_add)
    sat1_alt.append(sat1_alt_add)

low_sat1_0 = min(sat1_lon)
low_sat1_1 = min(sat1_lat)
low_sat1_2 = min(sat1_alt)

high_sat1_0 = max(sat1_lon)
high_sat1_1 = max(sat1_lat)
high_sat1_2 = max(sat1_alt)

print(low_sat1_0, high_sat1_0)
print(low_sat1_1, high_sat1_1)
print(low_sat1_2, high_sat1_2)

With the result:

Screen Shot 2021-01-12 at 9 33 02 AM

Actual Result, Traceback if applicable

However, when I run the code at the top using "line1" for the satname from the TLE file, it gives me the error.

Screen Shot 2021-01-12 at 1 29 46 AM

Could it be something with this line of code and trying to do the iteration:

for line1,line2,line3 in itertools.zip_longest(*[r]*3):

and then using line1 for the satellite name?

For, when I change "line1" to "sat1" again the code, specifically:

orb2=Orbital(sat1, tle_file=satfilename)

it works.

Could it be the number of satellites or calculations?

Versions of Python, package at hand and relevant dependencies

3.8.6 | packaged by conda-forge | (default, Dec 22 2020, 10:15:24)
[Clang 11.0.0 ]

Thank you for reporting an issue !

@clmuddjr
Copy link
Author

After running some testing, it happens to be some aspect of specific satellites in the science celestral tle file.

I began an 'x' count had the routine stop at 5 and it worked. I did the same for additional levels and eventually obtained an error at 829.

I then had the routine skip 829 which it did. But, it stopped at 831. After a few more satellites, I wanted to see what line caused the issue and determined that it broke at the following line:

orb2=Orbital(abra, tle_file=satfilename)

The satellites that do not work so far are:

POLAR
1 23802U 96013A 20295.99938125 .00000118 00000-0 00000-0 0 9998
2 23802 78.7088 248.2197 6205894 279.1057 19.6545 1.29846457118054

XMM-NEWTON
1 25989U 99066A 20297.18987583 -.00000114 00000-0 00000-0 0 9999
2 25989 71.0622 317.6914 6934313 92.2856 359.7978 0.50131985 27026

CLUSTER II-FM7 (SAMBA)
1 26410U 00041A 20298.26891925 .00000128 00000-0 00000-0 0 9992
2 26410 132.1394 342.6239 4553022 186.5114 0.7721 0.44217239 11151

CLUSTER II-FM6 (SALSA)
1 26411U 00041B 20298.35099240 .00000002 00000-0 00000-0 0 9994
2 26411 132.3246 344.0376 5911886 192.0067 0.8331 0.44249497 11197

I noticed a pattern in field 11 for Drag Term:

Screen Shot 2021-01-14 at 12 03 47 AM

in that they all were 00000-0:

@clmuddjr
Copy link
Author

So, I wrote this code rather than adding each specific satellite and it completed without issue:

        line2_str = str(line2)
        dragterm = line2_str[54:59]
        if dragterm == "00000":
            print (line1, dragterm)
            continue

@mraspaud
Copy link
Member

@clmuddjr thanks for reporting this issue!

I think the Deep space error comes when trying to use TLEs for computing geostationary or deep space orbits, with pyorbital doesn't support yet.

For polar satellites, you shouldn't get this problem. What are the orbits of the satellites you are working on?

@mraspaud
Copy link
Member

mraspaud commented Mar 2, 2021

If someone wants to dive into a PR for deep space computations: deep space initialisation (https://github.com/pytroll/pyorbital/blob/master/pyorbital/orbital.py#L779-L780) should follow page 85 of https://celestrak.com/publications/AIAA/2006-6753/AIAA-2006-6753-Rev3.pdf
and propagation (https://github.com/pytroll/pyorbital/blob/master/pyorbital/orbital.py#L779-L780) should implement the beginning of page 88 (and the functions called therein)
Other places marked with if (satrec.method == 'd') need to be implemented too.

Some of the deep space test cases are already included in test_aiaa.py, but just skipped for now: https://github.com/pytroll/pyorbital/blob/master/pyorbital/tests/test_aiaa.py#L128-L130

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

No branches or pull requests

2 participants