Skip to content

Commit f7a3443

Browse files
committed
DOC: properly handle temporary input file for xmatch docs
1 parent 64461a7 commit f7a3443

File tree

1 file changed

+23
-4
lines changed

1 file changed

+23
-4
lines changed

docs/xmatch/xmatch.rst

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,21 +21,33 @@ has the following content::
2121
306.01575,33.86756
2222
322.493,12.16703
2323

24+
.. testsetup::
25+
26+
>>> with open('pos_list.csv', 'w') as f: # doctest: +IGNORE_OUTPUT
27+
... f.write("""ra,dec
28+
... 267.22029,-20.35869
29+
... 274.83971,-25.42714
30+
... 275.92229,-30.36572
31+
... 283.26621,-8.70756
32+
... 306.01575,33.86756
33+
... 322.493,12.16703""")
34+
2435
Next, the xMatch service will be used to find cross matches between the
2536
uploaded file and a VizieR catalogue. The parameters ``cat1`` and ``cat2``
2637
define the catalogues where one of them may point to a local file (in this
2738
example, the CSV file is stored in
28-
``'/tmp/pos_list.csv'``). ``max_distance`` denotes the maximum distance in
39+
``'pos_list.csv'``). ``max_distance`` denotes the maximum distance in
2940
arcsec to look for counterparts; it is used here to limit the number of rows
3041
in the resulting table for demonstration purposes. Finally, ``colRa1`` and
3142
``colDec1`` are used to denote the column names in the input file.
3243

33-
.. code-block:: python
3444
.. doctest-remote-data::
3545

3646
>>> from astropy import units as u
37-
>>> from astroquery.xmatch import XMatch # doctest: +IGNORE_OUTPUT
38-
>>> table = XMatch.query(cat1=open('/tmp/pos_list.csv'),
47+
>>> from astroquery.xmatch import XMatch
48+
>>> from astropy.table import Table
49+
>>> input_table = Table.read('pos_list.csv')
50+
>>> table = XMatch.query(cat1=input_table,
3951
... cat2='vizier:II/246/out',
4052
... max_distance=5 * u.arcsec, colRA1='ra',
4153
... colDec1='dec')
@@ -56,6 +68,13 @@ in the resulting table for demonstration purposes. Finally, ``colRa1`` and
5668
0.853178 322.493 12.16703 21295836+1210007 ... EEA 222 0 2451080.6935
5769
4.50395 322.493 12.16703 21295861+1210023 ... EEE 222 0 2451080.6935
5870

71+
72+
.. testcleanup::
73+
74+
>>> from astroquery.utils import cleanup_saved_downloads
75+
>>> cleanup_saved_downloads(['pos_list.csv'])
76+
77+
5978
Reference/API
6079
=============
6180

0 commit comments

Comments
 (0)