Skip to content
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

NIST Vectorizing #2678

Merged
merged 3 commits into from
Mar 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,12 @@ mast

- Expanding ``Cutouts`` functionality to support TICA HLSPs now available through
``TesscutClass``. [##2668]

nist
^^^^

- Vectoized ``linename`` option to query multiple spectral lines with one call
of ``Nist.query``. [#2678]

oac
^^^
Expand Down
7 changes: 4 additions & 3 deletions astroquery/nist/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ def _args_to_payload(self, *args, **kwargs):
The lower wavelength for the spectrum in appropriate units.
maxwav : `astropy.units.Quantity` object
The upper wavelength for the spectrum in appropriate units.
linename : str, optional
The spectrum to fetch. Defaults to "H I"
linename : str or iterable of str, optional
The spectrum/spectra to fetch. Defaults to "H I"
energy_level_unit : str, optional
The energy level units must be one of the following:
'R', 'Rydberg', 'rydberg', 'cm', 'cm-1', 'EV', 'eV',
Expand All @@ -85,7 +85,8 @@ def _args_to_payload(self, *args, **kwargs):

"""
request_payload = {}
request_payload["spectra"] = kwargs['linename']
linename = kwargs["linename"]
request_payload["spectra"] = linename if isinstance(linename, str) else "; ".join(linename)
(min_wav, max_wav, wav_unit) = _parse_wavelength(args[0], args[1])
request_payload["low_wl"] = min_wav
request_payload["upp_wl"] = max_wav
Expand Down
3 changes: 3 additions & 0 deletions astroquery/nist/tests/test_nist.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ def test_query_async(patch_get):
linename="H I", get_query_payload=True)
assert response['spectra'] == "H I"
assert response['unit'] == nist.core.Nist.unit_code['nm']
response = nist.core.Nist.query_async(4000 * u.nm, 7000 * u.nm,
linename=["H I", "Fe I"], get_query_payload=True)
assert response["spectra"] == "H I; Fe I"
response = nist.core.Nist.query_async(4000 * u.nm, 7000 * u.nm, linename="H I")
assert response is not None

Expand Down
6 changes: 4 additions & 2 deletions docs/nist/nist.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@ nanometer, or angstrom or the like. For example, to use a lower wavelength
value of 4000 Angstroms, you should use ```4000 * u.AA``` and if you want the
same in nanometers, just use ```400 * u.nm```. Of course there are several optional
parameters you can also specify. For instance use the ``linename`` parameter to
specify the spectrum you wish to fetch. By default this is set to "H I", but
you can set it to several other values like "Na;Mg", etc. Lets now see a simple example.
specify the spectrum you wish to fetch.
``linename`` also accepts multiple line strings in an iterable (e.g. ``["Na", "H I"]``)
or you can specify multiple lines as a single string value separated with a
semicolon (e.g. ``"Na;Mg"``). Now let's see a simple example:

.. doctest-remote-data::

Expand Down