-
-
Notifications
You must be signed in to change notification settings - Fork 435
Add astroquery.linelists.exomol — ExoMol database query module #3536
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
base: main
Are you sure you want to change the base?
Changes from 18 commits
5152dcb
64a7d7b
f8445f9
02165e2
7b4f4e3
c6fb117
abb9bef
6af1b54
1e6d2fb
0ba56e8
abd6b2d
c7a0d69
d10be96
6b37d59
9db0db6
2b044be
892567a
062e043
55e715c
bbd89ee
121df8e
9312afd
99c856a
974a1aa
b0d1a6c
5618a38
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| # Licensed under a 3-clause BSD style license - see LICENSE.rst | ||
| from .core import ExoMol, ExoMolClass | ||
|
|
||
| __all__ = ["ExoMol", "ExoMolClass"] |
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,212 @@ | ||||||||||
| # Licensed under a 3-clause BSD style license - see LICENSE.rst | ||||||||||
| """ | ||||||||||
| ExoMol database query module for astroquery. | ||||||||||
| Wraps RADIS ExoMol reader (radis.io.exomol) into astroquery BaseQuery pattern. | ||||||||||
|
|
||||||||||
| References | ||||||||||
| ---------- | ||||||||||
| Tennyson et al. 2020, J. Quant. Spectrosc. Radiat. Transf. | ||||||||||
| https://www.exomol.com | ||||||||||
| RADIS: https://github.com/radis/radis (issue #925) | ||||||||||
| """ | ||||||||||
|
|
||||||||||
| from astropy.table import Table | ||||||||||
| from astroquery.query import BaseQuery | ||||||||||
| from astroquery import log | ||||||||||
|
|
||||||||||
| __all__ = ["ExoMol", "ExoMolClass"] | ||||||||||
|
|
||||||||||
| EXOMOL_URL = "https://www.exomol.com" | ||||||||||
|
|
||||||||||
|
|
||||||||||
| class ExoMolClass(BaseQuery): | ||||||||||
| """ | ||||||||||
| Queries the `ExoMol <https://www.exomol.com>`_ database for molecular | ||||||||||
| line lists used in exoplanet atmosphere modelling. | ||||||||||
|
|
||||||||||
| This module wraps the RADIS ExoMol reader (``radis.io.exomol``) and | ||||||||||
| exposes it via the standard astroquery ``BaseQuery`` interface, returning | ||||||||||
| ``astropy.table.Table`` objects. | ||||||||||
|
|
||||||||||
| Examples | ||||||||||
| -------- | ||||||||||
| Query CO lines between 2000-2100 cm^-1:: | ||||||||||
|
|
||||||||||
| from astroquery.linelists.exomol import ExoMol | ||||||||||
| result = ExoMol.query_lines('CO', | ||||||||||
| load_wavenum_min=2000, | ||||||||||
| load_wavenum_max=2100) | ||||||||||
| print(result) | ||||||||||
| """ | ||||||||||
|
|
||||||||||
| URL = EXOMOL_URL | ||||||||||
| TIMEOUT = 60 | ||||||||||
|
|
||||||||||
| def get_molecule_list(self, *, cache=True): | ||||||||||
| """ | ||||||||||
| Retrieve list of all molecules available in ExoMol. | ||||||||||
|
|
||||||||||
| Parameters | ||||||||||
| ---------- | ||||||||||
| cache : bool, optional | ||||||||||
| Cache HTTP response. Default ``True``. | ||||||||||
|
|
||||||||||
| Returns | ||||||||||
| ------- | ||||||||||
| list of str | ||||||||||
| Sorted list of molecule names available in ExoMol. | ||||||||||
| """ | ||||||||||
| url = f"{self.URL}/db/exomol.all" | ||||||||||
| response = self._request("GET", url, cache=cache, timeout=self.TIMEOUT) | ||||||||||
| response.raise_for_status() | ||||||||||
| molecules = [] | ||||||||||
| for line in response.text.splitlines(): | ||||||||||
| line = line.strip() | ||||||||||
| if line and not line.startswith("#"): | ||||||||||
| parts = line.split() | ||||||||||
| if parts: | ||||||||||
| molecules.append(parts[0]) | ||||||||||
| return sorted(list(set(molecules))) | ||||||||||
|
|
||||||||||
| def get_databases(self, molecule, isotopologue=None, *, cache=True): | ||||||||||
| """ | ||||||||||
| Get available line list databases for a given molecule. | ||||||||||
|
|
||||||||||
| Parameters | ||||||||||
| ---------- | ||||||||||
| molecule : str | ||||||||||
| Molecule formula e.g. ``'H2O'``, ``'CO'``, ``'CH4'``. | ||||||||||
| isotopologue : str, optional | ||||||||||
| Isotopologue slug e.g. ``'1H2-16O'``. If ``None``, uses default. | ||||||||||
| cache : bool, optional | ||||||||||
| Cache results. Default ``True``. | ||||||||||
|
|
||||||||||
| Returns | ||||||||||
| ------- | ||||||||||
| list of str | ||||||||||
| Available database names for this molecule. | ||||||||||
| """ | ||||||||||
| from radis.api.exomolapi import get_exomol_database_list | ||||||||||
| from radis.api.exomolapi import get_exomol_full_isotope_name | ||||||||||
|
||||||||||
|
|
||||||||||
| iso_name = get_exomol_full_isotope_name(molecule, 1) | ||||||||||
| dbs, _ = get_exomol_database_list(molecule, iso_name) | ||||||||||
| return dbs | ||||||||||
|
|
||||||||||
| def query_lines( | ||||||||||
| self, | ||||||||||
| molecule, | ||||||||||
| database=None, | ||||||||||
| isotopologue="1", | ||||||||||
| load_wavenum_min=None, | ||||||||||
| load_wavenum_max=None, | ||||||||||
|
||||||||||
| load_wavenum_min=None, | |
| load_wavenum_max=None, | |
| wavenum_min=None, | |
| wavenum_max=None, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
these should be Quantitys
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| [linelists.exomol] | ||
| ## ExoMol server base URL | ||
| server = https://www.exomol.com | ||
| ## Request timeout in seconds | ||
| timeout = 60 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To follow the astroquery standard for APIs, these should be specified with units - so
load_wavenum_min=2000*u.cm**-1, for example. Also, the keyword name should bewavenum_min-loaddoesn't fit here, afaict.