Skip to content

Commit b1eabf6

Browse files
authored
Merge pull request #2411 from keflavich/issue2409
Fix for CDMS issue 2409: mis-parsed GUP
2 parents 2922473 + 832f517 commit b1eabf6

File tree

6 files changed

+120
-7
lines changed

6 files changed

+120
-7
lines changed

CHANGES.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ linelists.cdms
3636
^^^^^^^^^^^^^^
3737

3838
- Fix issues with the line name parser and the line data parser; the original
39-
implementation was incomplete. [#2385]
39+
implementation was incomplete and upstream was not fully documented. [#2385, #2411]
4040

4141
Infrastructure, Utility and Other Changes and Additions
4242
-------------------------------------------------------

astroquery/linelists/cdms/core.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ def _parse_result(self, response, verbose=False):
224224
'LGINT': 25,
225225
'DR': 36,
226226
'ELO': 38,
227-
'GUP': 48,
227+
'GUP': 47,
228228
'MOLWT': 51,
229229
'TAG': 54,
230230
'QNFMT': 58,
@@ -255,13 +255,16 @@ def _parse_result(self, response, verbose=False):
255255
result['MOLWT'] = np.abs(result['MOLWT'])
256256
result['MOLWT'].unit = u.Da
257257

258+
fix_keys = ['GUP']
258259
for suf in 'ul':
259260
for qn in ('J', 'v', 'K', 'F1', 'F2', 'F3'):
260261
qnind = qn+suf
261-
if result[qnind].dtype != int:
262-
intcol = np.array(list(map(parse_letternumber, result[qnind])),
263-
dtype=int)
264-
result[qnind] = intcol
262+
fix_keys.append(qnind)
263+
for key in fix_keys:
264+
if result[key].dtype != int:
265+
intcol = np.array(list(map(parse_letternumber, result[key])),
266+
dtype=int)
267+
result[key] = intcol
265268

266269
# if there is a crash at this step, something went wrong with the query
267270
# and the _last_query_temperature was not set. This shouldn't ever

astroquery/linelists/cdms/setup_package.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ def get_package_data():
88

99
paths_test = [os.path.join('data', 'CO.data'),
1010
os.path.join('data', 'HC7S.data'),
11+
os.path.join('data', 'HC7N.data'),
1112
os.path.join('data', 'post_response.html'),
1213
]
1314
paths_data = [os.path.join('data', 'catdir.cat')]
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<!DOCTYPE html
2+
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
3+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
4+
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US" xml:lang="en-US">
5+
<head>
6+
<title>Untitled Document</title>
7+
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
8+
</head>
9+
<body>
10+
<pre>
11+
200693.4060 0.01 -2.241 2 592.5904A71 -99501 101H8 H7 HC7N, v=0
12+
201819.8670 0.01 -2.2477 2 599.2848A77 -99501 101H9 H8 HC7N, v=0
13+
202946.3080 0.01 -2.2545 2 606.0168A83 -99501 101I0 H9 HC7N, v=0
14+
204072.7438 0.0021 -2.2614 2 612.7864A89 99501 101I1 I0 HC7N, v=0
15+
205199.1560 0.01 -2.2685 2 619.5935A95 -99501 101I2 I1 HC7N, v=0
16+
206325.5464 0.0021 -2.2756 2 626.4382B01 99501 101I3 I2 HC7N, v=0
17+
207451.9212 0.0022 -2.2829 2 633.3205B07 99501 101I4 I3 HC7N, v=0
18+
208578.2850 0.01 -2.2903 2 640.2403B13 -99501 101I5 I4 HC7N, v=0
19+
209704.6300 0.01 -2.2978 2 647.1977B19 -99501 101I6 I5 HC7N, v=0
20+
210830.9270 0.01 -2.3054 2 654.1927B25 -99501 101I7 I6 HC7N, v=0
21+
211957.2426 0.0025 -2.3132 2 661.2253B31 99501 101I8 I7 HC7N, v=0
22+
213083.5310 0.01 -2.321 2 668.2954B37 -99501 101I9 I8 HC7N, v=0
23+
214209.8020 0.01 -2.329 2 675.4031B43 -99501 101J0 I9 HC7N, v=0
24+
215336.0450 0.01 -2.3371 2 682.5484B49 -99501 101J1 J0 HC7N, v=0
25+
216462.2742 0.0029 -2.3453 2 689.7312B55 99501 101J2 J1 HC7N, v=0
26+
217588.4862 0.003 -2.3536 2 696.9516B61 99501 101J3 J2 HC7N, v=0
27+
218714.6795 0.0032 -2.362 2 704.2096B67 99501 101J4 J3 HC7N, v=0
28+
219840.8542 0.0033 -2.3706 2 711.5052B73 99501 101J5 J4 HC7N, v=0
29+
220967.0101 0.0035 -2.3792 2 718.8383B79 99501 101J6 J5 HC7N, v=0
30+
222093.1472 0.0036 -2.388 2 726.2089B85 99501 101J7 J6 HC7N, v=0
31+
223219.2520 0.01 -2.3969 2 733.6172B91 -99501 101J8 J7 HC7N, v=0
32+
224345.3644 0.004 -2.4059 2 741.0629B97 99501 101J9 J8 HC7N, v=0
33+
225471.4400 0.01 -2.415 2 748.5463C03 -99501 101K0 J9 HC7N, v=0
34+
226597.5130 0.01 -2.4242 2 756.0672C09 -99501 101K1 K0 HC7N, v=0
35+
227723.5463 0.0046 -2.4335 2 763.6257C15 99501 101K2 K1 HC7N, v=0
36+
228849.5682 0.0048 -2.4429 2 771.2217C21 99501 101K3 K2 HC7N, v=0
37+
229975.5705 0.005 -2.4525 2 778.8553C27 99501 101K4 K3 HC7N, v=0
38+
</pre></body></html>

astroquery/linelists/cdms/tests/test_cdms.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,8 @@ def test_query(patch_post):
8181
assert tbl['FREQ'][0] == 115271.2018
8282
assert tbl['ERR'][0] == .0005
8383
assert tbl['LGINT'][0] == -7.1425
84+
assert tbl['GUP'][0] == 3
85+
assert tbl['GUP'][7] == 17
8486

8587

8688
def test_parseletternumber():
@@ -118,6 +120,7 @@ def test_hc7s(patch_post):
118120
assert tbl['LGINT'][0] == -3.9202
119121
assert tbl['MOLWT'][0] == 117
120122

123+
assert tbl['GUP'][0] == 255
121124
assert tbl['Ju'][0] == 126
122125
assert tbl['Jl'][0] == 125
123126
assert tbl['vu'][0] == 127
@@ -126,3 +129,34 @@ def test_hc7s(patch_post):
126129
assert tbl['Kl'][0] == 1
127130
assert tbl['F1u'][0] == 127
128131
assert tbl['F1l'][0] == 126
132+
133+
134+
def test_hc7n(patch_post):
135+
"""
136+
Regression test for 2409, specifically that GUP>1000 was not being
137+
processed correctly b/c the first digit of GUP was being included in the
138+
previous column (frequency)
139+
140+
CDMS.query_lines(200*u.GHz, 230.755608*u.GHz, molecule='HC7N',parse_name_locally=True)
141+
"""
142+
143+
tbl = CDMS.query_lines(200*u.GHz, 230.755608*u.GHz, molecule='HC7N')
144+
assert isinstance(tbl, Table)
145+
assert len(tbl) == 27
146+
assert set(tbl.keys()) == colname_set
147+
148+
assert tbl['FREQ'][0] == 200693.406
149+
assert tbl['ERR'][0] == 0.01
150+
assert tbl['LGINT'][0] == -2.241
151+
assert tbl['MOLWT'][0] == 99
152+
153+
assert tbl['GUP'][0] == 1071
154+
assert tbl['Ju'][0] == 178
155+
assert tbl['Jl'][0] == 177
156+
assert tbl['vu'][0].mask
157+
assert tbl['vl'][0].mask
158+
assert tbl['Ku'][0].mask
159+
assert tbl['Kl'][0].mask
160+
assert tbl['F1u'][0].mask
161+
assert tbl['F1l'][0].mask
162+
assert tbl['Lab'][0]

astroquery/linelists/cdms/tests/test_cdms_remote.py

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,45 @@ def test_molecule_with_parens():
6767
MC = np.ma.core.MaskedConstant()
6868

6969
for col, val in zip(tbl[0].colnames,
70-
(232588.7246, 0.2828, -4.1005, 3, '293.85404', 45, 66, 506, 303, 44, 14, 30, MC, MC, MC, 45, 13, 33, MC, MC, MC, 'H2C(CN)2', False)):
70+
(232588.7246, 0.2828, -4.1005, 3, 293.8540, 445, 66, 506, 303, 44, 14, 30, MC, MC, MC, 45, 13, 33, MC, MC, MC, 'H2C(CN)2', False)):
7171
if val is MC:
7272
assert tbl[0][col].mask
7373
else:
7474
assert tbl[0][col] == val
75+
76+
# this test row includes degeneracy = 1225, which covers one of the weird letter-is-number parser cases
77+
for col, val in zip(tbl[16].colnames,
78+
(233373.369, 10.26, -4.8704, 3, 1229.0674, 1125, 66, 506, 303, 112, 10, 102, MC, MC, MC, 112, 9, 103, MC, MC, MC, 'H2C(CN)2', False),):
79+
if val is MC:
80+
assert tbl[16][col].mask
81+
else:
82+
assert tbl[16][col] == val
83+
84+
85+
@pytest.mark.remote_data
86+
def test_complex_molecule_remote():
87+
"""
88+
Part of the regression test for 2409. See "test_hc7n" in the non-remote
89+
tests. This version covers both the local name parsing and checks whether
90+
there are upstream changes.
91+
"""
92+
tbl = CDMS.query_lines(200*u.GHz, 230.755608*u.GHz, molecule='HC7N', parse_name_locally=True)
93+
assert isinstance(tbl, Table)
94+
assert len(tbl) == 27
95+
assert set(tbl.keys()) == colname_set
96+
97+
assert tbl['FREQ'][0] == 200693.406
98+
assert tbl['ERR'][0] == 0.01
99+
assert tbl['LGINT'][0] == -2.241
100+
assert tbl['MOLWT'][0] == 99
101+
102+
assert tbl['GUP'][0] == 1071
103+
assert tbl['Ju'][0] == 178
104+
assert tbl['Jl'][0] == 177
105+
assert tbl['vu'][0].mask
106+
assert tbl['vl'][0].mask
107+
assert tbl['Ku'][0].mask
108+
assert tbl['Kl'][0].mask
109+
assert tbl['F1u'][0].mask
110+
assert tbl['F1l'][0].mask
111+
assert tbl['Lab'][0]

0 commit comments

Comments
 (0)