ornlneutronimaging / ImagingReso

Resonance Imaging
http://imagingreso.readthedocs.io
BSD 3-Clause "New" or "Revised" License
4 stars 3 forks source link

tutorial generates errors #8

Open ustajan opened 5 years ago

ustajan commented 5 years ago

Trying to use Method 1 from the tutorial from here. Looks like some server connection issue:

o_reso = Resonance(stack=_stack, energy_min=_energy_min, energy_max=_energy_max, energy_step=_energy_step)

First time using database 'ENDF_VII'? I will retrieve and store a local copy of database'ENDF_VII':

SSLError Traceback (most recent call last) /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/urllib/request.py in do_open(self, http_class, req, **http_conn_args) 1317 h.request(req.get_method(), req.selector, req.data, headers, -> 1318 encode_chunked=req.has_header('Transfer-encoding')) 1319 except OSError as err: # timeout error

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/http/client.py in request(self, method, url, body, headers, encode_chunked) 1238 """Send a complete request to the server.""" -> 1239 self._send_request(method, url, body, headers, encode_chunked) 1240

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/http/client.py in _send_request(self, method, url, body, headers, encode_chunked) 1284 body = _encode(body, 'body') -> 1285 self.endheaders(body, encode_chunked=encode_chunked) 1286

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/http/client.py in endheaders(self, message_body, encode_chunked) 1233 raise CannotSendHeader() -> 1234 self._send_output(message_body, encode_chunked=encode_chunked) 1235

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/http/client.py in _send_output(self, message_body, encode_chunked) 1025 del self._buffer[:] -> 1026 self.send(msg) 1027

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/http/client.py in send(self, data) 963 if self.auto_open: --> 964 self.connect() 965 else:

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/http/client.py in connect(self) 1399 self.sock = self._context.wrap_socket(self.sock, -> 1400 server_hostname=server_hostname) 1401 if not self._context.check_hostname and self._check_hostname:

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/ssl.py in wrap_socket(self, sock, server_side, do_handshake_on_connect, suppress_ragged_eofs, server_hostname, session) 400 server_hostname=server_hostname, --> 401 _context=self, _session=session) 402

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/ssl.py in init(self, sock, keyfile, certfile, server_side, cert_reqs, ssl_version, ca_certs, do_handshake_on_connect, family, type, proto, fileno, suppress_ragged_eofs, npn_protocols, ciphers, server_hostname, _context, _session) 807 raise ValueError("do_handshake_on_connect should not be specified for non-blocking sockets") --> 808 self.do_handshake() 809

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/ssl.py in do_handshake(self, block) 1060 self.settimeout(None) -> 1061 self._sslobj.do_handshake() 1062 finally:

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/ssl.py in do_handshake(self) 682 """Start the SSL/TLS handshake.""" --> 683 self._sslobj.do_handshake() 684 if self.context.check_hostname:

SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:747)

During handling of the above exception, another exception occurred:

URLError Traceback (most recent call last)

in ----> 1 o_reso = Resonance(stack=_stack, energy_min=_energy_min, energy_max=_energy_max, energy_step=_energy_step) /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/ImagingReso/resonance.py in __init__(self, stack, energy_max, energy_min, energy_step, database) 90 if not stack == {}: 91 # checking that every element of each stack is defined ---> 92 _utilities.checking_stack(stack=stack, database=self.database) 93 new_stack = self.__update_stack_with_isotopes_infos(stack=stack) 94 self.stack = new_stack /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/ImagingReso/_utilities.py in checking_stack(stack, database) 185 _elements = stack[_keys]['elements'] 186 for _element in _elements: --> 187 if not is_element_in_database(element=_element, database=database): 188 raise ValueError("Element {} can not be found in the database".format(_element)) 189 /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/ImagingReso/_utilities.py in is_element_in_database(element, database) 157 return False 158 --> 159 list_entry_from_database = get_list_element_from_database(database=database) 160 if element in list_entry_from_database: 161 return True /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/ImagingReso/_utilities.py in get_list_element_from_database(database) 94 print("First time using database '{}'? ".format(database)) 95 print("I will retrieve and store a local copy of database'{}': ".format(database)) ---> 96 download_from_github(fname=database + '.zip', path=_ref_data_folder) 97 98 # if '/_elements_list.csv' NOT exist /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/ImagingReso/_utilities.py in download_from_github(fname, path) 33 url = base_url + f 34 block_size = 16384 ---> 35 req = urlopen(url) 36 37 # Get file size from header /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/urllib/request.py in urlopen(url, data, timeout, cafile, capath, cadefault, context) 221 else: 222 opener = _opener --> 223 return opener.open(url, data, timeout) 224 225 def install_opener(opener): /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/urllib/request.py in open(self, fullurl, data, timeout) 524 req = meth(req) 525 --> 526 response = self._open(req, data) 527 528 # post-process response /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/urllib/request.py in _open(self, req, data) 542 protocol = req.type 543 result = self._call_chain(self.handle_open, protocol, protocol + --> 544 '_open', req) 545 if result: 546 return result /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/urllib/request.py in _call_chain(self, chain, kind, meth_name, *args) 502 for handler in handlers: 503 func = getattr(handler, meth_name) --> 504 result = func(*args) 505 if result is not None: 506 return result /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/urllib/request.py in https_open(self, req) 1359 def https_open(self, req): 1360 return self.do_open(http.client.HTTPSConnection, req, -> 1361 context=self._context, check_hostname=self._check_hostname) 1362 1363 https_request = AbstractHTTPHandler.do_request_ /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/urllib/request.py in do_open(self, http_class, req, **http_conn_args) 1318 encode_chunked=req.has_header('Transfer-encoding')) 1319 except OSError as err: # timeout error -> 1320 raise URLError(err) 1321 r = h.getresponse() 1322 except: URLError:
zhangy6x commented 3 years ago

@ustajan I just tried and failed to reproduce the error. It seems to be a connection issue. Due to the size of ENDF database, this package can not carry them with each release, this step is simply downloading the database from this git repo. You can download them at here (ENDF/B-VII, ENDF/B-VIII). And then move them to ./ImagingReso/reference_data/.