Skip to content

Commit c77be56

Browse files
committed
DOC: fixing the remaining doctest and cleanup
1 parent 81be498 commit c77be56

File tree

1 file changed

+59
-17
lines changed

1 file changed

+59
-17
lines changed

docs/esasky/esasky.rst

Lines changed: 59 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
.. _astroquery.esasky:
22

3+
.. testsetup::
4+
5+
>>> # Dealing with the openfile warnings here, globally rather than in the snippets below.
6+
>>> import warnings
7+
>>> warnings.filterwarnings("ignore", category=ResourceWarning, message="unclosed file")
8+
9+
310
************************************
411
ESASky Queries (`astroquery.esasky`)
512
************************************
@@ -257,11 +264,10 @@ HDUList is the value.
257264
.. doctest-remote-data::
258265

259266
>>> from astroquery.esasky import ESASky
260-
>>> images = ESASky.get_images(position="V* HT Aqr", radius="15 arcmin", missions=['Herschel', 'ISO-IR']) # doctest: +IGNORE_WARNINGS
261-
262-
Starting download of HERSCHEL data. (6 files)
263-
Downloading Observation ID: 1342220557 from http://archives.esac.esa.int/hsa/whsa-tap-server/data?RETRIEVAL_TYPE=STANDALONE&observation_oid=8628906&DATA_RETRIEVAL_ORIGIN=UI [Done]
264-
Downloading Observation ID: 1342221178 from http://archives.esac.esa.int/hsa/whsa-tap-server/data?RETRIEVAL_TYPE=STANDALONE&observation_oid=8628962&DATA_RETRIEVAL_ORIGIN=UI
267+
>>> images = ESASky.get_images(position="V* HT Aqr", radius="15 arcmin", missions=['Herschel', 'ISO-IR']) # doctest: +IGNORE_OUTPUT
268+
INFO: Starting download of HERSCHEL data. (6 files)
269+
INFO: Downloading Observation ID: 1342220557 from http://archives.esac.esa.int/hsa/whsa-tap-server/data?RETRIEVAL_TYPE=STANDALONE&observation_oid=8628906&DATA_RETRIEVAL_ORIGIN=UI [Done]
270+
INFO: Downloading Observation ID: 1342221178 from http://archives.esac.esa.int/hsa/whsa-tap-server/data?RETRIEVAL_TYPE=STANDALONE&observation_oid=8628962&DATA_RETRIEVAL_ORIGIN=UI
265271
...
266272
>>> print(images) # doctest: +IGNORE_OUTPUT
267273
{
@@ -275,8 +281,10 @@ parameter observation_id instead of target and position.
275281

276282
.. doctest-remote-data::
277283

278-
>>> images = ESASky.get_images(observation_ids="100001010", missions="SUZAKU") # doctest: +IGNORE_WARNINGS
279284
>>> images = ESASky.get_images(observation_ids=["100001010", "01500403"], missions=["SUZAKU", "ISO-IR"])
285+
INFO: Starting download of SUZAKU data. (1 files) [astroquery.esasky.core]
286+
INFO: Starting download of ISO-IR data. (1 files) [astroquery.esasky.core]
287+
...
280288

281289
Note that the fits files also are stored to disk. By default they are saved to the working directory but the location
282290
can be chosen by the download_dir parameter.
@@ -300,7 +308,7 @@ This example is equivalent to:
300308
.. doctest-remote-data::
301309

302310
>>> images = ESASky.get_images(position="V* HT Aqr", radius="15 arcmin", missions=['Herschel', 'ISO-IR'],
303-
download_dir="/home/user/esasky") # doctest: +SKIP
311+
... download_dir="/home/user/esasky") # doctest: +SKIP
304312

305313

306314
Get spectra
@@ -313,21 +321,23 @@ There are also two methods to download spectra: :meth:`astroquery.esasky.ESASkyC
313321
The methods returns a `dict` to separate the different missions. All mission except Herschel returns a list of
314322
`~astropy.io.fits.HDUList`. Herschel returns a three-level dictionary.
315323

316-
.. TODO: Skipping for now as it keeps timinig out. Needs fixing
317324
.. doctest-remote-data::
318325

319326
>>> from astroquery.esasky import ESASky
320327
>>> spectra = ESASky.get_spectra(position="Gaia DR3 4512810408088819712", radius="6.52 arcmin",
321-
missions=['Herschel', 'XMM-NEWTON'])
328+
... missions=['Herschel', 'XMM-NEWTON']) # doctest: +IGNORE_OUTPUT
322329
>>> spectra = ESASky.get_spectra(observation_ids=["02101201", "z1ax0102t"], missions=["ISO-IR", "HST-UV"])
330+
INFO: Starting download of ISO-IR data. (1 files) [astroquery.esasky.core]
331+
INFO: Starting download of HST-UV data. (1 files) [astroquery.esasky.core]
332+
...
323333

324334
or
325335

326336
.. doctest-remote-data::
327337

328338
>>> table_list = ESASky.query_region_spectra(position="Gaia DR3 4512810408088819712", radius="6.52 arcmin",
329-
missions=['Herschel', 'XMM-NEWTON'])
330-
>>> spectra = ESASky.get_spectra_from_table(query_table_list=table_list, download_dir="/home/user/esasky")
339+
... missions=['Herschel', 'XMM-NEWTON'])
340+
>>> spectra = ESASky.get_spectra_from_table(query_table_list=table_list, download_dir="/home/user/esasky") # doctest: +SKIP
331341
dict: {
332342
'HERSCHEL': {'1342244919': {'red' : {'HPSTBRRS' : HDUList}, 'blue' : {'HPSTBRBS': HDUList},
333343
'1342243607': {'SSW+SLW' : {'SPSS' : HDUList},
@@ -344,9 +354,25 @@ Here is another example for Herschel, since it is a bit special:
344354
>>> result = ESASky.query_region_spectra(position='[SMB88] 6327', radius='1 arcmin', missions=['HERSCHEL'])
345355
>>> herschel_result = result['HERSCHEL']
346356
>>> herschel_result['observation_id', 'target_name', 'instrument', 'observing_mode_name', 'band', 'duration'].pprint()
347-
>>> spectra = ESASky.get_spectra_from_table(query_table_list=[('HERSCHEL', herschel_result)], download_dir='Spectra_new')
357+
observation_id target_name instrument ... band duration
358+
... seconds
359+
-------------- -------------------- ---------- ... -------------- --------
360+
1342249066 HATLAS-NGP-NA.V1.144 SPIRE ... 191-671 micron 13752.0
361+
>>>
362+
>>> spectra = ESASky.get_spectra_from_table(query_table_list=[('HERSCHEL', herschel_result)], download_dir='Spectra_new') # doctest: +IGNORE_OUTPUT
348363
>>> spectra['HERSCHEL']['1342249066']['SSW+SLW'].keys()
364+
dict_keys(['SPSS'])
349365
>>> spectra['HERSCHEL']['1342249066']['SSW+SLW']['SPSS'].info()
366+
Filename: Spectra_new/HERSCHEL/...
367+
No. Name Ver Type Cards Dimensions Format
368+
0 PRIMARY 1 PrimaryHDU 404 ()
369+
1 0000 1 ImageHDU 58 ()
370+
2 SLWB2 1 BinTableHDU 90 1905R x 5C [1D, 1D, 1D, 1J, 1J]
371+
3 SLWB3 1 BinTableHDU 90 1905R x 5C [1D, 1D, 1D, 1J, 1J]
372+
4 SLWC2 1 BinTableHDU 90 1905R x 5C [1D, 1D, 1D, 1J, 1J]
373+
5 SLWC3 1 BinTableHDU 90 1905R x 5C [1D, 1D, 1D, 1J, 1J]
374+
6 SLWC4 1 BinTableHDU 90 1905R x 5C [1D, 1D, 1D, 1J, 1J]
375+
...
350376

351377

352378
Solar System Object Crossmatch
@@ -370,8 +396,10 @@ type of the desired object. For example:
370396
.. doctest-remote-data::
371397

372398
>>> from astroquery.esasky import ESASky
373-
>>> ESASky.query_sso(sso_name="503")
374-
INFO: Found 4 SSO's with name: 503.
399+
>>> ESASky.query_sso(sso_name="503") # doctest: +IGNORE_EXCEPTION_DETAIL
400+
Traceback (most recent call last):
401+
...
402+
ValueError: Found 4 SSO's with name: 503.
375403
Try narrowing your search by typing a more specific sso_name.
376404
You can also narrow your search by specifying the sso_type.
377405
Allowed values are ALL, ASTEROID, COMET, SATELLITE, PLANET, DWARF_PLANET, SPACECRAFT, SPACEJUNK, EXOPLANET, STAR.
@@ -388,15 +416,17 @@ In this case, you can specify the sso_type
388416

389417
>>> from astroquery.esasky import ESASky
390418
>>> ESASky.query_sso(sso_name="503", sso_type="SATELLITE")
391-
419+
TableList with 2 tables:
420+
'0:HST' with 45 column(s) and 618 row(s)
421+
'1:XMM' with 45 column(s) and 33 row(s)
392422

393423
You can see the available missions with:
394424

395425
.. doctest-remote-data::
396426

397427
>>> from astroquery.esasky import ESASky
398428
>>> ESASky.list_sso()
399-
429+
['Herschel', 'HST', 'XMM', 'XMM-OM']
400430

401431
Other parameters and the return value are structured in the same manner as the other query methods.
402432

@@ -411,14 +441,19 @@ are the same. You can for example, download a table list just like in get_maps b
411441
>>> table_list_from_query_maps=ESASky.query_sso(sso_name="ganymede", missions="XMM")
412442
>>> table_list_from_query_maps['XMM'].remove_rows(list(range(0, 32)))
413443
>>> images=ESASky.get_images_sso(table_list=table_list_from_query_maps)
444+
INFO: Starting download of XMM data. (1 files) [astroquery.esasky.core]
445+
...
414446

415447
Or download everything on an SSO by something like this:
416448

417449
.. doctest-remote-data::
418450

419451
>>> from astroquery.esasky import ESASky
420452
>>> images=ESASky.get_images_sso(sso_name="2017 RN65")
421-
453+
INFO: Starting download of HERSCHEL data. (1 files) [astroquery.esasky.core]
454+
INFO: Starting download of HST data. (1 files) [astroquery.esasky.core]
455+
INFO: Starting download of XMM data. (1 files) [astroquery.esasky.core]
456+
...
422457

423458
This module also offers access to IMCCE's SsODNet resolver, which allows you to find solar and extra solar system
424459
objects with a given name. Here you can see all matches and there aliases and types. You can use this method to help you
@@ -430,6 +465,13 @@ specify which SSO you are after. Use :meth:`astroquery.esasky.ESASkyClass.find_s
430465
>>> list_of_matches=ESASky.find_sso(sso_name="Io")
431466

432467

468+
469+
.. testcleanup::
470+
471+
>>> from astroquery.utils import cleanup_saved_downloads
472+
>>> cleanup_saved_downloads(['Spectra_new'])
473+
474+
433475
Reference/API
434476
=============
435477

0 commit comments

Comments
 (0)