Skip to content

Commit

Permalink
Merge pull request #66 from dr-rodriguez/master
Browse files Browse the repository at this point in the history
Bug fix: accessing spectra
  • Loading branch information
dr-rodriguez committed Aug 18, 2016
2 parents 3e5512f + 1f0dd2d commit 76ade5d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
4 changes: 1 addition & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ python:
- 3.5

before_script:
- "export DISPLAY=:99.0"
- "export DISPLAY=:99.0" # xvfb is used to ensure matplotlib plots don't fail
- "sh -e /etc/init.d/xvfb start"
- sleep 3 # give xvfb some time to start

Expand All @@ -31,8 +31,6 @@ env:
matrix:
allow_failures:
- python: 3.3
# - python: 3.4
# - python: 3.5

install:
- git clone git://github.com/astropy/ci-helpers.git
Expand Down
11 changes: 6 additions & 5 deletions astrodbkit/astrodb.py
Original file line number Diff line number Diff line change
Expand Up @@ -1524,27 +1524,28 @@ def convert_spectrum(File):
# If no wl axis generated, then clear out all retrieved data for object
if not isinstance(spectrum[0],np.ndarray):
spectrum = None

except IOError:
# Check if the FITS file is just Numpy arrays
try:
spectrum, header = pf.getdata(File, cache=True, header=True)
except:
print('Could not read FITS file at {}'.format(File))
pass

# For .txt files
if File.endswith('.txt'):
# For non-FITS files, assume ascii
else:
try:
spectrum = ii.read(File)
spectrum = np.array([np.asarray(spectrum.columns[n]) for n in range(len(spectrum.columns))])
try:
txt, header = open(File), []
for i in txt:
if any([i.startswith(char) for char in ['#', '|', '\\']]): header.append(i.replace('\n', ''))
if any([i.startswith(char) for char in ['#', '|', '\\']]):
header.append(i.replace('\n', ''))
txt.close()
except:
pass
except:
print('Could not read file at {}'.format(File))
pass

if spectrum == '':
Expand Down

0 comments on commit 76ade5d

Please sign in to comment.