Skip to content

Commit ea7af08

Browse files
committed
use get_molecule by default in jplspec - server is completely down now, may never come back. wayback machine URL added to config
1 parent 25c4840 commit ea7af08

2 files changed

Lines changed: 17 additions & 4 deletions

File tree

astroquery/linelists/jplspec/__init__.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,12 @@ class Conf(_config.ConfigNamespace):
1515
'https://spec.jpl.nasa.gov/cgi-bin/catform',
1616
'JPL Spectral Catalog URL.')
1717

18+
ftp_cat_server = _config.ConfigItem(
19+
['https://spec.jpl.nasa.gov/ftp/pub/catalog/',
20+
'https://web.archive.org/web/20250630185813/https://spec.jpl.nasa.gov/ftp/pub/catalog/'],
21+
'JPL FTP Catalog URL'
22+
)
23+
1824
timeout = _config.ConfigItem(
1925
60,
2026
'Time limit for connecting to JPL server.')

astroquery/linelists/jplspec/core.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ class JPLSpecClass(BaseQuery):
2727

2828
# use the Configuration Items imported from __init__.py
2929
URL = conf.server
30+
FTP_CAT_URL = conf.ftp_cat_server
3031
TIMEOUT = conf.timeout
3132

3233
def __init__(self):
@@ -142,6 +143,7 @@ def query_lines(self, min_frequency, max_frequency, *,
142143
parse_name_locally=False,
143144
get_query_payload=False,
144145
fallback_to_getmolecule=True,
146+
use_getmolecule=True,
145147
cache=True):
146148
"""
147149
Query the JPLSpec service for spectral lines.
@@ -153,6 +155,9 @@ def query_lines(self, min_frequency, max_frequency, *,
153155
governs whether `get_molecule` will be used when no results are returned
154156
by the query service. This workaround is needed while JPLSpec's query
155157
tool is broken.
158+
159+
use_getmolecule is an option to force the query to use get_molecule.
160+
It is needed if the JPL server is completely unresponsive.
156161
"""
157162
response = self.query_lines_async(min_frequency=min_frequency,
158163
max_frequency=max_frequency,
@@ -166,11 +171,13 @@ def query_lines(self, min_frequency, max_frequency, *,
166171
if get_query_payload:
167172
return response
168173
else:
169-
return self._parse_result(response, fallback_to_getmolecule=fallback_to_getmolecule)
174+
return self._parse_result(response, fallback_to_getmolecule=fallback_to_getmolecule,
175+
use_getmolecule=use_getmolecule)
170176

171177
query_lines.__doc__ = process_asyncs.async_to_sync_docstr(query_lines_async.__doc__)
172178

173-
def _parse_result(self, response, *, verbose=False, fallback_to_getmolecule=False):
179+
def _parse_result(self, response, *, verbose=False, fallback_to_getmolecule=False,
180+
use_getmolecule=True):
174181
"""
175182
Parse a response into an `~astropy.table.Table`
176183
@@ -201,7 +208,7 @@ def _parse_result(self, response, *, verbose=False, fallback_to_getmolecule=Fals
201208
QN": Quantum numbers for the lower state.
202209
"""
203210

204-
if 'Zero lines were found' in response.text:
211+
if 'Zero lines were found' in response.text or use_getmolecule:
205212
if fallback_to_getmolecule:
206213
self.lookup_ids = build_lookup()
207214
payload = parse_qs(response.request.body)
@@ -320,7 +327,7 @@ def get_molecule(self, molecule_id, *, cache=True):
320327
molecule_str = parse_molid(molecule_id)
321328

322329
# Construct the URL to the catalog file
323-
url = f'https://spec.jpl.nasa.gov/ftp/pub/catalog/c{molecule_str}.cat'
330+
url = f'{self.FTP_CAT_URL}/c{molecule_str}.cat'
324331

325332
# Request the catalog file
326333
response = self._request(method='GET', url=url,

0 commit comments

Comments
 (0)