astropy / astropy/astroquery

KeyError : 'run2d'

Open
#2,708 3 comments 0 reactions 0 assignees View on GitHub
close? sdss
Dominant language
Python
Stars
791
Forks
451
Avg merge
1d 3h
Merged PRs (30d)
4

Description

I am trying to download Spectral files using sdss.get_spectra but continuously getting this error.
![image](https://user-images.githubusercontent.com/116879941/232063933-a99f18eb-2487-4bb8-a7de-a43edd65a913.png)

KeyError Traceback (most recent call last)
K:\Anaconda\lib\site-packages\astropy\table\row.py in __getitem__(self, item)
50 # and allows a list of tuple or str, which is not the right thing here.
---> 51 out = OrderedDict.__getitem__(self._table.columns, item)[self._index]
52 except (KeyError, TypeError):

KeyError: 'run2d'

During handling of the above exception, another exception occurred:

KeyError Traceback (most recent call last)
~\AppData\Local\Temp\ipykernel_15996\155021905.py in
34 co = coords.SkyCoord(ra, dec, unit=(u.deg, u.deg))
35 try:
---> 36 spectrum = SDSS.get_spectra_async(co, plate=plate, fiberID=fiber, data_release=16)
37 except ConnectionError as e:
38 print(f"Connection error: {e}")

K:\Anaconda\lib\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)
589 # - instruments
590 # - run2d sometimes (#739)
--> 591 if isinstance(row['run2d'], bytes):
592 run2d = row['run2d'].decode()
593 elif isinstance(row['run2d'], (np.integer, int)):

K:\Anaconda\lib\site-packages\astropy\table\row.py in __getitem__(self, item)
56 else:
57 # This is only to raise an exception
---> 58 out = self._table.columns[item][self._index]
59 return out
60

K:\Anaconda\lib\site-packages\astropy\table\table.py in __getitem__(self, item)
244 """
245 if isinstance(item, str):
--> 246 return OrderedDict.__getitem__(self, item)
247 elif isinstance(item, (int, np.integer)):
248 return list(self.values())[item]

KeyError: 'run2d'

Contributor guide

Open the contributing guide

Research direction

Start at astroquery/sdss/core.py in get_spectra_async, where the traceback accesses row['run2d']; inspect the query response columns for the supplied plate, fiberID, and data_release=16. Reproduce the request with the reported inputs and verify that a response without run2d no longer raises KeyError while spectrum retrieval remains correct.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
data
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.