'Issue with SDSS.get spectra in AstroPy
I wrote the below code about 6 months ago, and it seemed to work fine. Now, however, I get the following::
~/astroconda/lib/python3.5/site-packages/astroquery/sdss/init.py:28: UserWarning: Experimental: SDSS has not yet been refactored to have its API match the rest of astroquery (but it's nearly there). warnings.warn("Experimental: SDSS has not yet been refactored to have its API "
~/astroconda/lib/python3.5/site-packages/astroquery/sdss/core.py:857: VisibleDeprecationWarning: Reading unicode strings without specifying the encoding argument is deprecated. Set the encoding, use None for the system default.
AttributeError Traceback (most recent call last)
~/spectra/plot_spectra.py in <module>()
34 xid = SDSS.query_region(pos, spectro=True,radius=2*u.arcsec)
35 print(xid)
---> 36 j_eleven = SDSS.get_spectra(matches=xid)
37
38
~/astroconda/lib/python3.5/site-packages/astroquery/sdss/core.py in get_spectra(self, coordinates, radius, matches, plate, fiberID, mjd, timeout, cache, data_release, show_progress)
613 mjd=mjd, timeout=timeout,
614 data_release=data_release,
--> 615 show_progress=show_progress)
616
617 if readable_objs is not None:
~/astroconda/lib/python3.5/site-packages/astroquery/sdss/core.py in get_spectra_async(self, coordinates, radius, matches, plate, fiberID, mjd, timeout, get_query_payload, data_release, cache, show_progress)
585 link = linkstr.format(
586 base=conf.sas_baseurl, dr=data_release,
--> 587 instrument=row['instrument'].decode().lower(),
588 run2d=run2d, plate=row['plate'],
589 fiber=row['fiberID'], mjd=row['mjd'])
AttributeError: 'str' object has no attribute 'decode'
error. Not sure what I did wrong/differently...
import numpy as np
import scipy.interpolate as interp
import matplotlib
import matplotlib.pyplot as plt
from astroML.plotting import setup_text_plots
from astroquery.sdss import SDSS
from astropy import coordinates as coords
import astropy.units as u
## Find a spectrum using astroquery
pos = coords.SkyCoord('165.24045d -0.88458d', frame='icrs')
xid = SDSS.query_region(pos, spectro=True,radius=2*u.arcsec)
print(xid)
j_eleven = SDSS.get_spectra(matches=xid)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
