Skip to content

Commit 41d6b81

Browse files
committed
NIST: added ability to query of multiple linenames
1 parent a6f3e0a commit 41d6b81

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

astroquery/nist/core.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,8 @@ def _args_to_payload(self, *args, **kwargs):
6363
The lower wavelength for the spectrum in appropriate units.
6464
maxwav : `astropy.units.Quantity` object
6565
The upper wavelength for the spectrum in appropriate units.
66-
linename : str, optional
67-
The spectrum to fetch. Defaults to "H I"
66+
linename : str or list, optional
67+
The spectrum/spectra to fetch. Defaults to "H I"
6868
energy_level_unit : str, optional
6969
The energy level units must be one of the following:
7070
'R', 'Rydberg', 'rydberg', 'cm', 'cm-1', 'EV', 'eV',
@@ -85,7 +85,13 @@ def _args_to_payload(self, *args, **kwargs):
8585
8686
"""
8787
request_payload = {}
88-
request_payload["spectra"] = kwargs['linename']
88+
linename = kwargs["linename"]
89+
if isinstance(linename, str):
90+
request_payload["spectra"] = linename
91+
elif isinstance(linename, list):
92+
request_payload["spectra"] = " ".join(linename)
93+
else:
94+
raise TypeError("linename must str or list")
8995
(min_wav, max_wav, wav_unit) = _parse_wavelength(args[0], args[1])
9096
request_payload["low_wl"] = min_wav
9197
request_payload["upp_wl"] = max_wav

astroquery/nist/tests/test_nist.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,13 @@ def test_query_async(patch_get):
4545
linename="H I", get_query_payload=True)
4646
assert response['spectra'] == "H I"
4747
assert response['unit'] == nist.core.Nist.unit_code['nm']
48+
response = nist.core.Nist.query_async(4000 * u.nm, 7000 * u.nm,
49+
linename=["H I", "Fe I"], get_query_payload=True)
50+
assert response["spectra"] == "H I Fe I"
51+
with pytest.raises(TypeError) as err:
52+
nist.core.Nist.query_async(4000 * u.nm, 7000 * u.nm,
53+
linename=("H I", "Fe"), get_query_payload=True)
54+
assert str(err.value) == "linename must str or list"
4855
response = nist.core.Nist.query_async(4000 * u.nm, 7000 * u.nm, linename="H I")
4956
assert response is not None
5057

0 commit comments

Comments
 (0)