Closed swarnajyoti closed 4 years ago
What version of Skyfield are you using? I recommend updating to the most recent version 1.14:
Hi,
probably I could help: I had this point as well. The point is that iokit.py raises this OS error if urllib fails. This exception has to be captured in the application calling. For some reason the server for downloading the time delta file was available, but cut the connection. With changing to 1.14 there might be this error gone away (because using a different one) but the core topic remains.
It could be done like this (at least I did it this way) :
def loadTimescale(self):
"""
loadTimescale tries to get timescale with the appropriate parameters. if something
is happening on the way, it uses the built-in files of skyfield package instead.
:return:
"""
try:
self.ts = self.loader.timescale()
except Exception as e:
self.ts = self.loader.timescale(builtin=True)
self.logger.info(f'Used built-in as degradation because of : {e}')
Michel
Thanks for your feedback. I have used the most recent version of skyfield but again the same problem. @brandon-rhodes . But @mworion I have tried your technique but I am getting this,
My code:
self = Loader('~/Python/SkyData')
de421 = load('de421.bsp')
def loadTimescale(self):
"""
loadTimescale tries to get timescale with the appropriate parameters. if something
is happening on the way, it uses the built-in files of skyfield package instead.
:return:
"""
try:
self.ts = self.loader.timescale()
except Exception as e:
self.ts = self.loader.timescale(builtin=True)
self.logger.info(f'Used built-in as degradation because of : {e}')
loadTimescale()
minutes = np.arange(24*60 + 1)
seconds = 60.*minutes
times = loadTimescale.utc(2019, 9, 20, 10, minutes)
And I am getting this error:
AttributeError Traceback (most recent call last)
@swarnajyoti It looks like you might have changed the indentation when you pasted in @mworion’s code, changing its meaning; but hopefully he will help you get that unraveled. To address your first question: it is possible that policy issues might make communication difficult between your computer and NASA, depending on where your computer is connected in the world. Let’s for a moment take Skyfield out entirely: try directing your browser at
ftp://cddis.nasa.gov/products/iers/
and see if a directory of files comes up. If not, then forces beyond Skyfield’s control are preventing you from fetching the data files, and buildin=True
is the easiest way for you to stay unblocked and keep your program running correctly.
I have improved the exception Skyfield prints to include both the advice to check out the URL in the browser, and also to try using the builtin files. Hopefully the next user to run into this will not be stopped in their tracks without a solution!
In the meantime, if you learn more about your particular case and have further questions, feel free to post them here as further comments!
Hi,
I can not run load.timescale(), although here, previously I saw some guys had the same problem but as I saw after installing skyfield 1.11, it supposed to be fine but the same problem again.
Any lead would be much appreciated. Thanks.
The complete error status is given below:
RemoteDisconnected Traceback (most recent call last) C:\ProgramData\Anaconda3\lib\site-packages\skyfield\iokit.py in download(url, path, verbose, blocksize) 502 try: --> 503 connection = urlopen(url) 504 except Exception as e:
C:\ProgramData\Anaconda3\lib\urllib\request.py in urlopen(url, data, timeout, cafile, capath, cadefault, context) 221 opener = _opener --> 222 return opener.open(url, data, timeout) 223
C:\ProgramData\Anaconda3\lib\urllib\request.py in open(self, fullurl, data, timeout) 524 --> 525 response = self._open(req, data) 526
C:\ProgramData\Anaconda3\lib\urllib\request.py in _open(self, req, data) 542 result = self._call_chain(self.handle_open, protocol, protocol + --> 543 '_open', req) 544 if result:
C:\ProgramData\Anaconda3\lib\urllib\request.py in _call_chain(self, chain, kind, meth_name, args) 502 func = getattr(handler, meth_name) --> 503 result = func(args) 504 if result is not None:
C:\ProgramData\Anaconda3\lib\urllib\request.py in http_open(self, req) 1344 def http_open(self, req): -> 1345 return self.do_open(http.client.HTTPConnection, req) 1346
C:\ProgramData\Anaconda3\lib\urllib\request.py in do_open(self, http_class, req, **http_conn_args) 1319 raise URLError(err) -> 1320 r = h.getresponse() 1321 except:
C:\ProgramData\Anaconda3\lib\http\client.py in getresponse(self) 1320 try: -> 1321 response.begin() 1322 except ConnectionError:
C:\ProgramData\Anaconda3\lib\http\client.py in begin(self) 295 while True: --> 296 version, status, reason = self._read_status() 297 if status != CONTINUE:
C:\ProgramData\Anaconda3\lib\http\client.py in _read_status(self) 264 # sending a valid response. --> 265 raise RemoteDisconnected("Remote end closed connection without" 266 " response")
RemoteDisconnected: Remote end closed connection without response
During handling of the above exception, another exception occurred:
OSError Traceback (most recent call last)