Skip to content

Commit a118b79

Browse files
committed
TST: fixing examples to pass doctesting. Some genuine issues and some formatting and outputs.
1 parent e1bd98a commit a118b79

File tree

1 file changed

+73
-74
lines changed

1 file changed

+73
-74
lines changed

docs/esasky/esasky.rst

Lines changed: 73 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,12 @@ If you know the names of all the available catalogs you can use :meth:`~astroque
2424

2525
>>> from astroquery.esasky import ESASky
2626
>>> catalog_list = ESASky.list_catalogs()
27-
>>> print(catalog_list) # doctest: +IGNORE_OUTPUT
28-
['LAMOST', 'AllWise', 'AKARI-IRC-SC', 'TwoMASS', 'INTEGRAL',
29-
'CHANDRA-SC2', 'XMM-EPIC-STACK', 'XMM-EPIC', 'XMM-OM', 'XMM-SLEW',
30-
'Tycho-2', 'Gaia-eDR3', 'Hipparcos-2', 'HSC', 'Herschel-HPPSC-070',
31-
'Herschel-HPPSC-100', 'Herschel-HPPSC-160', 'Herschel-SPSC-250',
32-
'Herschel-SPSC-350', 'Herschel-SPSC-500','Planck-PGCC',
33-
'Planck-PCCS2E-HFI', 'Planck-PCCS2-HFI', 'Planck-PCCS2-LFI', 'Planck-PSZ2']
27+
>>> print(catalog_list)
28+
['LAMOST_LRS', 'LAMOST_MRS', 'AllWise', 'Spitzer', 'AKARI-IRC-SC', 'TwoMASS', 'INTEGRAL', 'CHANDRA-SC2',
29+
'XMM-EPIC-STACK', 'XMM-EPIC', 'XMM-OM', 'XMM-SLEW', 'Tycho-2', 'Gaia-DR3', 'Hipparcos-2', 'HSC',
30+
'Herschel-HPPSC-070', 'Herschel-HPPSC-100', 'Herschel-HPPSC-160', 'Herschel-SPSC-250', 'Herschel-SPSC-350',
31+
'Herschel-SPSC-500', 'Planck-PGCC', 'Planck-PCCS2E-HFI', 'Planck-PCCS2-HFI', 'Planck-PCCS2-LFI', 'Planck-PSZ2',
32+
'Icecube', 'Fermi_4FGL-DR2', 'Fermi_3FHL', 'Fermi_4LAC-DR2', '2WHSP', '2RXS', 'OU_Blazars']
3433

3534
Get the available maps mission names
3635
------------------------------------
@@ -40,10 +39,9 @@ If you know the names of all the available maps missions you can use :meth:`~ast
4039
.. doctest-remote-data::
4140

4241
>>> maps_list = ESASky.list_maps()
43-
>>> print(maps_list) # doctest: +IGNORE_OUTPUT
44-
['INTEGRAL', 'XMM', 'Chandra', 'SUZAKU', 'XMM-OM-OPTICAL',
45-
'XMM-OM-UV', 'HST-UV', 'HST-OPTICAL', 'HST-IR', 'ISO-IR',
46-
'Herschel', 'AKARI', 'Spitzer', 'ALMA']
42+
>>> print(maps_list)
43+
['INTEGRAL', 'XMM', 'Chandra', 'SUZAKU', 'XMM-OM-OPTICAL', 'XMM-OM-UV', 'HST-UV', 'HST-OPTICAL', 'HST-IR',
44+
'ISO-IR', 'Herschel', 'AKARI', 'JWST-MID-IR', 'JWST-NEAR-IR', 'Spitzer', 'ALMA']
4745

4846
Get the available spectra mission names
4947
---------------------------------------
@@ -53,9 +51,9 @@ If you know the names of all the available spectra you can use :meth:`~astroquer
5351
.. doctest-remote-data::
5452

5553
>>> spectra_list = ESASky.list_spectra()
56-
>>> print(spectra_list) # doctest: +IGNORE_OUTPUT
57-
['XMM-NEWTON', 'Chandra', 'IUE', 'HST-UV', 'HST-OPTICAL',
58-
'HST-IR', 'ISO-IR', 'Herschel', 'LAMOST']
54+
>>> print(spectra_list)
55+
['XMM-NEWTON', 'Chandra', 'IUE', 'HST-UV', 'HST-OPTICAL', 'JWST-MID-IR', 'JWST-NEAR-IR', 'HST-IR', 'ISO-IR',
56+
'Herschel', 'LAMOST_LRS', 'LAMOST_MRS', 'CHEOPS']
5957

6058
Get the available SSO mission names
6159
-----------------------------------
@@ -67,7 +65,7 @@ If you know the names of all the available missions with SSO cross match data, y
6765

6866
>>> sso_list = ESASky.list_sso()
6967
>>> print(sso_list)
70-
['Herschel', 'HST', 'XMM']
68+
['Herschel', 'HST', 'XMM', 'XMM-OM']
7169

7270

7371
Query an object
@@ -87,38 +85,38 @@ For instance to query an object around M51 in the Hubble catalog:
8785
.. doctest-remote-data::
8886

8987
>>> from astroquery.esasky import ESASky
90-
>>> result = ESASky.query_object_catalogs(position="M51", missions="HSC")
88+
>>> result = ESASky.query_object_catalogs(position="M51", catalogs="HSC")
9189

9290
Note that the catalog may also be specified as a list.
9391
So the above query may also be written as:
9492

9593
.. doctest-remote-data::
9694

97-
>>> result = ESASky.query_object_catalogs(position="M51", missions=["HSC", "XMM-OM"])
95+
>>> result = ESASky.query_object_catalogs(position="M51", catalogs=["HSC", "XMM-OM"])
9896

9997
To search in all available catalogs you can write ``"all"`` instead of a catalog name. The same thing will happen if you
10098
don't write any catalog name.
10199

102100
.. doctest-remote-data::
103101

104-
>>> result = ESASky.query_object_catalogs(position="M51", missions="all")
102+
>>> result = ESASky.query_object_catalogs(position="M51", catalogs="all")
105103
>>> result = ESASky.query_object_catalogs(position="M51")
106104

107105
To see the result:
108106

109107
.. doctest-remote-data::
110108

111109
>>> print(result)
112-
TableList with 9 tables:
113-
'0:ALLWISE' with 13 column(s) and 1 row(s)
114-
'1:TWOMASS' with 9 column(s) and 3 row(s)
115-
'2:CHANDRA-SC2' with 41 column(s) and 9 row(s)
116-
'3:XMM-EPIC-STACK' with 13 column(s) and 1 row(s)
117-
'4:XMM-EPIC' with 14 column(s) and 11 row(s)
118-
'5:XMM-OM' with 11 column(s) and 5 row(s)
119-
'6:HSC' with 9 column(s) and 230 row(s)
120-
'7:HERSCHEL-HPPSC-070' with 15 column(s) and 1 row(s)
121-
'8:HERSCHEL-HPPSC-100' with 15 column(s) and 1 row(s)
110+
TableList with 9 tables:
111+
'0:ALLWISE' with 25 column(s) and 1 row(s)
112+
'1:TWOMASS' with 14 column(s) and 3 row(s)
113+
'2:CHANDRA-SC2' with 41 column(s) and 9 row(s)
114+
'3:XMM-EPIC-STACK' with 347 column(s) and 1 row(s)
115+
'4:XMM-EPIC' with 223 column(s) and 12 row(s)
116+
'5:XMM-OM' with 122 column(s) and 5 row(s)
117+
'6:HSC' with 27 column(s) and 230 row(s)
118+
'7:HERSCHEL-HPPSC-070' with 21 column(s) and 1 row(s)
119+
'8:HERSCHEL-HPPSC-100' with 21 column(s) and 1 row(s)
122120

123121
All the results are returned as a `~astroquery.utils.TableList` object. This is a container for `~astropy.table.Table`
124122
objects. It is basically an extension to `~collections.OrderedDict` for storing a `~astropy.table.Table` against its
@@ -129,7 +127,7 @@ To access an individual table from the `~astroquery.utils.TableList` object
129127
.. doctest-remote-data::
130128

131129
>>> interesting_table = result['ALLWISE']
132-
>>> print(interesting_table)
130+
>>> print(interesting_table) # doctest: +IGNORE_OUTPUT
133131
name ra dec ... w3mpro_error w4mpro w4mpro_error
134132
deg deg ... mag mag mag
135133
------------------- ----------- ---------- ... ------------ ------ ------------
@@ -158,6 +156,7 @@ The parameters are interchangeable in the same way as in :meth:`~astroquery.esas
158156

159157
Query a region
160158
--------------
159+
161160
The region queries work in a similar way as query_object, except that you must choose a radius as well. There are three
162161
query region methods in this module :meth:`astroquery.esasky.ESASkyClass.query_region_catalogs`,
163162
:meth:`astroquery.esasky.ESASkyClass.query_region_maps`, and :meth:`astroquery.esasky.ESASkyClass.query_region_spectra`.
@@ -172,52 +171,43 @@ value for the radius of the region. For instance to query region around M51 in t
172171

173172
>>> from astroquery.esasky import ESASky
174173
>>> import astropy.units as u
175-
>>> result = ESASky.query_region_catalogs(position="M51", radius=10 * u.arcmin, catalogs="HSC")
176-
177-
Note that the catalog may also be specified as a list. So the above query may also be written as:
178-
179-
.. doctest-remote-data::
180-
181174
>>> result = ESASky.query_region_catalogs(position="M51", radius=10 * u.arcmin, catalogs=["HSC", "XMM-OM"])
182175

183176
To search in all available catalogs you can write ``"all"`` instead of a catalog name. The same thing will happen if you
184177
don't write any catalog name.
178+
In the same manner, the radius can be specified with either a string or any `~astropy.units.Quantity`.
185179

186180
.. doctest-remote-data::
187181

188182
>>> result = ESASky.query_region_catalogs(position="M51", radius=10 * u.arcmin, catalogs="all")
189-
>>> result = ESASky.query_region_catalogs(position="M51", radius=10 * u.arcmin)
190-
191-
In the same manner, the radius can be specified with either a string or any `~astropy.units.Quantity`
192-
193-
.. doctest-remote-data::
194-
195183
>>> result = ESASky.query_region_catalogs(position="M51", radius="10 arcmin")
196184

197185
To see the result:
198186

199187
.. doctest-remote-data::
200188

201189
>>> print(result)
202-
TableList with 18 tables:
203-
'0:LAMOST' with 21 column(s) and 41 row(s)
204-
'1:ALLWISE' with 13 column(s) and 1762 row(s)
205-
'2:AKARI-IRC-SC' with 13 column(s) and 1 row(s)
206-
'3:TWOMASS' with 9 column(s) and 188 row(s)
207-
'4:CHANDRA-SC2' with 41 column(s) and 430 row(s)
208-
'5:XMM-EPIC-STACK' with 13 column(s) and 214 row(s)
209-
'6:XMM-EPIC' with 14 column(s) and 823 row(s)
210-
'7:XMM-OM' with 11 column(s) and 4849 row(s)
211-
'8:XMM-SLEW' with 9 column(s) and 2 row(s)
212-
'9:GAIA-EDR3' with 20 column(s) and 932 row(s)
213-
'10:HSC' with 9 column(s) and 10000 row(s)
214-
'11:HERSCHEL-HPPSC-070' with 15 column(s) and 93 row(s)
215-
'12:HERSCHEL-HPPSC-100' with 15 column(s) and 122 row(s)
216-
'13:HERSCHEL-HPPSC-160' with 15 column(s) and 93 row(s)
217-
'14:HERSCHEL-SPSC-250' with 16 column(s) and 59 row(s)
218-
'15:HERSCHEL-SPSC-350' with 16 column(s) and 24 row(s)
219-
'16:HERSCHEL-SPSC-500' with 16 column(s) and 7 row(s)
220-
'17:PLANCK-PCCS2-HFI' with 8 column(s) and 8 row(s)
190+
TableList with 20 tables:
191+
'0:LAMOST_LRS' with 43 column(s) and 37 row(s)
192+
'1:ALLWISE' with 25 column(s) and 1762 row(s)
193+
'2:SPITZER' with 146 column(s) and 1082 row(s)
194+
'3:AKARI-IRC-SC' with 29 column(s) and 1 row(s)
195+
'4:TWOMASS' with 14 column(s) and 188 row(s)
196+
'5:CHANDRA-SC2' with 41 column(s) and 430 row(s)
197+
'6:XMM-EPIC-STACK' with 347 column(s) and 225 row(s)
198+
'7:XMM-EPIC' with 223 column(s) and 941 row(s)
199+
'8:XMM-OM' with 122 column(s) and 4849 row(s)
200+
'9:XMM-SLEW' with 106 column(s) and 2 row(s)
201+
'10:GAIA-DR3' with 153 column(s) and 932 row(s)
202+
'11:HSC' with 27 column(s) and 10000 row(s)
203+
'12:HERSCHEL-HPPSC-070' with 21 column(s) and 93 row(s)
204+
'13:HERSCHEL-HPPSC-100' with 21 column(s) and 122 row(s)
205+
'14:HERSCHEL-HPPSC-160' with 21 column(s) and 93 row(s)
206+
'15:HERSCHEL-SPSC-250' with 36 column(s) and 59 row(s)
207+
'16:HERSCHEL-SPSC-350' with 36 column(s) and 24 row(s)
208+
'17:HERSCHEL-SPSC-500' with 36 column(s) and 7 row(s)
209+
'18:PLANCK-PCCS2-HFI' with 9 column(s) and 8 row(s)
210+
'19:2RXS' with 306 column(s) and 2 row(s)
221211

222212
You can use, :meth:`~astroquery.esasky.ESASkyClass.query_region_maps` and
223213
:meth:`~astroquery.esasky.ESASkyClass.query_region_maps` with the same parameters. To execute the same command as above
@@ -241,8 +231,11 @@ If you already know the observation ID's or source names of interest, you can ge
241231
.. doctest-remote-data::
242232

243233
>>> maps = ESASky.query_ids_maps(observation_ids=["lbsk03vbq", "ieag90010"], missions="HST-UV")
234+
INFO: Retrieving tables... [astroquery.utils.tap.core]
235+
INFO: Parsing tables... [astroquery.utils.tap.core]
236+
INFO: Done. [astroquery.utils.tap.core]
244237
>>> catalogs = ESASky.query_ids_catalogs(source_ids=["2CXO J090341.1-322609", "2CXO J090353.8-322642",
245-
"44899", "45057"], catalogs=["CHANDRA-SC2", "Hipparcos-2"])
238+
... "44899", "45057"], catalogs=["CHANDRA-SC2", "Hipparcos-2"])
246239
>>> spectra = ESASky.query_ids_spectra(observation_ids="0001730501")
247240

248241
If you already know which missions you are interested in, it is recommended to explicitly mention them in the mission
@@ -264,7 +257,7 @@ HDUList is the value.
264257
.. doctest-remote-data::
265258

266259
>>> from astroquery.esasky import ESASky
267-
>>> images = ESASky.get_images(position="m51", radius="20 arcmin", missions=['Herschel', 'ISO-IR']) # doctest: +IGNORE_OUTPUT
260+
>>> images = ESASky.get_images(position="m51", radius="20 arcmin", missions=['Herschel', 'ISO-IR']) # doctest: +IGNORE_WARNINGS +IGNORE_OUTPUT
268261
Starting download of HERSCHEL data. (25 files)
269262
Downloading Observation ID: 1342188589 from http://archives.esac.esa.int/hsa/whsa-tap-server/data?RETRIEVAL_TYPE=STANDALONE&observation_oid=8618001&DATA_RETRIEVAL_ORIGIN=UI [Done]
270263
Downloading Observation ID: 1342188328 from http://archives.esac.esa.int/hsa/whsa-tap-server/data?RETRIEVAL_TYPE=STANDALONE&observation_oid=8637833&DATA_RETRIEVAL_ORIGIN=UI
@@ -281,16 +274,11 @@ parameter observation_id instead of target and position.
281274

282275
.. doctest-remote-data::
283276

284-
>>> from astroquery.esasky import ESASky
285-
>>> images = ESASky.get_images(position="m51", radius="20 arcmin", missions=['Herschel', 'ISO-IR'])
277+
>>> images = ESASky.get_images(observation_ids=["100001010", "01500403"], missions=["SUZAKU", "ISO-IR"]) # doctest: +IGNORE_WARNINGS +IGNORE_OUTPUT
286278

287279
Note that the fits files also are stored to disk. By default they are saved to the working directory but the location
288-
can be chosen by the download_dir parameter:
280+
can be chosen by the download_dir parameter.
289281

290-
.. doctest-remote-data::
291-
292-
>>> images = ESASky.get_images(observation_ids="100001010", missions="SUZAKU")
293-
>>> images = ESASky.get_images(observation_ids=["100001010", "01500403"], missions=["SUZAKU", "ISO-IR"])
294282

295283
Get maps
296284
--------
@@ -300,17 +288,18 @@ You can also fetch images using :meth:`astroquery.esasky.ESASkyClass.get_maps`.
300288
position, radius and missions.
301289

302290

291+
.. Skip testing examples with with hard-wired download dir values
303292
.. doctest-remote-data::
304293

305294
>>> table_list = ESASky.query_region_maps(position="m51", radius="20 arcmin", missions=['Herschel', 'ISO-IR'])
306-
>>> images = ESASky.get_maps(query_table_list=table_list, download_dir="/home/user/esasky")
295+
>>> images = ESASky.get_maps(query_table_list=table_list, download_dir="/home/user/esasky") # doctest: +SKIP
307296

308297
This example is equivalent to:
309298

310299
.. doctest-remote-data::
311300

312301
>>> images = ESASky.get_images(position="m51", radius="20 arcmin", missions=['Herschel', 'ISO-IR'],
313-
... download_dir="/home/user/esasky")
302+
... download_dir="/home/user/esasky") # doctest: +SKIP
314303

315304

316305
Get spectra
@@ -323,19 +312,20 @@ There are also two methods to download spectra: :meth:`astroquery.esasky.ESASkyC
323312
The methods returns a `dict` to separate the different missions. All mission except Herschel returns a list of
324313
`~astropy.io.fits.HDUList`. Herschel returns a three-level dictionary.
325314

315+
.. TODO: Skipping for now as it keeps timinig out. Needs fixing
326316
.. doctest-remote-data::
327317

328318
>>> from astroquery.esasky import ESASky
329-
>>> spectra = ESASky.get_spectra(position="m51", radius="20 arcmin", missions=['Herschel', 'XMM-NEWTON'])
330-
>>> spectra = ESASky.get_spectra(observation_ids=["02101201", "z1ax0102t"], missions=["ISO-IR", "HST-UV"])
319+
>>> spectra = ESASky.get_spectra(position="m51", radius="20 arcmin", missions=['Herschel', 'XMM-NEWTON']) # doctest: +SKIP
320+
>>> spectra = ESASky.get_spectra(observation_ids=["02101201", "z1ax0102t"], missions=["ISO-IR", "HST-UV"]) # doctest: +IGNORE_OUTPUT
331321

332322
or
333323

334324
.. doctest-remote-data::
335325

336326
>>> table_list = ESASky.query_region_spectra(position="m51", radius="20 arcmin",
337327
... missions=['Herschel', 'XMM-NEWTON'])
338-
>>> spectra = ESASky.get_spectra_from_table(query_table_list=table_list, download_dir="/home/user/esasky")
328+
>>> spectra = ESASky.get_spectra_from_table(query_table_list=table_list)
339329
dict: {
340330
'HERSCHEL': {'1342211195': {'red' : {'HPSTBRRS' : HDUList}, 'blue' : {'HPSTBRBS': HDUList},
341331
'1342180796': {'WBS' : {'WBS-H_LSB_5a' : HDUList}, 'HRS' : {'HRS-H_LSB_5a': HDUList},
@@ -356,6 +346,15 @@ Here is another example for Herschel, since it is a bit special:
356346
>>> spectra = ESASky.get_spectra_from_table(query_table_list=[('HERSCHEL', herschel_result)], download_dir='Spectra_new')
357347
>>> spectra['HERSCHEL']['1342211195']['red'].keys()
358348
>>> spectra['HERSCHEL']['1342211195']['red']['HPSTBRRS'].info()
349+
observation_id target_name instrument observing_mode_name band duration
350+
seconds
351+
-------------- ------------ ---------- ------------------------ ------------------- ---------
352+
1342180479 M51 HIFI HifiMappingModeDBSRaster 555.45-571.56 GHz 8014.085
353+
1342211195 m51 strip2-1 PACS PacsLineSpec 62.96-190.85 micron 1254.0
354+
1342211188 m51 PACS PacsLineSpec 52.15-159.67 micron 5597.0
355+
1342180478 M51 HIFI HifiMappingModeOTF 562.54-578.65 GHz 4012.741
356+
...
357+
359358

360359
Solar System Object Crossmatch
361360
------------------------------

0 commit comments

Comments
 (0)