From 47a33ff5e5b0ffffd0b289e7f4149f464dbd2f44 Mon Sep 17 00:00:00 2001 From: "Adam Ginsburg (keflavich)" Date: Wed, 4 Mar 2026 15:37:02 -0500 Subject: [PATCH] use get_molecule by default in jplspec - server is completely down now, may never come back. wayback machine URL added to config --- astroquery/linelists/jplspec/__init__.py | 6 ++++++ astroquery/linelists/jplspec/core.py | 15 +++++++++++---- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/astroquery/linelists/jplspec/__init__.py b/astroquery/linelists/jplspec/__init__.py index 5b03985e7f..1f7b76ad4c 100644 --- a/astroquery/linelists/jplspec/__init__.py +++ b/astroquery/linelists/jplspec/__init__.py @@ -15,6 +15,12 @@ class Conf(_config.ConfigNamespace): 'https://spec.jpl.nasa.gov/cgi-bin/catform', 'JPL Spectral Catalog URL.') + ftp_cat_server = _config.ConfigItem( + ['https://spec.jpl.nasa.gov/ftp/pub/catalog/', + 'https://web.archive.org/web/20250630185813/https://spec.jpl.nasa.gov/ftp/pub/catalog/'], + 'JPL FTP Catalog URL' + ) + timeout = _config.ConfigItem( 60, 'Time limit for connecting to JPL server.') diff --git a/astroquery/linelists/jplspec/core.py b/astroquery/linelists/jplspec/core.py index fd2648dcf5..547d135044 100644 --- a/astroquery/linelists/jplspec/core.py +++ b/astroquery/linelists/jplspec/core.py @@ -27,6 +27,7 @@ class JPLSpecClass(BaseQuery): # use the Configuration Items imported from __init__.py URL = conf.server + FTP_CAT_URL = conf.ftp_cat_server TIMEOUT = conf.timeout def __init__(self): @@ -142,6 +143,7 @@ def query_lines(self, min_frequency, max_frequency, *, parse_name_locally=False, get_query_payload=False, fallback_to_getmolecule=True, + use_getmolecule=True, cache=True): """ Query the JPLSpec service for spectral lines. @@ -153,6 +155,9 @@ def query_lines(self, min_frequency, max_frequency, *, governs whether `get_molecule` will be used when no results are returned by the query service. This workaround is needed while JPLSpec's query tool is broken. + + use_getmolecule is an option to force the query to use get_molecule. + It is needed if the JPL server is completely unresponsive. """ response = self.query_lines_async(min_frequency=min_frequency, max_frequency=max_frequency, @@ -166,11 +171,13 @@ def query_lines(self, min_frequency, max_frequency, *, if get_query_payload: return response else: - return self._parse_result(response, fallback_to_getmolecule=fallback_to_getmolecule) + return self._parse_result(response, fallback_to_getmolecule=fallback_to_getmolecule, + use_getmolecule=use_getmolecule) query_lines.__doc__ = process_asyncs.async_to_sync_docstr(query_lines_async.__doc__) - def _parse_result(self, response, *, verbose=False, fallback_to_getmolecule=False): + def _parse_result(self, response, *, verbose=False, fallback_to_getmolecule=False, + use_getmolecule=True): """ Parse a response into an `~astropy.table.Table` @@ -201,7 +208,7 @@ def _parse_result(self, response, *, verbose=False, fallback_to_getmolecule=Fals QN": Quantum numbers for the lower state. """ - if 'Zero lines were found' in response.text: + if 'Zero lines were found' in response.text or use_getmolecule: if fallback_to_getmolecule: self.lookup_ids = build_lookup() payload = parse_qs(response.request.body) @@ -320,7 +327,7 @@ def get_molecule(self, molecule_id, *, cache=True): molecule_str = parse_molid(molecule_id) # Construct the URL to the catalog file - url = f'https://spec.jpl.nasa.gov/ftp/pub/catalog/c{molecule_str}.cat' + url = f'{self.FTP_CAT_URL}/c{molecule_str}.cat' # Request the catalog file response = self._request(method='GET', url=url,