Skip to content

Commit

Permalink
Merge pull request #3122 from snbianco/ASB-28019-doctests
Browse files Browse the repository at this point in the history
Reduce running time for MAST doctests
  • Loading branch information
bsipocz authored Oct 23, 2024
2 parents 3e26521 + 701a4e3 commit 147546c
Show file tree
Hide file tree
Showing 3 changed files with 95 additions and 74 deletions.
34 changes: 25 additions & 9 deletions docs/mast/mast_catalog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,9 @@ the user that they might be getting a subset of the true result set.

>>> from astroquery.mast import Catalogs
...
>>> catalog_data = Catalogs.query_region("322.49324 12.16683", catalog="HSC", magtype=2) # doctest: +SHOW_WARNINGS
>>> catalog_data = Catalogs.query_region("322.49324 12.16683",
... catalog="HSC",
... magtype=2) # doctest: +SHOW_WARNINGS
InputWarning: Coordinate string is being interpreted as an ICRS coordinate provided in degrees.
MaxResultsWarning: Maximum catalog results returned, may not include all sources within radius.
>>> print(catalog_data[:10])
Expand Down Expand Up @@ -115,8 +117,11 @@ The table to query is a required parameter.

.. doctest-remote-data::

>>> catalog_data = Catalogs.query_region("158.47924 -7.30962", radius=0.1,
... catalog="Panstarrs", data_release="dr1", table="mean")
>>> catalog_data = Catalogs.query_region("158.47924 -7.30962",
... radius=0.1,
... catalog="Panstarrs",
... data_release="dr1",
... table="mean")
>>> print("Number of results:",len(catalog_data))
Number of results: 7007
>>> print(catalog_data[:10]) # doctest: +IGNORE_OUTPUT
Expand Down Expand Up @@ -166,7 +171,9 @@ The TESS Input Catalog (TIC), Disk Detective Catalog, and PanSTARRS Catalog can
>>> from astroquery.mast import Catalogs
...
>>> catalog_data = Catalogs.query_criteria(catalog="Ctl",
... objectname='M101', radius=1, Tmag=[10.75,11])
... objectname='M101',
... radius=1,
... Tmag=[10.75,11])
>>> print(catalog_data)
ID version HIP TYC ... raddflag wdflag objID
--------- -------- --- ------------ ... -------- ------ ---------
Expand All @@ -185,7 +192,9 @@ The TESS Input Catalog (TIC), Disk Detective Catalog, and PanSTARRS Catalog can
>>> from astroquery.mast import Catalogs
...
>>> catalog_data = Catalogs.query_criteria(catalog="DiskDetective",
... objectname="M10",radius=2,state="complete")
... objectname="M10",
... radius=2,
... state="complete")
>>> print(catalog_data) # doctest: +IGNORE_OUTPUT
designation ... ZooniverseURL
------------------- ... ----------------------------------------------------
Expand Down Expand Up @@ -230,11 +239,15 @@ tuples of criteria decorator (min, gte, gt, max, lte, lt, like, contains) and va

.. doctest-remote-data::

>>> catalog_data = Catalogs.query_criteria(coordinates="5.97754 32.53617", radius=0.01,
... catalog="PANSTARRS", table="mean", data_release="dr2",
>>> catalog_data = Catalogs.query_criteria(coordinates="5.97754 32.53617",
... radius=0.01,
... catalog="PANSTARRS",
... table="mean",
... data_release="dr2",
... nStackDetections=[("gte", 2)],
... columns=["objName", "objID", "nStackDetections", "distance"],
... sort_by=[("desc", "distance")], pagesize=15)
... sort_by=[("desc", "distance")],
... pagesize=15)
>>> print(catalog_data[:10]) # doctest: +IGNORE_OUTPUT
objName objID nStackDetections distance
--------------------- ------------------ ---------------- ---------------------
Expand All @@ -259,7 +272,10 @@ Given an HSC Match ID, return all catalog results.

>>> from astroquery.mast import Catalogs
...
>>> catalog_data = Catalogs.query_object("M10", radius=.02, catalog="HSC")
>>> catalog_data = Catalogs.query_object("M10",
... radius=.001,
... catalog="HSC",
... magtype=1)
>>> matchid = catalog_data[0]["MatchID"]
>>> print(matchid)
7542452
Expand Down
86 changes: 47 additions & 39 deletions docs/mast/mast_cut.rst
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,13 @@ not explicitly called for TICA.
>>> from astropy.coordinates import SkyCoord
...
>>> cutout_coord = SkyCoord(107.18696, -70.50919, unit="deg")
>>> hdulist = Tesscut.get_cutouts(coordinates=cutout_coord)
>>> hdulist = Tesscut.get_cutouts(coordinates=cutout_coord, sector=33)
>>> hdulist[0].info() # doctest: +IGNORE_OUTPUT
Filename: <class '_io.BytesIO'>
No. Name Ver Type Cards Dimensions Format
0 PRIMARY 1 PrimaryHDU 56 ()
1 PIXELS 1 BinTableHDU 280 1196R x 12C [D, E, J, 25J, 25E, 25E, 25E, 25E, J, E, E, 38A]
2 APERTURE 1 ImageHDU 81 (5, 5) int32
0 PRIMARY 1 PrimaryHDU 57 ()
1 PIXELS 1 BinTableHDU 281 3495R x 12C [D, E, J, 25J, 25E, 25E, 25E, 25E, J, E, E, 38A]
2 APERTURE 1 ImageHDU 82 (5, 5) int32


For users with time-sensitive targets who would like cutouts from the latest observations,
Expand All @@ -72,7 +72,9 @@ this example shows a request for TICA cutouts:
>>> from astropy.coordinates import SkyCoord
...
>>> cutout_coord = SkyCoord(107.18696, -70.50919, unit="deg")
>>> hdulist = Tesscut.get_cutouts(coordinates=cutout_coord, product='tica')
>>> hdulist = Tesscut.get_cutouts(coordinates=cutout_coord,
... product='tica',
... sector=28)
>>> hdulist[0][0].header['FFI_TYPE'] # doctest: +IGNORE_OUTPUT
'TICA'

Expand All @@ -83,7 +85,7 @@ than a set of coordinates.

>>> from astroquery.mast import Tesscut
...
>>> hdulist = Tesscut.get_cutouts(objectname="TIC 32449963")
>>> hdulist = Tesscut.get_cutouts(objectname="TIC 32449963", sector=37)
>>> hdulist[0].info() # doctest: +IGNORE_OUTPUT
Filename: <class '_io.BytesIO'>
No. Name Ver Type Cards Dimensions Format
Expand All @@ -106,7 +108,9 @@ simply with either the objectname or coordinates.

>>> from astroquery.mast import Tesscut
...
>>> hdulist = Tesscut.get_cutouts(objectname="Eleonora", moving_target=True, size=5, sector=6)
>>> hdulist = Tesscut.get_cutouts(objectname="Eleonora",
... moving_target=True,
... sector=6)
>>> hdulist[0].info() # doctest: +IGNORE_OUTPUT
Filename: <class '_io.BytesIO'>
No. Name Ver Type Cards Dimensions Format
Expand All @@ -121,7 +125,10 @@ parameter will result in an error when set to 'TICA'.

>>> from astroquery.mast import Tesscut
...
>>> hdulist = Tesscut.get_cutouts(objectname="Eleonora", product='tica', moving_target=True, size=5, sector=6)
>>> hdulist = Tesscut.get_cutouts(objectname="Eleonora",
... product='tica',
... moving_target=True,
... sector=6)
Traceback (most recent call last):
...
astroquery.exceptions.InvalidQueryError: Only SPOC is available for moving targets queries.
Expand All @@ -141,12 +148,14 @@ pixel file will be produced for each one.
>>> import astropy.units as u
...
>>> cutout_coord = SkyCoord(107.18696, -70.50919, unit="deg")
>>> manifest = Tesscut.download_cutouts(coordinates=cutout_coord, size=[5, 7]*u.arcmin, sector=9) # doctest: +IGNORE_OUTPUT
>>> manifest = Tesscut.download_cutouts(coordinates=cutout_coord,
... size=[5, 5]*u.arcmin,
... sector=9) # doctest: +IGNORE_OUTPUT
Downloading URL https://mast.stsci.edu/tesscut/api/v0.1/astrocut?ra=107.18696&dec=-70.50919&y=0.08333333333333333&x=0.11666666666666667&units=d&sector=9 to ./tesscut_20210716150026.zip ... [Done]
>>> print(manifest) # doctest: +IGNORE_OUTPUT
Local Path
----------------------------------------------------------
./tess-s0009-4-1_107.186960_-70.509190_21x15_astrocut.fits
./tess-s0009-4-1_107.186960_-70.509190_15x15_astrocut.fits

The query from the example above defaults to downloading cutouts from SPOC. The following example is a query for
the same target from above, but with the product argument passed as TICA to explicitly request for TICA cutouts,
Expand All @@ -159,7 +168,10 @@ and because the TICA products are not available for sectors 1-26, we request cut
>>> import astropy.units as u
...
>>> cutout_coord = SkyCoord(107.18696, -70.50919, unit="deg")
>>> manifest = Tesscut.download_cutouts(coordinates=cutout_coord, product='tica', size=[5, 7]*u.arcmin, sector=27) # doctest: +IGNORE_OUTPUT
>>> manifest = Tesscut.download_cutouts(coordinates=cutout_coord,
... product='tica',
... size=[5, 7]*u.arcmin,
... sector=27) # doctest: +IGNORE_OUTPUT
Downloading URL https://mast.stsci.edu/tesscut/api/v0.1/astrocut?ra=107.18696&dec=-70.50919&y=0.08333333333333333&x=0.11666666666666667&units=d&product=TICA&sector=27 to ./tesscut_20230214150644.zip ... [Done]
>>> print(manifest) # doctest: +IGNORE_OUTPUT
Local Path
Expand Down Expand Up @@ -234,17 +246,6 @@ The following example requests SPOC cutouts for a moving target.
Note that the moving targets functionality is not currently available for TICA,
so the query will always default to SPOC.

.. doctest-remote-data::

>>> from astroquery.mast import Tesscut
...
>>> sector_table = Tesscut.get_sectors(objectname="Ceres", moving_target=True)
>>> print(sector_table)
sectorName sector camera ccd
-------------- ------ ------ ---
tess-s0029-1-4 29 1 4
tess-s0043-3-3 43 3 3
tess-s0044-2-4 44 2 4

Zcut
====
Expand All @@ -270,7 +271,7 @@ If the given coordinate appears in more than one Zcut survey, a FITS file will b
>>> from astropy.coordinates import SkyCoord
...
>>> cutout_coord = SkyCoord(189.49206, 62.20615, unit="deg")
>>> hdulist = Zcut.get_cutouts(coordinates=cutout_coord, size=5)
>>> hdulist = Zcut.get_cutouts(coordinates=cutout_coord, survey='3dhst_goods-n')
>>> hdulist[0].info() # doctest: +IGNORE_OUTPUT
Filename: <class '_io.BytesIO'>
No. Name Ver Type Cards Dimensions Format
Expand All @@ -292,31 +293,37 @@ If a given coordinate appears in more than one Zcut survey, a cutout will be pro
>>> from astropy.coordinates import SkyCoord
...
>>> cutout_coord = SkyCoord(189.49206, 62.20615, unit="deg")
>>> manifest = Zcut.download_cutouts(coordinates=cutout_coord, size=[200, 300], units="px") # doctest: +IGNORE_OUTPUT
>>> manifest = Zcut.download_cutouts(coordinates=cutout_coord,
... size=[5, 10],
... units="px",
... survey="3dhst_goods-n") # doctest: +IGNORE_OUTPUT
Downloading URL https://mast.stsci.edu/zcut/api/v0.1/astrocut?ra=189.49206&dec=62.20615&y=200&x=300&units=px&format=fits to ./zcut_20210125155545.zip ... [Done]
Inflating...
...
>>> print(manifest) # doctest: +IGNORE_OUTPUT
Local Path
-------------------------------------------------------------------------
./candels_gn_30mas_189.492060_62.206150_300.0pix-x-200.0pix_astrocut.fits


.. doctest-remote-data::

>>> from astroquery.mast import Zcut
>>> from astropy.coordinates import SkyCoord
...
>>> cutout_coord = SkyCoord(189.49206, 62.20615, unit="deg")
>>> manifest = Zcut.download_cutouts(coordinates=cutout_coord, size=[200, 300], units="px", form="jpg") # doctest: +IGNORE_OUTPUT
>>> manifest = Zcut.download_cutouts(coordinates=cutout_coord,
... size=[5, 10],
... units="px",
... survey="3dhst_goods-n",
... cutout_format="jpg") # doctest: +IGNORE_OUTPUT
Downloading URL https://mast.stsci.edu/zcut/api/v0.1/astrocut?ra=189.49206&dec=62.20615&y=200&x=300&units=px&format=jpg to ./zcut_20201202132453.zip ... [Done]
...
>>> print(manifest) # doctest: +IGNORE_OUTPUT
Local Path
---------------------------------------------------------------------------------------------------------
./hlsp_candels_hst_acs_gn-tot-30mas_f606w_v1.0_drz_189.492060_62.206150_300.0pix-x-200.0pix_astrocut.jpg
./hlsp_candels_hst_acs_gn-tot-30mas_f814w_v1.0_drz_189.492060_62.206150_300.0pix-x-200.0pix_astrocut.jpg
./hlsp_candels_hst_acs_gn-tot-30mas_f850lp_v1.0_drz_189.492060_62.206150_300.0pix-x-200.0pix_astrocut.jpg
>>> print(manifest)
Local Path
-----------------------------------------------------------------------------------------------------
./hlsp_3dhst_spitzer_irac_goods-n_irac1_v4.0_sc_189.492060_62.206150_10.0pix-x-5.0pix_astrocut.jpg
./hlsp_3dhst_spitzer_irac_goods-n-s2_irac3_v4.0_sc_189.492060_62.206150_10.0pix-x-5.0pix_astrocut.jpg
./hlsp_3dhst_spitzer_irac_goods-n-s1_irac4_v4.0_sc_189.492060_62.206150_10.0pix-x-5.0pix_astrocut.jpg
./hlsp_3dhst_spitzer_irac_goods-n_irac2_v4.0_sc_189.492060_62.206150_10.0pix-x-5.0pix_astrocut.jpg
./hlsp_3dhst_mayall_mosaic_goods-n_u_v4.0_sc_189.492060_62.206150_10.0pix-x-5.0pix_astrocut.jpg
./hlsp_3dhst_subaru_suprimecam_goods-n_rc_v4.0_sc_189.492060_62.206150_10.0pix-x-5.0pix_astrocut.jpg
./hlsp_3dhst_subaru_suprimecam_goods-n_v_v4.0_sc_189.492060_62.206150_10.0pix-x-5.0pix_astrocut.jpg
./hlsp_3dhst_subaru_suprimecam_goods-n_ic_v4.0_sc_189.492060_62.206150_10.0pix-x-5.0pix_astrocut.jpg
./hlsp_3dhst_subaru_suprimecam_goods-n_zp_v4.0_sc_189.492060_62.206150_10.0pix-x-5.0pix_astrocut.jpg
./hlsp_3dhst_subaru_suprimecam_goods-n_b_v4.0_sc_189.492060_62.206150_10.0pix-x-5.0pix_astrocut.jpg


Survey information
Expand Down Expand Up @@ -387,5 +394,6 @@ If the given coordinate appears in more than one product, a cutout will be produ
Local Path
---------------------------------------------------------------------------------
./hst_cutout_skycell-p2007x09y05-ra351d3478-decn28d4978_wfc3_ir_f160w_coarse.fits
./hst_cutout_skycell-p2007x09y05-ra351d3478-decn28d4978_wfc3_ir_f160w.fits
./hst_cutout_skycell-p2007x09y05-ra351d3478-decn28d4978_wfc3_uvis_f606w.fits
./hst_cutout_skycell-p2007x09y05-ra351d3478-decn28d4978_wfc3_uvis_f814w.fits
Loading

0 comments on commit 147546c

Please sign in to comment.