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

ConnectionResetError: [WinError 10054] #289

Open
yun201720 opened this issue Dec 5, 2020 · 7 comments
Open

ConnectionResetError: [WinError 10054] #289

yun201720 opened this issue Dec 5, 2020 · 7 comments

Comments

@yun201720
Copy link

When I try to get bandpass using ''band = sncosmo.get_bandpass('sdssi')'', the server refused to give me any thing. This is also the problem when I try to get a model source with "model = sncosmo.Model(source='salt2')", I do not know why.

@rbiswas4
Copy link
Member

rbiswas4 commented Dec 5, 2020

Could you please specify :

  • version of sncosmo
  • version of python
  • What is the error message when the server 'refuses to give' you anything

For what it is worth, I find that on

import sncosmo
 sncosmo.__version__
Out[6]: '2.1.0'
band = sncosmo.get_bandpass('sdssi')
Downloading http://sncosmo.github.io/data/bandpasses/sdss/sdss_i.dat
|========================================================================| 1.2k/1.2k (100.00%)         0s

worked perfectly.

@yun201720
Copy link
Author

Hi,

here is the out-put information:

Python 3.8.3 (default, Jul 2 2020, 16:21:59)

sncosmo.version
'2.3.0'
band = sncosmo.get_bandpass('sdssi')

Traceback (most recent call last):
File "", line 1, in
File "/home/yun/anaconda3/lib/python3.8/site-packages/sncosmo/bandpasses.py", line 27, in get_bandpass
return _BANDPASSES.retrieve(name)
File "/home/yun/anaconda3/lib/python3.8/site-packages/sncosmo/_registry.py", line 160, in retrieve
self._instances[key] = func(*args, name=name)
File "/home/yun/anaconda3/lib/python3.8/site-packages/sncosmo/builtins.py", line 73, in load_bandpass_remote_aa
abspath = DATADIR.abspath(relpath)
File "/home/yun/anaconda3/lib/python3.8/site-packages/sncosmo/utils.py", line 464, in abspath
url = self._get_url(relpath)
File "/home/yun/anaconda3/lib/python3.8/site-packages/sncosmo/utils.py", line 434, in _get_url
self._fetch_redirects()
File "/home/yun/anaconda3/lib/python3.8/site-packages/sncosmo/utils.py", line 427, in _fetch_redirects
f = urlopen(self._remote_root + "redirects.json")
File "/home/yun/anaconda3/lib/python3.8/urllib/request.py", line 222, in urlopen
return opener.open(url, data, timeout)
File "/home/yun/anaconda3/lib/python3.8/urllib/request.py", line 525, in open
response = self._open(req, data)
File "/home/yun/anaconda3/lib/python3.8/urllib/request.py", line 542, in _open
result = self._call_chain(self.handle_open, protocol, protocol +
File "/home/yun/anaconda3/lib/python3.8/urllib/request.py", line 502, in _call_chain
result = func(*args)
File "/home/yun/anaconda3/lib/python3.8/urllib/request.py", line 1379, in http_open
return self.do_open(http.client.HTTPConnection, req)
File "/home/yun/anaconda3/lib/python3.8/urllib/request.py", line 1354, in do_open
r = h.getresponse()
File "/home/yun/anaconda3/lib/python3.8/http/client.py", line 1332, in getresponse
response.begin()
File "/home/yun/anaconda3/lib/python3.8/http/client.py", line 303, in begin
version, status, reason = self._read_status()
File "/home/yun/anaconda3/lib/python3.8/http/client.py", line 264, in _read_status
line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
File "/home/yun/anaconda3/lib/python3.8/socket.py", line 669, in readinto
return self._sock.recv_into(b)
ConnectionResetError: [Errno 104] Connection reset by peer

I am not sure if there is net restrictions. I am now at XInjiang China.

@rbiswas4
Copy link
Member

rbiswas4 commented Dec 6, 2020

I tried on sncosmo version 2.3 (pulling the latest development version master branch) and ran that on python 3.7. I am still able to run this. So, this might be related to net restrictions. Could you please check if you can download this file: The sdss bandpass file is :
https://github.com/sncosmo/sncosmo.github.io/blob/master/data/bandpasses/sdss/sdss_i.dat

The file looks like (first few lines):

6600   0.0002
6620   0.0007
6640   0.0011
6660   0.0016

If you cannot reach the file, then we would know it is a restriction problem. It is a bit surprising as you seem to be able connect to github.

@yun201720
Copy link
Author

Thanks for check, I have tried to download the above file, and I can reach this one. I have modified the ip-pointing to github, so I can connect github. I wonder if I can download all the bandpass files to sncosmo, but where do I put them?

@yun201720
Copy link
Author

By the way, I have light curves in AB magnitudes, how can I convert them to flux so that they can fit for sncosmo?
Thanks,

@rbiswas4
Copy link
Member

rbiswas4 commented Dec 8, 2020

Thanks for check, I have tried to download the above file, and I can reach this one. I have modified the ip-pointing to github, so I can connect github. I wonder if I can download all the bandpass files to sncosmo, but where do I put them?

It is a bit confusing then why the download did now work. You can download the bandpasses. The directory information is described in https://sncosmo.readthedocs.io/en/stable/configuration.html

in the sncosmo directory (for example in my case this is in ${HOME}/.astropy/cache/sncosmo)

The bandpass files are in locations like ${HOME}/.astropy/cache/sncosmo/bandpasses/sdss/sdss_i.dat

By the way, I have light curves in AB magnitudes, how can I convert them to flux so that they can fit for sncosmo?

You can convert the mags to flux as
flux = 10.0**(-0.4 * (mag -zp))
You can choose any zp that does not cause underflows or overflows, and you will need the zp column as well. The flux_errors are often calculated using the magerr:

flux_err = np.abs(flux*(-magerr/2.5*np.log(10)))```
This is not strictly correct, but strictly speaking magnitudes do not have a single error bar. So, probably the `flux_err` calculation should invert whatever was used to calculate the `magerr`



@benjaminrose
Copy link
Member

@yun201720 Is this issue happening on Windows?

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

3 participants