Skip to content

Commit 361e73b

Browse files
committed
cleanup molwt/tag parsing
shift tag back one spot. Fix tests to accommodate more complete "tag" name add the b1 = -21 test whitespace
1 parent ebda867 commit 361e73b

File tree

2 files changed

+15
-9
lines changed

2 files changed

+15
-9
lines changed

astroquery/linelists/cdms/core.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -262,9 +262,8 @@ def _parse_result(self, response, *, verbose=False):
262262
'DR': 36,
263263
'ELO': 38,
264264
'GUP': 47,
265-
'MOLWT': 50,
266-
'TAG': 54,
267-
'QNFMT': 58,
265+
'TAG': 50,
266+
'QNFMT': 57,
268267
'Ju': 61,
269268
'Ku': 63,
270269
'vu': 65,
@@ -288,6 +287,7 @@ def _parse_result(self, response, *, verbose=False):
288287
result['FREQ'].unit = u.MHz
289288
result['ERR'].unit = u.MHz
290289

290+
result['MOLWT'] = [int(x/1e3) for x in result['TAG']]
291291
result['Lab'] = result['MOLWT'] < 0
292292
result['MOLWT'] = np.abs(result['MOLWT'])
293293
result['MOLWT'].unit = u.Da

astroquery/linelists/cdms/tests/test_cdms_remote.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ def test_remote_300K():
4141
assert tbl['MOLWT'][0] == 18
4242
assert tbl['TAG'][0] == 18505
4343

44+
4445
@pytest.mark.remote_data
4546
def test_co_basics():
4647
tbl = CDMS.get_molecule('028503')
@@ -49,15 +50,20 @@ def test_co_basics():
4950
assert tbl['Q1'][10] == 11
5051
assert tbl['Q7'][10] == 10
5152
assert tbl['MOLWT'][0] == 28
52-
assert tbl['TAG'][0] == 28503
53+
assert tbl['TAG'][0] == -28503
5354

5455

5556
@pytest.mark.remote_data
5657
def test_ch3cn_negqn():
5758
tbl = CDMS.get_molecule('041501')
5859
fourtominusthree = tbl[(tbl['Q1'] == 4) & (tbl['Q2'] == -3)]
5960
assert len(fourtominusthree) >= 1
60-
assert tbl['TAG'][0] == 41501
61+
62+
# check specifically for -21, which is encoded as `b1`
63+
twentytwominustwentyone = tbl[(tbl['Q1'] == 22) & (tbl['Q2'] == -21)]
64+
assert len(twentytwominustwentyone) >= 1
65+
66+
assert tbl['TAG'][0] == -41501
6167

6268

6369
@pytest.mark.remote_data
@@ -103,16 +109,16 @@ def test_molecule_with_parens():
103109

104110
MC = np.ma.core.MaskedConstant()
105111

106-
for col, val in zip(tbl[0].colnames, (232588.7246, 0.2828, -4.1005, 3, 293.8540, 445, 66,
107-
506, 303, 44, 14, 30, MC, MC, MC, 45, 13, 33, MC, MC, MC, 'H2C(CN)2', False)):
112+
for col, val in zip(tbl[0].colnames, (232588.7246, 0.2828, -4.1005, 3, 293.8540, 445, 66506,
113+
303, 44, 14, 30, MC, MC, MC, 45, 13, 33, MC, MC, MC, 'H2C(CN)2', 66, False)):
108114
if val is MC:
109115
assert tbl[0][col].mask
110116
else:
111117
assert tbl[0][col] == val
112118

113119
# this test row includes degeneracy = 1225, which covers one of the weird letter-is-number parser cases
114-
for col, val in zip(tbl[16].colnames, (233373.369, 10.26, -4.8704, 3, 1229.0674, 1125, 66,
115-
506, 303, 112, 10, 102, MC, MC, MC, 112, 9, 103, MC, MC, MC, 'H2C(CN)2', False),):
120+
for col, val in zip(tbl[16].colnames, (233373.369, 10.26, -4.8704, 3, 1229.0674, 1125, 66506,
121+
303, 112, 10, 102, MC, MC, MC, 112, 9, 103, MC, MC, MC, 'H2C(CN)2', 66, False),):
116122
if val is MC:
117123
assert tbl[16][col].mask
118124
else:

0 commit comments

Comments
 (0)