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

Update the ibe module so all of the IbeClass list methods work correctly. #1428

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions astroquery/ibe/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,11 @@ class Conf(_config.ConfigNamespace):

dataset = _config.ConfigItem(
'images',
('Default data set. See, for example, '
'http://irsa.ipac.caltech.edu/ibe/search/ptf for options.'))
('This option is meaningless in the context of IRSA\'s ibe.'))
table = _config.ConfigItem(
'level1',
('Default table. See, for example, '
'http://irsa.ipac.caltech.edu/ibe/search/ptf/images for options.'))
'ptf.ptf_procimg',
('Default table. Select the desired mission at '
'http://irsa.ipac.caltech.edu/ibe/search/ for options.'))
timeout = _config.ConfigItem(
60,
'Time limit for connecting to the IRSA server.')
Expand Down
42 changes: 14 additions & 28 deletions astroquery/ibe/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

import astropy.coordinates as coord
from astropy.table import Table
from astropy.io.ascii.html import HTML
import six

from ..exceptions import InvalidQueryError
Expand Down Expand Up @@ -276,14 +277,17 @@ def list_missions(self, cache=True):

root = BeautifulSoup(response.text)
links = root.findAll('a')
missions = [os.path.basename(a.attrs['href']) for a in links]

missions = [os.path.basename(a.attrs['href'].rstrip('/'))
for a in links]
self._missions = missions

return missions

def list_datasets(self, mission=None, cache=True):
"""
For a given mission, list the available datasets
For a given mission, list the available datasets.
This level has no meaning in IRSA's ibe service.

Parameters
----------
Expand All @@ -299,24 +303,8 @@ def list_datasets(self, mission=None, cache=True):
datasets : list
A list of dataset names
"""
if mission is None:
mission = self.MISSION
if mission not in self.list_missions():
raise ValueError("Invalid mission specified: {0}."
"Must be one of: {1}"
.format(mission, self.list_missions()))

url = "{URL}search/{mission}/".format(URL=self.URL, mission=mission)
response = self._request('GET', url, timeout=self.TIMEOUT,
cache=cache)

root = BeautifulSoup(response.text)
links = root.findAll('a')
datasets = [a.text for a in links
if a.attrs['href'].count('/') >= 4 # shown as '..'; ignore
]

return datasets
return ["images"]

def list_tables(self, mission=None, dataset=None, cache=True):
"""
Expand Down Expand Up @@ -358,9 +346,7 @@ def list_tables(self, mission=None, dataset=None, cache=True):
.format(dataset, mission,
self.list_datasets(mission, cache=True)))

url = "{URL}search/{mission}/{dataset}/".format(URL=self.URL,
mission=mission,
dataset=dataset)
url = "{URL}search/{mission}/".format(URL=self.URL, mission=mission)
response = self._request('GET', url, timeout=self.TIMEOUT,
cache=cache)

Expand All @@ -386,10 +372,9 @@ def show_docs(self, mission=None, dataset=None, table=None):
The table to be queried (if not the default table).
"""

url = "{URL}docs/{mission}/{dataset}/{table}".format(
url = "{URL}docs/{mission}/{table}".format(
URL=self.URL,
mission=mission or self.MISSION,
dataset=dataset or self.DATASET,
table=table or self.TABLE)

return webbrowser.open(url)
Expand All @@ -413,19 +398,20 @@ def get_columns(self, mission=None, dataset=None, table=None):
A table containing a description of the columns
"""

url = "{URL}search/{mission}/{dataset}/{table}".format(
url = "{URL}search/{mission}/{table}/".format(
URL=self.URL,
mission=mission or self.MISSION,
dataset=dataset or self.DATASET,
table=table or self.TABLE)

response = self._request(
'GET', url, {'FORMAT': 'METADATA'}, timeout=self.TIMEOUT)
'GET', url, {'FORMAT': 'METADATA'},
timeout=self.TIMEOUT)

# Raise exception, if request failed
response.raise_for_status()
HTMLtoTable = HTML()

return Table.read(response.text, format='ipac', guess=False)
return HTMLtoTable.read(response.text)


Ibe = IbeClass()