Skip to content

Commit b848920

Browse files
committed
Test all code blocks except plots.
1 parent 4d54b64 commit b848920

File tree

1 file changed

+70
-77
lines changed

1 file changed

+70
-77
lines changed

docs/jplspec/jplspec.rst

Lines changed: 70 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ The units of the columns of the query can be displayed by calling
7171
... max_lines = 7)
7272
>>> print(response.info)
7373
<Table length=7>
74-
name dtype unit
74+
name dtype unit
7575
----- ------- -------
7676
FREQ float64 MHz
7777
ERR float64 MHz
@@ -213,108 +213,101 @@ to query these directly.
213213

214214
>>> from astroquery.jplspec import JPLSpec
215215
>>> import astropy.units as u
216-
>>> response = JPLSpec.query_lines_async(min_frequency=100 * u.GHz,
217-
... max_frequency=1000 * u.GHz,
218-
... min_strength=-500,
219-
... molecule="H2O",
220-
... parse_name_locally=True)
216+
>>> result = JPLSpec.query_lines(min_frequency=100 * u.GHz,
217+
... max_frequency=1000 * u.GHz,
218+
... min_strength=-500,
219+
... molecule="H2O",
220+
... parse_name_locally=True)
221+
>>> print([1, 2, 3]) # doctest: +ELLIPSIS
222+
[1, ... 3]
223+
>>> print(result) # doctest: +ELLIPSIS
224+
FREQ ERR LGINT DR ELO GUP TAG QNFMT QN' QN"
225+
MHz MHz MHz nm2 1 / cm
226+
----------- -------- -------- --- --------- --- ------ ----- -------- --------
227+
115542.5692 0.6588 -13.2595 3 4606.1683 35 18003 1404 17 810 0 18 513 0
228+
139614.293 0.15 -9.3636 3 3080.1788 87 -18003 1404 14 6 9 0 15 312 0
229+
177317.068 0.15 -10.3413 3 3437.2774 31 -18003 1404 15 610 0 16 313 0
230+
183310.087 0.001 -3.6463 3 136.1639 7 -18003 1404 3 1 3 0 2 2 0 0
231+
...
232+
Length = 2000 rows
233+
234+
Searches like these can lead to very broad queries, and may be limited in
235+
response length:
221236

222-
Searches like these can lead to very broad queries. Since the table yields
223-
extensive results, we will only show a dictionary of the tags that
224-
went into the payload to create a response:
237+
.. doctest-remote-data::
225238

239+
>>> print(result.meta['comments'])
240+
['', '', '', '', '', 'form is currently limited to 2000 lines. Please limit your search.']
226241

227-
.. We don't get these dictionaries as reponses, fix these examples and
228-
remove skip. #2408
242+
Inspecting the returned molecules shows that the 'H2O' string was processed as a
243+
regular expression, and the search matched any molecule that contained the
244+
combination of characters 'H2O':
229245

230-
.. doctest-skip::
246+
.. doctest-remote-data::
231247

232-
>>> {'CH2OO': 46014,
233-
... 'H2O': 18003,
234-
... 'H2O v2,2v2,v': 18005,
235-
... 'H2O-17': 19003,
236-
... 'H2O-18': 20003,
237-
... 'H2O2': 34004,
238-
... 'HCCCH2OD': 57003,
239-
... 'HCCCH2OH': 56010,
240-
... 'HCOCH2OH': 60006,
241-
... 'NH2CH2CH2OH': 61004}
242-
243-
As you can see, the 'H2O' string was processed as a regular expression,
244-
and the search matched any molecule that contained the combination of
245-
characters 'H20'.
248+
>>> tags = set(abs(result['TAG'])) # discard negative signs
249+
>>> species = {species: tag
250+
... for (species, tag) in JPLSpec.lookup_ids.items()
251+
... if tag in tags}
252+
>>> print(species)
253+
{'H2O': 18003, 'H2O v2,2v2,v': 18005, 'H2O-17': 19003, 'H2O-18': 20003, 'H2O2': 34004}
246254

247255
A few examples that show the power of the regex option are the following:
248256

249257
.. doctest-remote-data::
250258

251-
>>> response = JPLSpec.query_lines_async(min_frequency=100 * u.GHz,
252-
... max_frequency=1000 * u.GHz,
253-
... min_strength=-500,
254-
... molecule="H2O$",
255-
... parse_name_locally=True)
256-
257-
258-
The response:
259-
260-
.. doctest-skip::
261-
262-
>>> {'H2O': 18003}
263-
259+
>>> result = JPLSpec.query_lines(min_frequency=100 * u.GHz,
260+
... max_frequency=1000 * u.GHz,
261+
... min_strength=-500,
262+
... molecule="H2O$",
263+
... parse_name_locally=True)
264+
>>> tags = set(abs(result['TAG'])) # discard negative signs
265+
>>> species = {species: tag
266+
... for (species, tag) in JPLSpec.lookup_ids.items()
267+
... if tag in tags}
268+
>>> print(species)
269+
{'H2O': 18003}
264270

265271
As seen above, the regular expression "H2O$" yields only an exact match because
266272
the special character $ matches the end of the line. This functionality allows
267273
you to be as specific or vague as you want to allow the results to be:
268274

269275
.. doctest-remote-data::
270276

271-
>>> from astroquery.jplspec import JPLSpec
272-
>>> import astropy.units as u
273-
>>> response = JPLSpec.query_lines_async(min_frequency=100 * u.GHz,
274-
... max_frequency=1000 * u.GHz,
275-
... min_strength=-500,
276-
... molecule="^H.O$",
277-
... parse_name_locally=True)
277+
>>> result = JPLSpec.query_lines(min_frequency=100 * u.GHz,
278+
... max_frequency=1000 * u.GHz,
279+
... min_strength=-500,
280+
... molecule="^H.O$",
281+
... parse_name_locally=True)
282+
>>> tags = set(abs(result['TAG'])) # discard negative signs
283+
>>> species = {species: tag
284+
... for (species, tag) in JPLSpec.lookup_ids.items()
285+
... if tag in tags}
286+
>>> print(species)
287+
{'H2O': 18003, 'HDO': 19002, 'HCO': 29004, 'HNO': 31005}
278288

279289

280290
This pattern matches any word that starts with an H, ends with an O, and
281-
contains any character in between, it results in the following molecules
282-
being queried:
283-
284-
.. doctest-skip::
285-
286-
>>> {'H2O': 18003,
287-
... 'HDO': 19002
288-
... 'HCO': 29004
289-
... 'HNO': 31005 }
290-
291+
contains any character in between.
291292

292293
Another example of the functionality of this option is the option to obtain
293294
results from a molecule and its isotopes, in this case H2O and HDO:
294295

295296
.. doctest-remote-data::
296297

297-
>>> from astroquery.jplspec import JPLSpec
298-
>>> import astropy.units as u
299-
>>> response = JPLSpec.query_lines_async(min_frequency=100 * u.GHz,
300-
... max_frequency=1000 * u.GHz,
301-
... min_strength=-500,
302-
... molecule=r"^H[2D]O(-\d\d|)$",
303-
... parse_name_locally=True)
304-
305-
306-
This pattern matches any H2O and HDO isotopes and it results in the following
307-
molecules being part of the payload:
308-
309-
.. doctest-skip::
310-
311-
>>> {'H2O': 18003,
312-
... 'H2O-17': 19003,
313-
... 'H2O-18': 20003,
314-
... 'HDO': 19002,
315-
... 'HDO-18': 21001}
316-
317-
Remember to print your response to see the table of your results.
298+
>>> result = JPLSpec.query_lines(min_frequency=100 * u.GHz,
299+
... max_frequency=1000 * u.GHz,
300+
... min_strength=-500,
301+
... molecule=r"^H[2D]O(-\d\d|)$",
302+
... parse_name_locally=True)
303+
>>> tags = set(abs(result['TAG'])) # discard negative signs
304+
>>> species = {species: tag
305+
... for (species, tag) in JPLSpec.lookup_ids.items()
306+
... if tag in tags}
307+
>>> print(species)
308+
{'H2O': 18003, 'HDO': 19002, 'H2O-17': 19003, 'H2O-18': 20003, 'HDO-18': 21001}
309+
310+
This pattern matches any H2O and HDO isotopes.
318311

319312

320313
Reference/API

0 commit comments

Comments
 (0)