astropy / astroquery

Functions and classes to access online data resources. Maintainers: @keflavich and @bsipocz and @ceb8
http://astroquery.readthedocs.org/en/latest/
BSD 3-Clause "New" or "Revised" License
705 stars 397 forks source link

Error with Splatalogue.query_lines() for specific molecules #1407

Open wheeyeon opened 5 years ago

wheeyeon commented 5 years ago

Hello, I am trying to use Splatalogue.query_lines() to get line intensity data for a certain frequency range. When running the following code, I run into an error as shown below. It seems that the error only happens when the query involves '2,4-Pentadiynylidyne'. I wonder if there is a way to fix this as I would like to eventually write a code to calculate the spectrum for an arbitrary frequency range.

astropy : 3.1 astroquery : 0.3.9

Python 3.7.1 (default, Dec 10 2018, 22:54:23) [MSC v.1915 64 bit (AMD64)] :: Anaconda, Inc. on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from astroquery.splatalogue import Splatalogue
gzip was not found on your system! You should solve this issue for astroquery.eso to be at its best!
On POSIX system: make sure gzip is installed and in your path!On Windows: same for 7-zip (http://www.7-zip.org)!
>>> from astropy import units as u
>>> Splatalogue.query_lines(6.7 * u.GHz, 6.8 * u.GHz)
Traceback (most recent call last):
  File "C:\Users\wheey\Anaconda3\lib\site-packages\astropy\io\ascii\ui.py", line 542, in _guess
    dat = reader.read(table)
  File "C:\Users\wheey\Anaconda3\lib\site-packages\astropy\io\ascii\core.py", line 1189, in read
    raise InconsistentTableError(errmsg)
astropy.io.ascii.core.InconsistentTableError: Number of header columns (17) inconsistent with data columns (18) at data line 494
Header values: ['Species', 'Chemical Name', 'Freq-GHz(rest frame,redshifted)', 'Freq Err(rest frame,redshifted)', 'Meas Freq-GHz(rest frame,redshifted)', 'Meas Freq Err(rest frame,redshifted)', 'Resolved QNs', 'CDMS/JPL Intensity', 'S<sub>ij</sub>&#956;<sup>2</sup> (D<sup>2</sup>)', 'S<sub>ij</sub>', 'Log<sub>10</sub> (A<sub>ij</sub>)', 'Lovas/AST Intensity', 'E_L (cm^-1)', 'E_L (K)', 'E_U (cm^-1)', 'E_U (K)', 'Linelist']
Data values: ['l-C5D', '2,4-Pentadiynylidyne', '6.76284200', '1.2E-6', '', '', 'J-1/2', '2-1,&Omega;=1/2,f', '-6.03400', '95.30165', '0.00000', '-7.54376', '', '0.00000', '0.00000', '0.22558', '0.32457', 'CDMS']

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\wheey\Anaconda3\lib\site-packages\astroquery\utils\class_or_instance.py", line 25, in f
    return self.fn(obj, *args, **kwds)
  File "C:\Users\wheey\Anaconda3\lib\site-packages\astroquery\utils\process_asyncs.py", line 29, in newmethod
    result = self._parse_result(response, verbose=verbose)
  File "C:\Users\wheey\Anaconda3\lib\site-packages\astroquery\splatalogue\core.py", line 476, in _parse_result
    format='basic')
  File "C:\Users\wheey\Anaconda3\lib\site-packages\astropy\io\ascii\ui.py", line 368, in read
    dat = _guess(table, new_kwargs, format, fast_reader)
  File "C:\Users\wheey\Anaconda3\lib\site-packages\astropy\io\ascii\ui.py", line 574, in _guess
    raise core.InconsistentTableError('\n'.join(lines))
astropy.io.ascii.core.InconsistentTableError:
ERROR: Unable to guess table format with the guesses listed below:
Reader:FastBasic delimiter: ':' fast_reader: {'enable': True} fill_values: [('', '0')]
Reader:Basic delimiter: ':' fast_reader: {'enable': True} fill_values: [('', '0')]
Reader:Basic delimiter: ':' fast_reader: {'enable': True} fill_values: [('', '0')]

************************************************************************
** ERROR: Unable to guess table format with the guesses listed above. **
**                                                                    **
** To figure out why the table did not read, use guess=False and      **
** fast_reader=False, along with any appropriate arguments to read(). **
** In particular specify the format and any known attributes like the **
** delimiter.                                                         **
************************************************************************
>>>
keflavich commented 5 years ago

Right, this is almost certainly because of the comma in the molecule name. This is likely a real bug. We probably need to add a hack that replaces commas in the molecule name with, say, underscores. You can look at the raw return by looking at the result from query_lines_async and see if you can figure out how to parse the result.

bsipocz commented 5 years ago

Oh, I even wonder whether the ascii reader should be more clever and recognize that the it should ignore the comma inside quotation marks. If it should, then it's an upstream astropy issue. @taldcroft - what do you think?

wheeyeon commented 5 years ago

It seems like the problem is the colon in certain values of "Resolved QNs". Checking from the splatalogue site shows that "Resolved QNs" for 2,4-Pentadiynylidyne is "J-1/2: 2 - 1, Ω = 1/2, f". It seems that this was split into 'J-1/2' and '2-1,Ω=1/2,f'. Querying for 2,4-Pentadiynylidyne at frequencies where there isn't a colon works without error. Searching for other molecules with a comma in the molecule name seems to work fine as well.