Skip to content

Commit 6fe15b7

Browse files
authored
Merge pull request #2719 from bsipocz/jplspec_fix_CADDIR_parsing
BUG: fix parsing by filtering out junk lines
2 parents c0d8214 + 66f2099 commit 6fe15b7

File tree

2 files changed

+29
-30
lines changed

2 files changed

+29
-30
lines changed

astroquery/jplspec/core.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ def _parse_result(self, response, *, verbose=False):
164164
# Warning for a result with more than 1000 lines:
165165
# THIS form is currently limited to 1000 lines.
166166
result = ascii.read(response.text, header_start=None, data_start=0,
167-
comment=r'THIS|^\s{12,14}\d{4,6}.*',
167+
comment=r'THIS|^\s{12,14}\d{4,6}.*|CADDIR CATDIR',
168168
names=('FREQ', 'ERR', 'LGINT', 'DR', 'ELO', 'GUP',
169169
'TAG', 'QNFMT', 'QN\'', 'QN"'),
170170
col_starts=(0, 13, 21, 29, 31, 41, 44, 51, 55, 67),

docs/jplspec/jplspec.rst

Lines changed: 28 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -32,19 +32,19 @@ what each setting yields:
3232
... max_frequency=1000 * u.GHz,
3333
... min_strength=-500,
3434
... molecule="28001 CO",
35-
... max_lines = 7,
3635
... get_query_payload=False)
3736
>>> print(response)
3837
FREQ ERR LGINT DR ELO GUP TAG QNFMT QN' QN"
39-
MHz MHz MHz nm2 1 / cm
40-
----------- ------ ------- --- ------- --- ------ ----- --- ---
41-
115271.2018 0.0005 -5.0105 2 0.0 3 -28001 101 1 0
42-
230538.0 0.0005 -4.1197 2 3.845 5 -28001 101 2 1
43-
345795.9899 0.0005 -3.6118 2 11.535 7 -28001 101 3 2
44-
461040.7682 0.0005 -3.2657 2 23.0695 9 -28001 101 4 3
45-
576267.9305 0.0005 -3.0118 2 38.4481 11 -28001 101 5 4
46-
691473.0763 0.0005 -2.8193 2 57.6704 13 -28001 101 6 5
47-
806651.806 0.005 -2.6716 2 80.7354 15 -28001 101 7 6
38+
MHz MHz nm2 MHz 1 / cm
39+
----------- ------ ------- --- -------- --- ------ ----- --- ---
40+
115271.2018 0.0005 -5.0105 2 0.0 3 -28001 101 1 0
41+
230538.0 0.0005 -4.1197 2 3.845 5 -28001 101 2 1
42+
345795.9899 0.0005 -3.6118 2 11.535 7 -28001 101 3 2
43+
461040.7682 0.0005 -3.2657 2 23.0695 9 -28001 101 4 3
44+
576267.9305 0.0005 -3.0118 2 38.4481 11 -28001 101 5 4
45+
691473.0763 0.0005 -2.8193 2 57.6704 13 -28001 101 6 5
46+
806651.806 0.005 -2.6716 2 80.7354 15 -28001 101 7 6
47+
921799.7 0.005 -2.559 2 107.6424 17 -28001 101 8 7
4848

4949
The following example, with ``get_query_payload = True``, returns the payload:
5050

@@ -54,10 +54,9 @@ The following example, with ``get_query_payload = True``, returns the payload:
5454
... max_frequency=1000 * u.GHz,
5555
... min_strength=-500,
5656
... molecule="28001 CO",
57-
... max_lines = 7,
5857
... get_query_payload=True)
5958
>>> print(response)
60-
[('MinNu', 100.0), ('MaxNu', 1000.0), ('MaxLines', 7), ('UnitNu', 'GHz'), ('StrLim', -500), ('Mol', '28001 CO')]
59+
[('MinNu', 100.0), ('MaxNu', 1000.0), ('MaxLines', 2000), ('UnitNu', 'GHz'), ('StrLim', -500), ('Mol', '28001 CO')]
6160

6261
The units of the columns of the query can be displayed by calling
6362
``response.info``:
@@ -67,15 +66,14 @@ The units of the columns of the query can be displayed by calling
6766
>>> response = JPLSpec.query_lines(min_frequency=100 * u.GHz,
6867
... max_frequency=1000 * u.GHz,
6968
... min_strength=-500,
70-
... molecule="28001 CO",
71-
... max_lines = 7)
69+
... molecule="28001 CO")
7270
>>> print(response.info)
73-
<Table length=7>
71+
<Table length=8>
7472
name dtype unit
7573
----- ------- -------
7674
FREQ float64 MHz
7775
ERR float64 MHz
78-
LGINT float64 MHz nm2
76+
LGINT float64 nm2 MHz
7977
DR int64
8078
ELO float64 1 / cm
8179
GUP int64
@@ -92,18 +90,19 @@ simplified version of the data above is shown below:
9290
>>> print (response['FREQ', 'ERR', 'ELO'])
9391
FREQ ERR ELO
9492
MHz MHz 1 / cm
95-
----------- ------ -------
96-
115271.2018 0.0005 0.0
97-
230538.0 0.0005 3.845
98-
345795.9899 0.0005 11.535
99-
461040.7682 0.0005 23.0695
100-
576267.9305 0.0005 38.4481
101-
691473.0763 0.0005 57.6704
102-
806651.806 0.005 80.7354
93+
----------- ------ --------
94+
115271.2018 0.0005 0.0
95+
230538.0 0.0005 3.845
96+
345795.9899 0.0005 11.535
97+
461040.7682 0.0005 23.0695
98+
576267.9305 0.0005 38.4481
99+
691473.0763 0.0005 57.6704
100+
806651.806 0.005 80.7354
101+
921799.7 0.005 107.6424
103102
>>> response['FREQ'].quantity
104-
<Quantity [115271.2018, 230538. , 345795.9899, 461040.7682, 576267.9305, 691473.0763, 806651.806 ] MHz>
103+
<Quantity [115271.2018, 230538. , 345795.9899, 461040.7682, 576267.9305, 691473.0763, 806651.806 , 921799.7 ] MHz>
105104
>>> response['FREQ'].to('GHz')
106-
<Quantity [115.2712018, 230.538 , 345.7959899, 461.0407682, 576.2679305, 691.4730763, 806.651806 ] GHz>
105+
<Quantity [115.2712018, 230.538 , 345.7959899, 461.0407682, 576.2679305, 691.4730763, 806.651806 , 921.7997 ] GHz>
107106

108107
The parameters and response keys are described in detail under the
109108
Reference/API section.
@@ -219,8 +218,8 @@ to query these directly.
219218
... molecule="H2O",
220219
... parse_name_locally=True)
221220
>>> print(result)
222-
FREQ ERR LGINT DR ELO GUP TAG QNFMT QN' QN"
223-
MHz MHz MHz nm2 1 / cm
221+
FREQ ERR LGINT DR ELO GUP TAG QNFMT QN' QN"
222+
MHz MHz nm2 MHz 1 / cm
224223
----------- -------- -------- --- --------- --- ------ ----- -------- --------
225224
115542.5692 0.6588 -13.2595 3 4606.1683 35 18003 1404 17 810 0 18 513 0
226225
139614.293 0.15 -9.3636 3 3080.1788 87 -18003 1404 14 6 9 0 15 312 0
@@ -235,7 +234,7 @@ response length:
235234
.. doctest-remote-data::
236235

237236
>>> print(result.meta['comments'])
238-
['', '', '', '', '', 'form is currently limited to 2000 lines. Please limit your search.']
237+
['', '', '', '', '', '', '', '', '', '', '', 'form is currently limilted to 2000 lines. Please limit your search.']
239238

240239
Inspecting the returned molecules shows that the 'H2O' string was processed as a
241240
regular expression, and the search matched any molecule that contained the

0 commit comments

Comments
 (0)