Skip to content

Commit

Permalink
Fixes for SDSS spectra README and old version of astropy
Browse files Browse the repository at this point in the history
  • Loading branch information
CodyRude committed Sep 14, 2018
1 parent acbbcce commit 5cf1249
Show file tree
Hide file tree
Showing 5 changed files with 210 additions and 4 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ Supported data sets:
<td width=200>
<sup>
<img src=https://github.com/MITHaystack/scikit-dataaccess/raw/master/skdaccess/docs/images/icon_astro.png>
astro.kepler
astro.spectra
</sup>
</td>

Expand Down
4 changes: 3 additions & 1 deletion skdaccess/astro/spectra/stream.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@

# Standard library imports
from collections import OrderedDict
from io import BytesIO

# 3rd part imports
from six.moves.urllib.request import urlopen
Expand Down Expand Up @@ -61,7 +62,8 @@ def output(self):

for url in url_list:
with urlopen(url) as url_data:
hdu_list = fits.open(url_data)
bytes_data = BytesIO(url_data.read())
hdu_list = fits.open(bytes_data)
data_dict[url] = Table(hdu_list[1].data).to_pandas()
meta_dict[url] = hdu_list[0].header

Expand Down
Binary file added skdaccess/docs/images/icon_skdaccess.spectra.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
203 changes: 203 additions & 0 deletions skdaccess/examples/Demo_SDSS_Spectra.ipynb

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions skdaccess/framework/data_class.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,14 +276,15 @@ def retrieveOnlineData(self, data_specification):
if content_type == 'application/fits':

# Do not want caching to avoid issues when running multiple pipelines
with warnings.catch_warnings(), fits.open(url_access, cache=False) as hdu_list:
bytes_data = BytesIO(url_access.read())
with warnings.catch_warnings(), fits.open(bytes_data, cache=False) as hdu_list:
warnings.simplefilter("ignore", fits.verify.VerifyWarning)

# Need to fix header otherwise astropy can fail to read data
hdu_list.verify('fix')

data_dict[url] = hdu_list[1].data
metadata_dict[url] = hdu_list[0].header
metadata_dict[url] = hdu_list[1].header

# Access jpg file
elif content_type == 'image/jpeg':
Expand Down

0 comments on commit 5cf1249

Please sign in to comment.