Skip to content

Commit 8de360b

Browse files
committed
Updated unit tests to reflect new timeout arg and cutout size warning.
1 parent 64157c9 commit 8de360b

File tree

2 files changed

+24
-5
lines changed

2 files changed

+24
-5
lines changed

astroquery/mast/cutouts.py

+9-4
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,15 @@ def _parse_cutout_size(size, timeout=None, mission=None):
6868
either pixels or degrees.
6969
"""
7070

71+
# This local variable will change to True if input cutout size exceeds recommended limits for TESS
72+
limit_reached = False
73+
7174
# Making size into an array [ny, nx]
7275
if np.isscalar(size):
7376
size = np.repeat(size, 2)
7477

75-
limit_reached = (size > 30).any()
78+
if mission == 'TESS':
79+
limit_reached = (size > 30).any()
7680

7781
if isinstance(size, u.Quantity):
7882
size = np.atleast_1d(size)
@@ -83,8 +87,9 @@ def _parse_cutout_size(size, timeout=None, mission=None):
8387
# Based on the literature, TESS resolution is approx. 21 arcseconds per pixel.
8488
# We will convert the recommended upper limit for a dimension from pixels
8589
# to the unit being passed.
86-
with u.set_enabled_equivalencies(u.pixel_scale(21 * u.arcsec / u.pixel)):
87-
limit_reached = (size > 30 * u.pixel).any()
90+
if mission == 'TESS':
91+
with u.set_enabled_equivalencies(u.pixel_scale(21 * u.arcsec / u.pixel)):
92+
limit_reached = (size > 30 * u.pixel).any()
8893

8994
if len(size) > 2:
9095
warnings.warn("Too many dimensions in cutout size, only the first two will be used.",
@@ -110,7 +115,7 @@ def _parse_cutout_size(size, timeout=None, mission=None):
110115
else:
111116
raise InvalidQueryError("Cutout size must be in pixels or angular quantity.")
112117

113-
if (mission == 'TESS') & (limit_reached) & (not timeout):
118+
if (limit_reached) & (not timeout):
114119
warnings.warn("You have selected a large cutout size that may result in a timeout error. We suggest limiting"
115120
" the size of your requested cutout, or changing the request timeout limit from its"
116121
" default 600 seconds to something higher, using the timeout argument.", InputWarning)

astroquery/mast/tests/test_mast_remote.py

+15-1
Original file line numberDiff line numberDiff line change
@@ -938,7 +938,7 @@ def test_tesscut_download_cutouts_mt(self, tmpdir):
938938
assert error_tica_mt in str(error_msg.value)
939939

940940
@pytest.mark.parametrize("product", ["tica", "spoc"])
941-
def test_tesscut_get_cutouts(self, product):
941+
def test_tesscut_get_cutouts(self, product, caplog):
942942

943943
coord = SkyCoord(107.18696, -70.50919, unit="deg")
944944

@@ -964,6 +964,11 @@ def test_tesscut_get_cutouts(self, product):
964964
assert len(cutout_hdus_list) >= 1
965965
assert isinstance(cutout_hdus_list[0], fits.HDUList)
966966

967+
# Check that an INFO message is returned when timeout is adjusted
968+
mast.Tesscut.get_cutouts(product=product, coordinates=coord, size=5, timeout=1000)
969+
with caplog.at_level("INFO", logger="astroquery"):
970+
assert "timeout upper limit is being changed" in caplog.text
971+
967972
def test_tesscut_get_cutouts_mt(self):
968973

969974
# Moving target functionality testing
@@ -1016,6 +1021,15 @@ def test_tesscut_get_cutouts_mt(self):
10161021
moving_target=True)
10171022
assert error_tica_mt in str(error_msg.value)
10181023

1024+
@pytest.mark.xfail(raises=InputWarning)
1025+
@pytest.mark.parametrize("product", ["tica", "spoc"])
1026+
@pytest.mark.parametrize("size", [31, 0.2 * u.deg, 5000 * u.arcsec, 20 * u.arcmin])
1027+
def test_tesscut_timeout_param(self, product, size):
1028+
1029+
# Check that a warning comes up when cutout size too big
1030+
coordinates = '60 60'
1031+
mast.Tesscut.get_cutouts(product=product, coordinates=coordinates, size=size)
1032+
10191033
###################
10201034
# ZcutClass tests #
10211035
###################

0 commit comments

Comments
 (0)