Skip to content

Commit fadc456

Browse files
authored
Merge pull request #2136 from keflavich/issue2135
splatalogue.utils minimize bugfix
2 parents 5685c70 + c66efff commit fadc456

File tree

3 files changed

+26
-2
lines changed

3 files changed

+26
-2
lines changed

CHANGES.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ New Tools and Services
88
Service fixes and enhancements
99
------------------------------
1010

11+
- Splatalogue table merging can now handle unmasked columns [#2136]
12+
1113

1214
Infrastructure, Utility and Other Changes and Additions
1315
-------------------------------------------------------

astroquery/splatalogue/tests/test_utils.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
from ... import splatalogue
33
from astropy import units as u
44
import numpy as np
5+
import pytest
56
from .test_splatalogue import patch_post
67
from .. import utils
78

@@ -31,3 +32,18 @@ def test_minimize(patch_post):
3132
assert np.all(c['Freq'] > 0)
3233
assert 'Resolved QNs' not in c.colnames
3334
assert 'QNs' in c.colnames
35+
36+
37+
@pytest.mark.remote_data
38+
def test_minimize_issue2135():
39+
rslt = splatalogue.Splatalogue.query_lines(100*u.GHz, 200*u.GHz,
40+
chemical_name=' SiO ',
41+
energy_max=1840,
42+
energy_type='eu_k',
43+
line_lists=['JPL', 'CDMS', 'SLAIM'],
44+
show_upper_degeneracy=True)
45+
46+
minimized = utils.minimize_table(rslt)
47+
48+
theomask = rslt['Freq-GHz(rest frame,redshifted)'].mask
49+
np.testing.assert_allclose(minimized['Freq'][theomask], rslt['Meas Freq-GHz(rest frame,redshifted)'][theomask])

astroquery/splatalogue/utils.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,17 @@ def merge_frequencies(table, prefer='measured',
5656

5757
if prefer == 'measured':
5858
Freq = np.copy(table[theor_kwd]).astype('float')
59-
measmask = np.logical_not(table[meas_kwd].mask)
59+
if hasattr(table[meas_kwd], 'mask'):
60+
measmask = np.logical_not(table[meas_kwd].mask)
61+
else:
62+
measmask = slice(None) # equivalent to [:] - all data are good
6063
Freq[measmask] = table[meas_kwd][measmask].astype('float')
6164
elif prefer == 'theoretical':
6265
Freq = np.copy(table[meas_kwd]).astype('float')
63-
theomask = np.logical_not(table[theor_kwd].mask)
66+
if hasattr(table[theor_kwd], 'mask'):
67+
theomask = np.logical_not(table[theor_kwd].mask)
68+
else:
69+
theomask = slice(None) # equivalent to [:] - all data are good
6470
Freq[theomask] = table[theor_kwd][theomask].astype('float')
6571
else:
6672
raise ValueError('prefer must be one of "measured" or "theoretical"')

0 commit comments

Comments
 (0)