Open dioginn opened 2 years ago
Yep, same problem here. Am having this problem for a couple of days -- i figured it might be related to Celestrak, but it now seems get_tle() is unable to read the TLEs on Celestak for some reason. Error message below:
CelestrakError Traceback (most recent call last) Input In [6], in <cell line: 15>() 12 date_end = date_start + datetime.timedelta(days=10) 13 source = CelestrakTLESource() ---> 15 tle = source.get_tle(25544) # International space station, Norad ID 25544 16 #satellite = SGP4Propagator.from_tle(tle) 17 observer = Observer(location, satellite)
File ~/.local/lib/python3.8/site-packages/passpredict/sources.py:92, in CelestrakTLESource.get_tle(self, satid) 90 tle = TLE(res['satid'], res['lines'], name=res.get('name', '')) 91 else: ---> 92 tle = self._query_tle_from_celestrak(satid) 93 self.cache.set(key, tle.dict(), ttl=86400) 94 return tle
File ~/.local/lib/python3.8/site-packages/passpredict/sources.py:128, in CelestrakTLESource._query_tle_from_celestrak(self, satid) 126 r = httpx.get(url, params=params) 127 if r.text.lower() in ("no tle found", "no gp data found") or r.status_code >= 300: --> 128 raise CelestrakError(f'Celestrak TLE for satellite {satid} not found') 129 tle_strings = r.text.splitlines() 130 tle = parse_tle(tle_strings)
CelestrakError: Celestrak TLE for satellite 25544 not found
Thanks!
The problem is actually related to httpx and the use of params when invoking httpx.get.
In the sources.py file from the predictpass library folder, there is the "_query_tle_from_celestrak" function which access the celestrrak website to generate the TLE. This is how the function does it:
url = 'https://celestrak.com/NORAD/elements/gp.php'
params = {
'CATNR': satid,
'FORMAT': 'TLE',
}
r = httpx.get(url, params=params)
I came up with a workaround, you can comment out the bit above and do the following instead:
url = "https://celestrak.org/NORAD/elements/gp.php?CATNR="+str(satid)+"&FORMAT=TLE" r = httpx.get(url)
This tells me the way you invoke parameters in httpx.get has changed in a recent update.
Aah, i looked at that part of the code and tried something similar, but did not add the "FORMAT=TLE" at the end -- so did not work. Thanks!!
Hello,
I have used the passpredict package on a daily basis without any problems since March the 22nd and the code that worked since then suddenly stopped working on the 29th of July. It is something to do with the tle = source.get_tle command:
Traceback (most recent call last): File "C:\Users\EM27\Desktop\PROFFASTv2.0.1\le_tropomi.py", line 430, in
tle = source.get_tle(42969) # Sentinel 5P, Norad ID 42969
File "C:\Users\EM27\AppData\Local\Programs\Python\Python310\lib\site-packages\passpredict\sources.py", line 92, in get_tle
tle = self._query_tle_from_celestrak(satid)
File "C:\Users\EM27\AppData\Local\Programs\Python\Python310\lib\site-packages\passpredict\sources.py", line 128, in _query_tle_from_celestrak
raise CelestrakError(f'Celestrak TLE for satellite {satid} not found')
passpredict.exceptions.CelestrakError: Celestrak TLE for satellite 42969 not found
I can change the NORAD ID for 25544, and it also does not work. I have updated predictpass to 0.5.1 but it does not solve the problem. Any thoughts on this?