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

Fix issue 2889: NIST wl keyword #2918

Merged
merged 3 commits into from
Jan 8, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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: 3 additions & 3 deletions astroquery/nist/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,15 +88,15 @@ def _args_to_payload(self, *args, **kwargs):
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
request_payload["low_w"] = min_wav
request_payload["upp_w"] = max_wav
request_payload["unit"] = wav_unit
request_payload["submit"] = "Retrieve Data"
request_payload["format"] = 1 # ascii
request_payload["line_out"] = 0 # All lines
request_payload["en_unit"] = Nist.energy_level_code[
kwargs["energy_level_unit"]]
request_payload["output"] = 0 # entirely rather than pagewise
request_payload["output_type"] = 0 # entirely rather than pagewise
request_payload["bibrefs"] = 1
request_payload["show_obs_wl"] = 1
request_payload["show_calc_wl"] = 1
Expand Down
24 changes: 22 additions & 2 deletions astroquery/nist/tests/test_nist_remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@
class TestNist:

def test_query_async(self):
response = nist.core.Nist.query_async(4000 * u.nm, 7000 * u.nm)
response = nist.core.Nist.query_async(4000 * u.AA, 7000 * u.AA)
assert response is not None

def test_query(self):
result = nist.core.Nist.query(4000 * u.nm, 7000 * u.nm)
result = nist.core.Nist.query(4000 * u.AA, 7000 * u.AA)
assert isinstance(result, Table)

# check that no javascript was left in the table
Expand All @@ -30,3 +30,23 @@ def test_unescape_html(self):
# raw HTML code equivalents during parsing
response = nist.core.Nist._parse_result(response)
assert any('†' in s for s in response['Ei Ek'])

def test_query_limits(self):
result = nist.core.Nist.query(4101 * u.AA, 4103 * u.AA)
# check that min, max wavelengths are appropriately set
assert result['Ritz'].min() >= 4101
assert result['Ritz'].max() <= 4103

# check that the units are respected
result = nist.core.Nist.query(410.1 * u.nm, 410.3 * u.nm)
assert result['Ritz'].min() >= 410.1
assert result['Ritz'].max() <= 410.3

result = nist.core.Nist.query(0.4101 * u.um, 0.4103 * u.um)
assert result['Ritz'].min() >= 0.4101
assert result['Ritz'].max() <= 0.4103

# check that non-supported units default to angstroms
result = nist.core.Nist.query(4101 * 1e-10 * u.m, 4103 * 1e-10 * u.m)
assert result['Ritz'].min() >= 4101
assert result['Ritz'].max() <= 4103
Comment on lines +49 to +52
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wow, this is totally unexpected. Would you mention it in the narrative docs?

Or, alternative we should instead return a QTable with units properly set on the column.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

QTable seems the better solution; I think we should punt to the next PR though.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.